duke@435: /* johnc@2781: * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #include "precompiled.hpp" stefank@2314: #include "interpreter/bytecodeInterpreter.hpp" stefank@2314: #include "interpreter/interpreter.hpp" stefank@2314: #include "interpreter/interpreterGenerator.hpp" stefank@2314: #include "interpreter/interpreterRuntime.hpp" duke@435: duke@435: #ifdef CC_INTERP duke@435: # define __ _masm-> duke@435: duke@435: void CppInterpreter::initialize() { duke@435: if (_code != NULL) return; duke@435: AbstractInterpreter::initialize(); duke@435: duke@435: // generate interpreter duke@435: { ResourceMark rm; duke@435: TraceTime timer("Interpreter generation", TraceStartupTime); duke@435: int code_size = InterpreterCodeSize; duke@435: NOT_PRODUCT(code_size *= 4;) // debug uses extra interpreter code space duke@435: _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL, duke@435: "Interpreter"); duke@435: InterpreterGenerator g(_code); duke@435: if (PrintInterpreter) print(); duke@435: } duke@435: duke@435: duke@435: // Allow c++ interpreter to do one initialization now that switches are set, etc. duke@435: BytecodeInterpreter start_msg(BytecodeInterpreter::initialize); duke@435: if (JvmtiExport::can_post_interpreter_events()) duke@435: BytecodeInterpreter::runWithChecks(&start_msg); duke@435: else duke@435: BytecodeInterpreter::run(&start_msg); duke@435: } duke@435: duke@435: duke@435: address CppInterpreter::_tosca_to_stack [AbstractInterpreter::number_of_result_handlers]; duke@435: address CppInterpreter::_stack_to_stack [AbstractInterpreter::number_of_result_handlers]; duke@435: address CppInterpreter::_stack_to_native_abi [AbstractInterpreter::number_of_result_handlers]; duke@435: duke@435: CppInterpreterGenerator::CppInterpreterGenerator(StubQueue* _code): AbstractInterpreterGenerator(_code) { duke@435: } duke@435: duke@435: static const BasicType types[Interpreter::number_of_result_handlers] = { duke@435: T_BOOLEAN, duke@435: T_CHAR , duke@435: T_BYTE , duke@435: T_SHORT , duke@435: T_INT , duke@435: T_LONG , duke@435: T_VOID , duke@435: T_FLOAT , duke@435: T_DOUBLE , duke@435: T_OBJECT duke@435: }; duke@435: duke@435: void CppInterpreterGenerator::generate_all() { duke@435: AbstractInterpreterGenerator::generate_all(); duke@435: duke@435: { CodeletMark cm(_masm, "result handlers for native calls"); duke@435: // The various result converter stublets. duke@435: int is_generated[Interpreter::number_of_result_handlers]; duke@435: memset(is_generated, 0, sizeof(is_generated)); duke@435: int _tosca_to_stack_is_generated[Interpreter::number_of_result_handlers]; duke@435: int _stack_to_stack_is_generated[Interpreter::number_of_result_handlers]; duke@435: int _stack_to_native_abi_is_generated[Interpreter::number_of_result_handlers]; duke@435: duke@435: memset(_tosca_to_stack_is_generated, 0, sizeof(_tosca_to_stack_is_generated)); duke@435: memset(_stack_to_stack_is_generated, 0, sizeof(_stack_to_stack_is_generated)); duke@435: memset(_stack_to_native_abi_is_generated, 0, sizeof(_stack_to_native_abi_is_generated)); duke@435: for (int i = 0; i < Interpreter::number_of_result_handlers; i++) { duke@435: BasicType type = types[i]; duke@435: if (!is_generated[Interpreter::BasicType_as_index(type)]++) { duke@435: Interpreter::_native_abi_to_tosca[Interpreter::BasicType_as_index(type)] = generate_result_handler_for(type); duke@435: } duke@435: if (!_tosca_to_stack_is_generated[Interpreter::BasicType_as_index(type)]++) { duke@435: Interpreter::_tosca_to_stack[Interpreter::BasicType_as_index(type)] = generate_tosca_to_stack_converter(type); duke@435: } duke@435: if (!_stack_to_stack_is_generated[Interpreter::BasicType_as_index(type)]++) { duke@435: Interpreter::_stack_to_stack[Interpreter::BasicType_as_index(type)] = generate_stack_to_stack_converter(type); duke@435: } duke@435: if (!_stack_to_native_abi_is_generated[Interpreter::BasicType_as_index(type)]++) { duke@435: Interpreter::_stack_to_native_abi[Interpreter::BasicType_as_index(type)] = generate_stack_to_native_abi_converter(type); duke@435: } duke@435: } duke@435: } duke@435: duke@435: duke@435: #define method_entry(kind) Interpreter::_entry_table[Interpreter::kind] = generate_method_entry(Interpreter::kind) duke@435: duke@435: { CodeletMark cm(_masm, "(kind = frame_manager)"); duke@435: // all non-native method kinds duke@435: method_entry(zerolocals); duke@435: method_entry(zerolocals_synchronized); duke@435: method_entry(empty); duke@435: method_entry(accessor); duke@435: method_entry(abstract); duke@435: method_entry(java_lang_math_sin ); duke@435: method_entry(java_lang_math_cos ); duke@435: method_entry(java_lang_math_tan ); duke@435: method_entry(java_lang_math_abs ); duke@435: method_entry(java_lang_math_sqrt ); duke@435: method_entry(java_lang_math_log ); duke@435: method_entry(java_lang_math_log10 ); twisti@4237: method_entry(java_lang_math_pow ); twisti@4237: method_entry(java_lang_math_exp ); johnc@2781: method_entry(java_lang_ref_reference_get); twisti@4237: twisti@4237: initialize_method_handle_entries(); twisti@4237: duke@435: Interpreter::_native_entry_begin = Interpreter::code()->code_end(); duke@435: method_entry(native); duke@435: method_entry(native_synchronized); duke@435: Interpreter::_native_entry_end = Interpreter::code()->code_end(); duke@435: } duke@435: duke@435: duke@435: #undef method_entry duke@435: duke@435: } duke@435: duke@435: #endif // CC_INTERP