1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/interpreter/cppInterpreter.cpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,135 @@ 1.4 +/* 1.5 + * Copyright 1997-2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "incls/_precompiled.incl" 1.29 +#include "incls/_cppInterpreter.cpp.incl" 1.30 + 1.31 +#ifdef CC_INTERP 1.32 +# define __ _masm-> 1.33 + 1.34 +void CppInterpreter::initialize() { 1.35 + if (_code != NULL) return; 1.36 + AbstractInterpreter::initialize(); 1.37 + 1.38 + // generate interpreter 1.39 + { ResourceMark rm; 1.40 + TraceTime timer("Interpreter generation", TraceStartupTime); 1.41 + int code_size = InterpreterCodeSize; 1.42 + NOT_PRODUCT(code_size *= 4;) // debug uses extra interpreter code space 1.43 + _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL, 1.44 + "Interpreter"); 1.45 + InterpreterGenerator g(_code); 1.46 + if (PrintInterpreter) print(); 1.47 + } 1.48 + 1.49 + 1.50 + // Allow c++ interpreter to do one initialization now that switches are set, etc. 1.51 + BytecodeInterpreter start_msg(BytecodeInterpreter::initialize); 1.52 + if (JvmtiExport::can_post_interpreter_events()) 1.53 + BytecodeInterpreter::runWithChecks(&start_msg); 1.54 + else 1.55 + BytecodeInterpreter::run(&start_msg); 1.56 +} 1.57 + 1.58 + 1.59 +address CppInterpreter::_tosca_to_stack [AbstractInterpreter::number_of_result_handlers]; 1.60 +address CppInterpreter::_stack_to_stack [AbstractInterpreter::number_of_result_handlers]; 1.61 +address CppInterpreter::_stack_to_native_abi [AbstractInterpreter::number_of_result_handlers]; 1.62 + 1.63 +CppInterpreterGenerator::CppInterpreterGenerator(StubQueue* _code): AbstractInterpreterGenerator(_code) { 1.64 +} 1.65 + 1.66 +static const BasicType types[Interpreter::number_of_result_handlers] = { 1.67 + T_BOOLEAN, 1.68 + T_CHAR , 1.69 + T_BYTE , 1.70 + T_SHORT , 1.71 + T_INT , 1.72 + T_LONG , 1.73 + T_VOID , 1.74 + T_FLOAT , 1.75 + T_DOUBLE , 1.76 + T_OBJECT 1.77 +}; 1.78 + 1.79 +void CppInterpreterGenerator::generate_all() { 1.80 + AbstractInterpreterGenerator::generate_all(); 1.81 + 1.82 + { CodeletMark cm(_masm, "result handlers for native calls"); 1.83 + // The various result converter stublets. 1.84 + int is_generated[Interpreter::number_of_result_handlers]; 1.85 + memset(is_generated, 0, sizeof(is_generated)); 1.86 + int _tosca_to_stack_is_generated[Interpreter::number_of_result_handlers]; 1.87 + int _stack_to_stack_is_generated[Interpreter::number_of_result_handlers]; 1.88 + int _stack_to_native_abi_is_generated[Interpreter::number_of_result_handlers]; 1.89 + 1.90 + memset(_tosca_to_stack_is_generated, 0, sizeof(_tosca_to_stack_is_generated)); 1.91 + memset(_stack_to_stack_is_generated, 0, sizeof(_stack_to_stack_is_generated)); 1.92 + memset(_stack_to_native_abi_is_generated, 0, sizeof(_stack_to_native_abi_is_generated)); 1.93 + for (int i = 0; i < Interpreter::number_of_result_handlers; i++) { 1.94 + BasicType type = types[i]; 1.95 + if (!is_generated[Interpreter::BasicType_as_index(type)]++) { 1.96 + Interpreter::_native_abi_to_tosca[Interpreter::BasicType_as_index(type)] = generate_result_handler_for(type); 1.97 + } 1.98 + if (!_tosca_to_stack_is_generated[Interpreter::BasicType_as_index(type)]++) { 1.99 + Interpreter::_tosca_to_stack[Interpreter::BasicType_as_index(type)] = generate_tosca_to_stack_converter(type); 1.100 + } 1.101 + if (!_stack_to_stack_is_generated[Interpreter::BasicType_as_index(type)]++) { 1.102 + Interpreter::_stack_to_stack[Interpreter::BasicType_as_index(type)] = generate_stack_to_stack_converter(type); 1.103 + } 1.104 + if (!_stack_to_native_abi_is_generated[Interpreter::BasicType_as_index(type)]++) { 1.105 + Interpreter::_stack_to_native_abi[Interpreter::BasicType_as_index(type)] = generate_stack_to_native_abi_converter(type); 1.106 + } 1.107 + } 1.108 + } 1.109 + 1.110 + 1.111 +#define method_entry(kind) Interpreter::_entry_table[Interpreter::kind] = generate_method_entry(Interpreter::kind) 1.112 + 1.113 + { CodeletMark cm(_masm, "(kind = frame_manager)"); 1.114 + // all non-native method kinds 1.115 + method_entry(zerolocals); 1.116 + method_entry(zerolocals_synchronized); 1.117 + method_entry(empty); 1.118 + method_entry(accessor); 1.119 + method_entry(abstract); 1.120 + method_entry(java_lang_math_sin ); 1.121 + method_entry(java_lang_math_cos ); 1.122 + method_entry(java_lang_math_tan ); 1.123 + method_entry(java_lang_math_abs ); 1.124 + method_entry(java_lang_math_sqrt ); 1.125 + method_entry(java_lang_math_log ); 1.126 + method_entry(java_lang_math_log10 ); 1.127 + Interpreter::_native_entry_begin = Interpreter::code()->code_end(); 1.128 + method_entry(native); 1.129 + method_entry(native_synchronized); 1.130 + Interpreter::_native_entry_end = Interpreter::code()->code_end(); 1.131 + } 1.132 + 1.133 + 1.134 +#undef method_entry 1.135 + 1.136 +} 1.137 + 1.138 +#endif // CC_INTERP