src/share/vm/interpreter/cppInterpreter.cpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/interpreter/cppInterpreter.cpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,144 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "precompiled.hpp"
    1.29 +#include "interpreter/bytecodeInterpreter.hpp"
    1.30 +#include "interpreter/interpreter.hpp"
    1.31 +#include "interpreter/interpreterGenerator.hpp"
    1.32 +#include "interpreter/interpreterRuntime.hpp"
    1.33 +
    1.34 +#ifdef CC_INTERP
    1.35 +# define __ _masm->
    1.36 +
    1.37 +void CppInterpreter::initialize() {
    1.38 +  if (_code != NULL) return;
    1.39 +  AbstractInterpreter::initialize();
    1.40 +
    1.41 +  // generate interpreter
    1.42 +  { ResourceMark rm;
    1.43 +    TraceTime timer("Interpreter generation", TraceStartupTime);
    1.44 +    int code_size = InterpreterCodeSize;
    1.45 +    NOT_PRODUCT(code_size *= 4;)  // debug uses extra interpreter code space
    1.46 +    _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL,
    1.47 +                          "Interpreter");
    1.48 +    InterpreterGenerator g(_code);
    1.49 +    if (PrintInterpreter) print();
    1.50 +  }
    1.51 +
    1.52 +
    1.53 +  // Allow c++ interpreter to do one initialization now that switches are set, etc.
    1.54 +  BytecodeInterpreter start_msg(BytecodeInterpreter::initialize);
    1.55 +  if (JvmtiExport::can_post_interpreter_events())
    1.56 +    BytecodeInterpreter::runWithChecks(&start_msg);
    1.57 +  else
    1.58 +    BytecodeInterpreter::run(&start_msg);
    1.59 +}
    1.60 +
    1.61 +
    1.62 +address    CppInterpreter::_tosca_to_stack         [AbstractInterpreter::number_of_result_handlers];
    1.63 +address    CppInterpreter::_stack_to_stack         [AbstractInterpreter::number_of_result_handlers];
    1.64 +address    CppInterpreter::_stack_to_native_abi    [AbstractInterpreter::number_of_result_handlers];
    1.65 +
    1.66 +CppInterpreterGenerator::CppInterpreterGenerator(StubQueue* _code): AbstractInterpreterGenerator(_code) {
    1.67 +}
    1.68 +
    1.69 +static const BasicType types[Interpreter::number_of_result_handlers] = {
    1.70 +  T_BOOLEAN,
    1.71 +  T_CHAR   ,
    1.72 +  T_BYTE   ,
    1.73 +  T_SHORT  ,
    1.74 +  T_INT    ,
    1.75 +  T_LONG   ,
    1.76 +  T_VOID   ,
    1.77 +  T_FLOAT  ,
    1.78 +  T_DOUBLE ,
    1.79 +  T_OBJECT
    1.80 +};
    1.81 +
    1.82 +void CppInterpreterGenerator::generate_all() {
    1.83 +  AbstractInterpreterGenerator::generate_all();
    1.84 +
    1.85 +  { CodeletMark cm(_masm, "result handlers for native calls");
    1.86 +    // The various result converter stublets.
    1.87 +    int is_generated[Interpreter::number_of_result_handlers];
    1.88 +    memset(is_generated, 0, sizeof(is_generated));
    1.89 +    int _tosca_to_stack_is_generated[Interpreter::number_of_result_handlers];
    1.90 +    int _stack_to_stack_is_generated[Interpreter::number_of_result_handlers];
    1.91 +    int _stack_to_native_abi_is_generated[Interpreter::number_of_result_handlers];
    1.92 +
    1.93 +    memset(_tosca_to_stack_is_generated, 0, sizeof(_tosca_to_stack_is_generated));
    1.94 +    memset(_stack_to_stack_is_generated, 0, sizeof(_stack_to_stack_is_generated));
    1.95 +    memset(_stack_to_native_abi_is_generated, 0, sizeof(_stack_to_native_abi_is_generated));
    1.96 +    for (int i = 0; i < Interpreter::number_of_result_handlers; i++) {
    1.97 +      BasicType type = types[i];
    1.98 +      if (!is_generated[Interpreter::BasicType_as_index(type)]++) {
    1.99 +        Interpreter::_native_abi_to_tosca[Interpreter::BasicType_as_index(type)] = generate_result_handler_for(type);
   1.100 +      }
   1.101 +      if (!_tosca_to_stack_is_generated[Interpreter::BasicType_as_index(type)]++) {
   1.102 +        Interpreter::_tosca_to_stack[Interpreter::BasicType_as_index(type)] = generate_tosca_to_stack_converter(type);
   1.103 +      }
   1.104 +      if (!_stack_to_stack_is_generated[Interpreter::BasicType_as_index(type)]++) {
   1.105 +        Interpreter::_stack_to_stack[Interpreter::BasicType_as_index(type)] = generate_stack_to_stack_converter(type);
   1.106 +      }
   1.107 +      if (!_stack_to_native_abi_is_generated[Interpreter::BasicType_as_index(type)]++) {
   1.108 +        Interpreter::_stack_to_native_abi[Interpreter::BasicType_as_index(type)] = generate_stack_to_native_abi_converter(type);
   1.109 +      }
   1.110 +    }
   1.111 +  }
   1.112 +
   1.113 +
   1.114 +#define method_entry(kind) Interpreter::_entry_table[Interpreter::kind] = generate_method_entry(Interpreter::kind)
   1.115 +
   1.116 +  { CodeletMark cm(_masm, "(kind = frame_manager)");
   1.117 +    // all non-native method kinds
   1.118 +    method_entry(zerolocals);
   1.119 +    method_entry(zerolocals_synchronized);
   1.120 +    method_entry(empty);
   1.121 +    method_entry(accessor);
   1.122 +    method_entry(abstract);
   1.123 +    method_entry(java_lang_math_sin   );
   1.124 +    method_entry(java_lang_math_cos   );
   1.125 +    method_entry(java_lang_math_tan   );
   1.126 +    method_entry(java_lang_math_abs   );
   1.127 +    method_entry(java_lang_math_sqrt  );
   1.128 +    method_entry(java_lang_math_log   );
   1.129 +    method_entry(java_lang_math_log10 );
   1.130 +    method_entry(java_lang_math_pow );
   1.131 +    method_entry(java_lang_math_exp );
   1.132 +    method_entry(java_lang_ref_reference_get);
   1.133 +
   1.134 +    initialize_method_handle_entries();
   1.135 +
   1.136 +    Interpreter::_native_entry_begin = Interpreter::code()->code_end();
   1.137 +    method_entry(native);
   1.138 +    method_entry(native_synchronized);
   1.139 +    Interpreter::_native_entry_end = Interpreter::code()->code_end();
   1.140 +  }
   1.141 +
   1.142 +
   1.143 +#undef method_entry
   1.144 +
   1.145 +}
   1.146 +
   1.147 +#endif // CC_INTERP

mercurial