author | rehn |
Tue, 15 Mar 2016 14:41:07 +0100 | |
changeset 37161 | e881f320966e |
parent 36178 | 9739f8c767da |
child 37480 | 291ee208fb72 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
35479
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
2 |
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
31620
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
26 |
#include "code/codeCacheExtensions.hpp" |
7397 | 27 |
#include "interpreter/interpreter.hpp" |
28 |
#include "interpreter/interpreterRuntime.hpp" |
|
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
24424
diff
changeset
|
29 |
#include "interpreter/interp_masm.hpp" |
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
24424
diff
changeset
|
30 |
#include "interpreter/templateInterpreter.hpp" |
35214 | 31 |
#include "interpreter/templateInterpreterGenerator.hpp" |
7397 | 32 |
#include "interpreter/templateTable.hpp" |
35479
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
33 |
#include "memory/resourceArea.hpp" |
37161
e881f320966e
8150015: Integrate TraceTime with Unified Logging more seamlessly
rehn
parents:
36178
diff
changeset
|
34 |
#include "runtime/timerTrace.hpp" |
1 | 35 |
|
36 |
#ifndef CC_INTERP |
|
37 |
||
38 |
# define __ _masm-> |
|
39 |
||
40 |
void TemplateInterpreter::initialize() { |
|
41 |
if (_code != NULL) return; |
|
42 |
// assertions |
|
43 |
assert((int)Bytecodes::number_of_codes <= (int)DispatchTable::length, |
|
44 |
"dispatch table too small"); |
|
45 |
||
46 |
AbstractInterpreter::initialize(); |
|
47 |
||
48 |
TemplateTable::initialize(); |
|
49 |
||
50 |
// generate interpreter |
|
51 |
{ ResourceMark rm; |
|
37161
e881f320966e
8150015: Integrate TraceTime with Unified Logging more seamlessly
rehn
parents:
36178
diff
changeset
|
52 |
TraceTime timer("Interpreter generation", TRACETIME_LOG(Info, startuptime)); |
1 | 53 |
int code_size = InterpreterCodeSize; |
54 |
NOT_PRODUCT(code_size *= 4;) // debug uses extra interpreter code space |
|
31620
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
55 |
#if INCLUDE_JVMTI |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
56 |
if (CodeCacheExtensions::saving_generated_interpreter()) { |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
57 |
// May requires several versions of the codelets. |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
58 |
// Final size will automatically be optimized. |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
59 |
code_size *= 2; |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
60 |
} |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
61 |
#endif |
1 | 62 |
_code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL, |
63 |
"Interpreter"); |
|
35214 | 64 |
TemplateInterpreterGenerator g(_code); |
31620
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
65 |
} |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
66 |
if (PrintInterpreter) { |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
67 |
if (CodeCacheExtensions::saving_generated_interpreter() && |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
68 |
CodeCacheExtensions::use_pregenerated_interpreter()) { |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
69 |
ResourceMark rm; |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
70 |
tty->print("Printing the newly generated interpreter first"); |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
71 |
print(); |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
72 |
tty->print("Printing the pregenerated interpreter next"); |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
73 |
} |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
74 |
} |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
75 |
|
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
76 |
// Install the pregenerated interpreter code before printing it |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
77 |
CodeCacheExtensions::complete_step(CodeCacheExtensionsSteps::TemplateInterpreter); |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
78 |
|
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
79 |
if (PrintInterpreter) { |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
80 |
ResourceMark rm; |
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
25950
diff
changeset
|
81 |
print(); |
1 | 82 |
} |
83 |
||
84 |
// initialize dispatch table |
|
85 |
_active_table = _normal_table; |
|
86 |
} |
|
87 |
||
88 |
//------------------------------------------------------------------------------------------------------------------------ |
|
89 |
// Implementation of EntryPoint |
|
90 |
||
91 |
EntryPoint::EntryPoint() { |
|
92 |
assert(number_of_states == 9, "check the code below"); |
|
93 |
_entry[btos] = NULL; |
|
94 |
_entry[ctos] = NULL; |
|
95 |
_entry[stos] = NULL; |
|
96 |
_entry[atos] = NULL; |
|
97 |
_entry[itos] = NULL; |
|
98 |
_entry[ltos] = NULL; |
|
99 |
_entry[ftos] = NULL; |
|
100 |
_entry[dtos] = NULL; |
|
101 |
_entry[vtos] = NULL; |
|
102 |
} |
|
103 |
||
104 |
||
105 |
EntryPoint::EntryPoint(address bentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry) { |
|
106 |
assert(number_of_states == 9, "check the code below"); |
|
107 |
_entry[btos] = bentry; |
|
108 |
_entry[ctos] = centry; |
|
109 |
_entry[stos] = sentry; |
|
110 |
_entry[atos] = aentry; |
|
111 |
_entry[itos] = ientry; |
|
112 |
_entry[ltos] = lentry; |
|
113 |
_entry[ftos] = fentry; |
|
114 |
_entry[dtos] = dentry; |
|
115 |
_entry[vtos] = ventry; |
|
116 |
} |
|
117 |
||
118 |
||
119 |
void EntryPoint::set_entry(TosState state, address entry) { |
|
120 |
assert(0 <= state && state < number_of_states, "state out of bounds"); |
|
121 |
_entry[state] = entry; |
|
122 |
} |
|
123 |
||
124 |
||
125 |
address EntryPoint::entry(TosState state) const { |
|
126 |
assert(0 <= state && state < number_of_states, "state out of bounds"); |
|
127 |
return _entry[state]; |
|
128 |
} |
|
129 |
||
130 |
||
131 |
void EntryPoint::print() { |
|
132 |
tty->print("["); |
|
133 |
for (int i = 0; i < number_of_states; i++) { |
|
134 |
if (i > 0) tty->print(", "); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
21198
diff
changeset
|
135 |
tty->print(INTPTR_FORMAT, p2i(_entry[i])); |
1 | 136 |
} |
137 |
tty->print("]"); |
|
138 |
} |
|
139 |
||
140 |
||
141 |
bool EntryPoint::operator == (const EntryPoint& y) { |
|
142 |
int i = number_of_states; |
|
143 |
while (i-- > 0) { |
|
144 |
if (_entry[i] != y._entry[i]) return false; |
|
145 |
} |
|
146 |
return true; |
|
147 |
} |
|
148 |
||
149 |
||
150 |
//------------------------------------------------------------------------------------------------------------------------ |
|
151 |
// Implementation of DispatchTable |
|
152 |
||
153 |
EntryPoint DispatchTable::entry(int i) const { |
|
154 |
assert(0 <= i && i < length, "index out of bounds"); |
|
155 |
return |
|
156 |
EntryPoint( |
|
157 |
_table[btos][i], |
|
158 |
_table[ctos][i], |
|
159 |
_table[stos][i], |
|
160 |
_table[atos][i], |
|
161 |
_table[itos][i], |
|
162 |
_table[ltos][i], |
|
163 |
_table[ftos][i], |
|
164 |
_table[dtos][i], |
|
165 |
_table[vtos][i] |
|
166 |
); |
|
167 |
} |
|
168 |
||
169 |
||
170 |
void DispatchTable::set_entry(int i, EntryPoint& entry) { |
|
171 |
assert(0 <= i && i < length, "index out of bounds"); |
|
172 |
assert(number_of_states == 9, "check the code below"); |
|
173 |
_table[btos][i] = entry.entry(btos); |
|
174 |
_table[ctos][i] = entry.entry(ctos); |
|
175 |
_table[stos][i] = entry.entry(stos); |
|
176 |
_table[atos][i] = entry.entry(atos); |
|
177 |
_table[itos][i] = entry.entry(itos); |
|
178 |
_table[ltos][i] = entry.entry(ltos); |
|
179 |
_table[ftos][i] = entry.entry(ftos); |
|
180 |
_table[dtos][i] = entry.entry(dtos); |
|
181 |
_table[vtos][i] = entry.entry(vtos); |
|
182 |
} |
|
183 |
||
184 |
||
185 |
bool DispatchTable::operator == (DispatchTable& y) { |
|
186 |
int i = length; |
|
187 |
while (i-- > 0) { |
|
188 |
EntryPoint t = y.entry(i); // for compiler compatibility (BugId 4150096) |
|
189 |
if (!(entry(i) == t)) return false; |
|
190 |
} |
|
191 |
return true; |
|
192 |
} |
|
193 |
||
194 |
address TemplateInterpreter::_remove_activation_entry = NULL; |
|
195 |
address TemplateInterpreter::_remove_activation_preserving_args_entry = NULL; |
|
196 |
||
197 |
||
198 |
address TemplateInterpreter::_throw_ArrayIndexOutOfBoundsException_entry = NULL; |
|
199 |
address TemplateInterpreter::_throw_ArrayStoreException_entry = NULL; |
|
200 |
address TemplateInterpreter::_throw_ArithmeticException_entry = NULL; |
|
201 |
address TemplateInterpreter::_throw_ClassCastException_entry = NULL; |
|
202 |
address TemplateInterpreter::_throw_NullPointerException_entry = NULL; |
|
203 |
address TemplateInterpreter::_throw_StackOverflowError_entry = NULL; |
|
204 |
address TemplateInterpreter::_throw_exception_entry = NULL; |
|
205 |
||
206 |
#ifndef PRODUCT |
|
207 |
EntryPoint TemplateInterpreter::_trace_code; |
|
208 |
#endif // !PRODUCT |
|
209 |
EntryPoint TemplateInterpreter::_return_entry[TemplateInterpreter::number_of_return_entries]; |
|
210 |
EntryPoint TemplateInterpreter::_earlyret_entry; |
|
211 |
EntryPoint TemplateInterpreter::_deopt_entry [TemplateInterpreter::number_of_deopt_entries ]; |
|
212 |
EntryPoint TemplateInterpreter::_continuation_entry; |
|
213 |
EntryPoint TemplateInterpreter::_safept_entry; |
|
214 |
||
21198
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
215 |
address TemplateInterpreter::_invoke_return_entry[TemplateInterpreter::number_of_return_addrs]; |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
216 |
address TemplateInterpreter::_invokeinterface_return_entry[TemplateInterpreter::number_of_return_addrs]; |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
217 |
address TemplateInterpreter::_invokedynamic_return_entry[TemplateInterpreter::number_of_return_addrs]; |
1 | 218 |
|
219 |
DispatchTable TemplateInterpreter::_active_table; |
|
220 |
DispatchTable TemplateInterpreter::_normal_table; |
|
221 |
DispatchTable TemplateInterpreter::_safept_table; |
|
222 |
address TemplateInterpreter::_wentry_point[DispatchTable::length]; |
|
223 |
||
224 |
||
225 |
//------------------------------------------------------------------------------------------------------------------------ |
|
226 |
// Entry points |
|
227 |
||
21198
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
228 |
/** |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
229 |
* Returns the return entry table for the given invoke bytecode. |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
230 |
*/ |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
231 |
address* TemplateInterpreter::invoke_return_entry_table_for(Bytecodes::Code code) { |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
232 |
switch (code) { |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
233 |
case Bytecodes::_invokestatic: |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
234 |
case Bytecodes::_invokespecial: |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
235 |
case Bytecodes::_invokevirtual: |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
236 |
case Bytecodes::_invokehandle: |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
237 |
return Interpreter::invoke_return_entry_table(); |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
238 |
case Bytecodes::_invokeinterface: |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
239 |
return Interpreter::invokeinterface_return_entry_table(); |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
240 |
case Bytecodes::_invokedynamic: |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
241 |
return Interpreter::invokedynamic_return_entry_table(); |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
242 |
default: |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32391
diff
changeset
|
243 |
fatal("invalid bytecode: %s", Bytecodes::name(code)); |
21198
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
244 |
return NULL; |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
245 |
} |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
246 |
} |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
247 |
|
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
248 |
/** |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
249 |
* Returns the return entry address for the given top-of-stack state and bytecode. |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
250 |
*/ |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
251 |
address TemplateInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) { |
1 | 252 |
guarantee(0 <= length && length < Interpreter::number_of_return_entries, "illegal length"); |
21198
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
253 |
const int index = TosState_as_index(state); |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
254 |
switch (code) { |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
255 |
case Bytecodes::_invokestatic: |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
256 |
case Bytecodes::_invokespecial: |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
257 |
case Bytecodes::_invokevirtual: |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
258 |
case Bytecodes::_invokehandle: |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
259 |
return _invoke_return_entry[index]; |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
260 |
case Bytecodes::_invokeinterface: |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
261 |
return _invokeinterface_return_entry[index]; |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
262 |
case Bytecodes::_invokedynamic: |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
263 |
return _invokedynamic_return_entry[index]; |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
264 |
default: |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32391
diff
changeset
|
265 |
assert(!Bytecodes::is_invoke(code), "invoke instructions should be handled separately: %s", Bytecodes::name(code)); |
21198
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
266 |
return _return_entry[length].entry(state); |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
18507
diff
changeset
|
267 |
} |
1 | 268 |
} |
269 |
||
270 |
||
271 |
address TemplateInterpreter::deopt_entry(TosState state, int length) { |
|
272 |
guarantee(0 <= length && length < Interpreter::number_of_deopt_entries, "illegal length"); |
|
273 |
return _deopt_entry[length].entry(state); |
|
274 |
} |
|
275 |
||
276 |
//------------------------------------------------------------------------------------------------------------------------ |
|
277 |
// Suport for invokes |
|
278 |
||
279 |
int TemplateInterpreter::TosState_as_index(TosState state) { |
|
280 |
assert( state < number_of_states , "Invalid state in TosState_as_index"); |
|
281 |
assert(0 <= (int)state && (int)state < TemplateInterpreter::number_of_return_addrs, "index out of bounds"); |
|
282 |
return (int)state; |
|
283 |
} |
|
284 |
||
285 |
||
286 |
//------------------------------------------------------------------------------------------------------------------------ |
|
287 |
// Safepoint suppport |
|
288 |
||
289 |
static inline void copy_table(address* from, address* to, int size) { |
|
290 |
// Copy non-overlapping tables. The copy has to occur word wise for MT safety. |
|
291 |
while (size-- > 0) *to++ = *from++; |
|
292 |
} |
|
293 |
||
294 |
void TemplateInterpreter::notice_safepoints() { |
|
295 |
if (!_notice_safepoints) { |
|
296 |
// switch to safepoint dispatch table |
|
297 |
_notice_safepoints = true; |
|
298 |
copy_table((address*)&_safept_table, (address*)&_active_table, sizeof(_active_table) / sizeof(address)); |
|
299 |
} |
|
300 |
} |
|
301 |
||
302 |
// switch from the dispatch table which notices safepoints back to the |
|
303 |
// normal dispatch table. So that we can notice single stepping points, |
|
304 |
// keep the safepoint dispatch table if we are single stepping in JVMTI. |
|
305 |
// Note that the should_post_single_step test is exactly as fast as the |
|
306 |
// JvmtiExport::_enabled test and covers both cases. |
|
307 |
void TemplateInterpreter::ignore_safepoints() { |
|
308 |
if (_notice_safepoints) { |
|
309 |
if (!JvmtiExport::should_post_single_step()) { |
|
310 |
// switch to normal dispatch table |
|
311 |
_notice_safepoints = false; |
|
312 |
copy_table((address*)&_normal_table, (address*)&_active_table, sizeof(_active_table) / sizeof(address)); |
|
313 |
} |
|
314 |
} |
|
315 |
} |
|
316 |
||
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
317 |
//------------------------------------------------------------------------------------------------------------------------ |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
318 |
// Deoptimization support |
1 | 319 |
|
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
320 |
// If deoptimization happens, this function returns the point of next bytecode to continue execution |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
321 |
address TemplateInterpreter::deopt_continue_after_entry(Method* method, address bcp, int callee_parameters, bool is_top_frame) { |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
322 |
return AbstractInterpreter::deopt_continue_after_entry(method, bcp, callee_parameters, is_top_frame); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
323 |
} |
1 | 324 |
|
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
325 |
// If deoptimization happens, this function returns the point where the interpreter reexecutes |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
326 |
// the bytecode. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
327 |
// Note: Bytecodes::_athrow (C1 only) and Bytecodes::_return are the special cases |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
328 |
// that do not return "Interpreter::deopt_entry(vtos, 0)" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
329 |
address TemplateInterpreter::deopt_reexecute_entry(Method* method, address bcp) { |
1 | 330 |
assert(method->contains(bcp), "just checkin'"); |
7913 | 331 |
Bytecodes::Code code = Bytecodes::java_code_at(method, bcp); |
1 | 332 |
if (code == Bytecodes::_return) { |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
333 |
// This is used for deopt during registration of finalizers |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
334 |
// during Object.<init>. We simply need to resume execution at |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
335 |
// the standard return vtos bytecode to pop the frame normally. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
336 |
// reexecuting the real bytecode would cause double registration |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
337 |
// of the finalizable object. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
338 |
return _normal_table.entry(Bytecodes::_return).entry(vtos); |
1 | 339 |
} else { |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
340 |
return AbstractInterpreter::deopt_reexecute_entry(method, bcp); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
341 |
} |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
342 |
} |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
343 |
|
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
344 |
// If deoptimization happens, the interpreter should reexecute this bytecode. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
345 |
// This function mainly helps the compilers to set up the reexecute bit. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
346 |
bool TemplateInterpreter::bytecode_should_reexecute(Bytecodes::Code code) { |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
347 |
if (code == Bytecodes::_return) { |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
348 |
//Yes, we consider Bytecodes::_return as a special case of reexecution |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
349 |
return true; |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
350 |
} else { |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
351 |
return AbstractInterpreter::bytecode_should_reexecute(code); |
1 | 352 |
} |
353 |
} |
|
354 |
||
35214 | 355 |
InterpreterCodelet* TemplateInterpreter::codelet_containing(address pc) { |
356 |
return (InterpreterCodelet*)_code->stub_containing(pc); |
|
357 |
} |
|
358 |
||
1 | 359 |
#endif // !CC_INTERP |