1
|
1 |
/*
|
|
2 |
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
#include "incls/_precompiled.incl"
|
|
26 |
#include "incls/_cppInterpreter.cpp.incl"
|
|
27 |
|
|
28 |
#ifdef CC_INTERP
|
|
29 |
# define __ _masm->
|
|
30 |
|
|
31 |
void CppInterpreter::initialize() {
|
|
32 |
if (_code != NULL) return;
|
|
33 |
AbstractInterpreter::initialize();
|
|
34 |
|
|
35 |
// generate interpreter
|
|
36 |
{ ResourceMark rm;
|
|
37 |
TraceTime timer("Interpreter generation", TraceStartupTime);
|
|
38 |
int code_size = InterpreterCodeSize;
|
|
39 |
NOT_PRODUCT(code_size *= 4;) // debug uses extra interpreter code space
|
|
40 |
_code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL,
|
|
41 |
"Interpreter");
|
|
42 |
InterpreterGenerator g(_code);
|
|
43 |
if (PrintInterpreter) print();
|
|
44 |
}
|
|
45 |
|
|
46 |
|
|
47 |
// Allow c++ interpreter to do one initialization now that switches are set, etc.
|
|
48 |
BytecodeInterpreter start_msg(BytecodeInterpreter::initialize);
|
|
49 |
if (JvmtiExport::can_post_interpreter_events())
|
|
50 |
BytecodeInterpreter::runWithChecks(&start_msg);
|
|
51 |
else
|
|
52 |
BytecodeInterpreter::run(&start_msg);
|
|
53 |
}
|
|
54 |
|
|
55 |
|
|
56 |
address CppInterpreter::_tosca_to_stack [AbstractInterpreter::number_of_result_handlers];
|
|
57 |
address CppInterpreter::_stack_to_stack [AbstractInterpreter::number_of_result_handlers];
|
|
58 |
address CppInterpreter::_stack_to_native_abi [AbstractInterpreter::number_of_result_handlers];
|
|
59 |
|
|
60 |
CppInterpreterGenerator::CppInterpreterGenerator(StubQueue* _code): AbstractInterpreterGenerator(_code) {
|
|
61 |
}
|
|
62 |
|
|
63 |
static const BasicType types[Interpreter::number_of_result_handlers] = {
|
|
64 |
T_BOOLEAN,
|
|
65 |
T_CHAR ,
|
|
66 |
T_BYTE ,
|
|
67 |
T_SHORT ,
|
|
68 |
T_INT ,
|
|
69 |
T_LONG ,
|
|
70 |
T_VOID ,
|
|
71 |
T_FLOAT ,
|
|
72 |
T_DOUBLE ,
|
|
73 |
T_OBJECT
|
|
74 |
};
|
|
75 |
|
|
76 |
void CppInterpreterGenerator::generate_all() {
|
|
77 |
AbstractInterpreterGenerator::generate_all();
|
|
78 |
|
|
79 |
{ CodeletMark cm(_masm, "result handlers for native calls");
|
|
80 |
// The various result converter stublets.
|
|
81 |
int is_generated[Interpreter::number_of_result_handlers];
|
|
82 |
memset(is_generated, 0, sizeof(is_generated));
|
|
83 |
int _tosca_to_stack_is_generated[Interpreter::number_of_result_handlers];
|
|
84 |
int _stack_to_stack_is_generated[Interpreter::number_of_result_handlers];
|
|
85 |
int _stack_to_native_abi_is_generated[Interpreter::number_of_result_handlers];
|
|
86 |
|
|
87 |
memset(_tosca_to_stack_is_generated, 0, sizeof(_tosca_to_stack_is_generated));
|
|
88 |
memset(_stack_to_stack_is_generated, 0, sizeof(_stack_to_stack_is_generated));
|
|
89 |
memset(_stack_to_native_abi_is_generated, 0, sizeof(_stack_to_native_abi_is_generated));
|
|
90 |
for (int i = 0; i < Interpreter::number_of_result_handlers; i++) {
|
|
91 |
BasicType type = types[i];
|
|
92 |
if (!is_generated[Interpreter::BasicType_as_index(type)]++) {
|
|
93 |
Interpreter::_native_abi_to_tosca[Interpreter::BasicType_as_index(type)] = generate_result_handler_for(type);
|
|
94 |
}
|
|
95 |
if (!_tosca_to_stack_is_generated[Interpreter::BasicType_as_index(type)]++) {
|
|
96 |
Interpreter::_tosca_to_stack[Interpreter::BasicType_as_index(type)] = generate_tosca_to_stack_converter(type);
|
|
97 |
}
|
|
98 |
if (!_stack_to_stack_is_generated[Interpreter::BasicType_as_index(type)]++) {
|
|
99 |
Interpreter::_stack_to_stack[Interpreter::BasicType_as_index(type)] = generate_stack_to_stack_converter(type);
|
|
100 |
}
|
|
101 |
if (!_stack_to_native_abi_is_generated[Interpreter::BasicType_as_index(type)]++) {
|
|
102 |
Interpreter::_stack_to_native_abi[Interpreter::BasicType_as_index(type)] = generate_stack_to_native_abi_converter(type);
|
|
103 |
}
|
|
104 |
}
|
|
105 |
}
|
|
106 |
|
|
107 |
|
|
108 |
#define method_entry(kind) Interpreter::_entry_table[Interpreter::kind] = generate_method_entry(Interpreter::kind)
|
|
109 |
|
|
110 |
{ CodeletMark cm(_masm, "(kind = frame_manager)");
|
|
111 |
// all non-native method kinds
|
|
112 |
method_entry(zerolocals);
|
|
113 |
method_entry(zerolocals_synchronized);
|
|
114 |
method_entry(empty);
|
|
115 |
method_entry(accessor);
|
|
116 |
method_entry(abstract);
|
|
117 |
method_entry(java_lang_math_sin );
|
|
118 |
method_entry(java_lang_math_cos );
|
|
119 |
method_entry(java_lang_math_tan );
|
|
120 |
method_entry(java_lang_math_abs );
|
|
121 |
method_entry(java_lang_math_sqrt );
|
|
122 |
method_entry(java_lang_math_log );
|
|
123 |
method_entry(java_lang_math_log10 );
|
|
124 |
Interpreter::_native_entry_begin = Interpreter::code()->code_end();
|
|
125 |
method_entry(native);
|
|
126 |
method_entry(native_synchronized);
|
|
127 |
Interpreter::_native_entry_end = Interpreter::code()->code_end();
|
|
128 |
}
|
|
129 |
|
|
130 |
|
|
131 |
#undef method_entry
|
|
132 |
|
|
133 |
}
|
|
134 |
|
|
135 |
#endif // CC_INTERP
|