Mercurial > hg > graal-jvmci-8
annotate src/share/vm/interpreter/bytecodeInterpreter.cpp @ 14399:48b178ff07b6
8019518: PPC64 (part 103): cppInterpreter: implement support for compressed Oops
Reviewed-by: kvn, coleenp
author | goetz |
---|---|
date | Wed, 03 Jul 2013 01:41:42 +0200 |
parents | 641d55c11d6b |
children | bfd9d884693d |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1513
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1513
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1513
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 // no precompiled headers |
26 #include "classfile/vmSymbols.hpp" | |
27 #include "gc_interface/collectedHeap.hpp" | |
28 #include "interpreter/bytecodeHistogram.hpp" | |
29 #include "interpreter/bytecodeInterpreter.hpp" | |
30 #include "interpreter/bytecodeInterpreter.inline.hpp" | |
31 #include "interpreter/interpreter.hpp" | |
32 #include "interpreter/interpreterRuntime.hpp" | |
33 #include "memory/resourceArea.hpp" | |
10233 | 34 #include "oops/methodCounters.hpp" |
1972 | 35 #include "oops/objArrayKlass.hpp" |
36 #include "oops/oop.inline.hpp" | |
37 #include "prims/jvmtiExport.hpp" | |
14395
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
38 #include "runtime/biasedLocking.hpp" |
1972 | 39 #include "runtime/frame.inline.hpp" |
40 #include "runtime/handles.inline.hpp" | |
41 #include "runtime/interfaceSupport.hpp" | |
42 #include "runtime/sharedRuntime.hpp" | |
43 #include "runtime/threadCritical.hpp" | |
44 #include "utilities/exceptions.hpp" | |
45 #ifdef TARGET_OS_ARCH_linux_x86 | |
46 # include "orderAccess_linux_x86.inline.hpp" | |
47 #endif | |
48 #ifdef TARGET_OS_ARCH_linux_sparc | |
49 # include "orderAccess_linux_sparc.inline.hpp" | |
50 #endif | |
51 #ifdef TARGET_OS_ARCH_linux_zero | |
52 # include "orderAccess_linux_zero.inline.hpp" | |
53 #endif | |
54 #ifdef TARGET_OS_ARCH_solaris_x86 | |
55 # include "orderAccess_solaris_x86.inline.hpp" | |
56 #endif | |
57 #ifdef TARGET_OS_ARCH_solaris_sparc | |
58 # include "orderAccess_solaris_sparc.inline.hpp" | |
59 #endif | |
60 #ifdef TARGET_OS_ARCH_windows_x86 | |
61 # include "orderAccess_windows_x86.inline.hpp" | |
62 #endif | |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2142
diff
changeset
|
63 #ifdef TARGET_OS_ARCH_linux_arm |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2142
diff
changeset
|
64 # include "orderAccess_linux_arm.inline.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2142
diff
changeset
|
65 #endif |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2142
diff
changeset
|
66 #ifdef TARGET_OS_ARCH_linux_ppc |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2142
diff
changeset
|
67 # include "orderAccess_linux_ppc.inline.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2142
diff
changeset
|
68 #endif |
3960 | 69 #ifdef TARGET_OS_ARCH_bsd_x86 |
70 # include "orderAccess_bsd_x86.inline.hpp" | |
71 #endif | |
72 #ifdef TARGET_OS_ARCH_bsd_zero | |
73 # include "orderAccess_bsd_zero.inline.hpp" | |
74 #endif | |
1972 | 75 |
0 | 76 |
77 // no precompiled headers | |
78 #ifdef CC_INTERP | |
79 | |
80 /* | |
81 * USELABELS - If using GCC, then use labels for the opcode dispatching | |
82 * rather -then a switch statement. This improves performance because it | |
83 * gives us the oportunity to have the instructions that calculate the | |
84 * next opcode to jump to be intermixed with the rest of the instructions | |
85 * that implement the opcode (see UPDATE_PC_AND_TOS_AND_CONTINUE macro). | |
86 */ | |
87 #undef USELABELS | |
88 #ifdef __GNUC__ | |
89 /* | |
90 ASSERT signifies debugging. It is much easier to step thru bytecodes if we | |
91 don't use the computed goto approach. | |
92 */ | |
93 #ifndef ASSERT | |
94 #define USELABELS | |
95 #endif | |
96 #endif | |
97 | |
98 #undef CASE | |
99 #ifdef USELABELS | |
100 #define CASE(opcode) opc ## opcode | |
101 #define DEFAULT opc_default | |
102 #else | |
103 #define CASE(opcode) case Bytecodes:: opcode | |
104 #define DEFAULT default | |
105 #endif | |
106 | |
107 /* | |
108 * PREFETCH_OPCCODE - Some compilers do better if you prefetch the next | |
109 * opcode before going back to the top of the while loop, rather then having | |
110 * the top of the while loop handle it. This provides a better opportunity | |
111 * for instruction scheduling. Some compilers just do this prefetch | |
112 * automatically. Some actually end up with worse performance if you | |
113 * force the prefetch. Solaris gcc seems to do better, but cc does worse. | |
114 */ | |
115 #undef PREFETCH_OPCCODE | |
116 #define PREFETCH_OPCCODE | |
117 | |
118 /* | |
119 Interpreter safepoint: it is expected that the interpreter will have no live | |
120 handles of its own creation live at an interpreter safepoint. Therefore we | |
121 run a HandleMarkCleaner and trash all handles allocated in the call chain | |
122 since the JavaCalls::call_helper invocation that initiated the chain. | |
123 There really shouldn't be any handles remaining to trash but this is cheap | |
124 in relation to a safepoint. | |
125 */ | |
126 #define SAFEPOINT \ | |
127 if ( SafepointSynchronize::is_synchronizing()) { \ | |
128 { \ | |
129 /* zap freed handles rather than GC'ing them */ \ | |
130 HandleMarkCleaner __hmc(THREAD); \ | |
131 } \ | |
132 CALL_VM(SafepointSynchronize::block(THREAD), handle_exception); \ | |
133 } | |
134 | |
135 /* | |
136 * VM_JAVA_ERROR - Macro for throwing a java exception from | |
137 * the interpreter loop. Should really be a CALL_VM but there | |
138 * is no entry point to do the transition to vm so we just | |
139 * do it by hand here. | |
140 */ | |
141 #define VM_JAVA_ERROR_NO_JUMP(name, msg) \ | |
142 DECACHE_STATE(); \ | |
143 SET_LAST_JAVA_FRAME(); \ | |
144 { \ | |
145 ThreadInVMfromJava trans(THREAD); \ | |
146 Exceptions::_throw_msg(THREAD, __FILE__, __LINE__, name, msg); \ | |
147 } \ | |
148 RESET_LAST_JAVA_FRAME(); \ | |
149 CACHE_STATE(); | |
150 | |
151 // Normal throw of a java error | |
152 #define VM_JAVA_ERROR(name, msg) \ | |
153 VM_JAVA_ERROR_NO_JUMP(name, msg) \ | |
154 goto handle_exception; | |
155 | |
156 #ifdef PRODUCT | |
157 #define DO_UPDATE_INSTRUCTION_COUNT(opcode) | |
158 #else | |
159 #define DO_UPDATE_INSTRUCTION_COUNT(opcode) \ | |
160 { \ | |
161 BytecodeCounter::_counter_value++; \ | |
162 BytecodeHistogram::_counters[(Bytecodes::Code)opcode]++; \ | |
163 if (StopInterpreterAt && StopInterpreterAt == BytecodeCounter::_counter_value) os::breakpoint(); \ | |
164 if (TraceBytecodes) { \ | |
165 CALL_VM((void)SharedRuntime::trace_bytecode(THREAD, 0, \ | |
166 topOfStack[Interpreter::expr_index_at(1)], \ | |
167 topOfStack[Interpreter::expr_index_at(2)]), \ | |
168 handle_exception); \ | |
169 } \ | |
170 } | |
171 #endif | |
172 | |
173 #undef DEBUGGER_SINGLE_STEP_NOTIFY | |
174 #ifdef VM_JVMTI | |
175 /* NOTE: (kbr) This macro must be called AFTER the PC has been | |
176 incremented. JvmtiExport::at_single_stepping_point() may cause a | |
177 breakpoint opcode to get inserted at the current PC to allow the | |
178 debugger to coalesce single-step events. | |
179 | |
180 As a result if we call at_single_stepping_point() we refetch opcode | |
181 to get the current opcode. This will override any other prefetching | |
182 that might have occurred. | |
183 */ | |
184 #define DEBUGGER_SINGLE_STEP_NOTIFY() \ | |
185 { \ | |
186 if (_jvmti_interp_events) { \ | |
187 if (JvmtiExport::should_post_single_step()) { \ | |
188 DECACHE_STATE(); \ | |
189 SET_LAST_JAVA_FRAME(); \ | |
190 ThreadInVMfromJava trans(THREAD); \ | |
191 JvmtiExport::at_single_stepping_point(THREAD, \ | |
192 istate->method(), \ | |
193 pc); \ | |
194 RESET_LAST_JAVA_FRAME(); \ | |
195 CACHE_STATE(); \ | |
196 if (THREAD->pop_frame_pending() && \ | |
197 !THREAD->pop_frame_in_process()) { \ | |
198 goto handle_Pop_Frame; \ | |
199 } \ | |
200 opcode = *pc; \ | |
201 } \ | |
202 } \ | |
203 } | |
204 #else | |
205 #define DEBUGGER_SINGLE_STEP_NOTIFY() | |
206 #endif | |
207 | |
208 /* | |
209 * CONTINUE - Macro for executing the next opcode. | |
210 */ | |
211 #undef CONTINUE | |
212 #ifdef USELABELS | |
213 // Have to do this dispatch this way in C++ because otherwise gcc complains about crossing an | |
214 // initialization (which is is the initialization of the table pointer...) | |
520
52a431267315
6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents:
196
diff
changeset
|
215 #define DISPATCH(opcode) goto *(void*)dispatch_table[opcode] |
0 | 216 #define CONTINUE { \ |
217 opcode = *pc; \ | |
218 DO_UPDATE_INSTRUCTION_COUNT(opcode); \ | |
219 DEBUGGER_SINGLE_STEP_NOTIFY(); \ | |
220 DISPATCH(opcode); \ | |
221 } | |
222 #else | |
223 #ifdef PREFETCH_OPCCODE | |
224 #define CONTINUE { \ | |
225 opcode = *pc; \ | |
226 DO_UPDATE_INSTRUCTION_COUNT(opcode); \ | |
227 DEBUGGER_SINGLE_STEP_NOTIFY(); \ | |
228 continue; \ | |
229 } | |
230 #else | |
231 #define CONTINUE { \ | |
232 DO_UPDATE_INSTRUCTION_COUNT(opcode); \ | |
233 DEBUGGER_SINGLE_STEP_NOTIFY(); \ | |
234 continue; \ | |
235 } | |
236 #endif | |
237 #endif | |
238 | |
239 | |
240 #define UPDATE_PC(opsize) {pc += opsize; } | |
241 /* | |
242 * UPDATE_PC_AND_TOS - Macro for updating the pc and topOfStack. | |
243 */ | |
244 #undef UPDATE_PC_AND_TOS | |
245 #define UPDATE_PC_AND_TOS(opsize, stack) \ | |
246 {pc += opsize; MORE_STACK(stack); } | |
247 | |
248 /* | |
249 * UPDATE_PC_AND_TOS_AND_CONTINUE - Macro for updating the pc and topOfStack, | |
250 * and executing the next opcode. It's somewhat similar to the combination | |
251 * of UPDATE_PC_AND_TOS and CONTINUE, but with some minor optimizations. | |
252 */ | |
253 #undef UPDATE_PC_AND_TOS_AND_CONTINUE | |
254 #ifdef USELABELS | |
255 #define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) { \ | |
256 pc += opsize; opcode = *pc; MORE_STACK(stack); \ | |
257 DO_UPDATE_INSTRUCTION_COUNT(opcode); \ | |
258 DEBUGGER_SINGLE_STEP_NOTIFY(); \ | |
259 DISPATCH(opcode); \ | |
260 } | |
261 | |
262 #define UPDATE_PC_AND_CONTINUE(opsize) { \ | |
263 pc += opsize; opcode = *pc; \ | |
264 DO_UPDATE_INSTRUCTION_COUNT(opcode); \ | |
265 DEBUGGER_SINGLE_STEP_NOTIFY(); \ | |
266 DISPATCH(opcode); \ | |
267 } | |
268 #else | |
269 #ifdef PREFETCH_OPCCODE | |
270 #define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) { \ | |
271 pc += opsize; opcode = *pc; MORE_STACK(stack); \ | |
272 DO_UPDATE_INSTRUCTION_COUNT(opcode); \ | |
273 DEBUGGER_SINGLE_STEP_NOTIFY(); \ | |
274 goto do_continue; \ | |
275 } | |
276 | |
277 #define UPDATE_PC_AND_CONTINUE(opsize) { \ | |
278 pc += opsize; opcode = *pc; \ | |
279 DO_UPDATE_INSTRUCTION_COUNT(opcode); \ | |
280 DEBUGGER_SINGLE_STEP_NOTIFY(); \ | |
281 goto do_continue; \ | |
282 } | |
283 #else | |
284 #define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) { \ | |
285 pc += opsize; MORE_STACK(stack); \ | |
286 DO_UPDATE_INSTRUCTION_COUNT(opcode); \ | |
287 DEBUGGER_SINGLE_STEP_NOTIFY(); \ | |
288 goto do_continue; \ | |
289 } | |
290 | |
291 #define UPDATE_PC_AND_CONTINUE(opsize) { \ | |
292 pc += opsize; \ | |
293 DO_UPDATE_INSTRUCTION_COUNT(opcode); \ | |
294 DEBUGGER_SINGLE_STEP_NOTIFY(); \ | |
295 goto do_continue; \ | |
296 } | |
297 #endif /* PREFETCH_OPCCODE */ | |
298 #endif /* USELABELS */ | |
299 | |
300 // About to call a new method, update the save the adjusted pc and return to frame manager | |
301 #define UPDATE_PC_AND_RETURN(opsize) \ | |
302 DECACHE_TOS(); \ | |
303 istate->set_bcp(pc+opsize); \ | |
304 return; | |
305 | |
306 | |
307 #define METHOD istate->method() | |
10233 | 308 #define GET_METHOD_COUNTERS(res) \ |
309 res = METHOD->method_counters(); \ | |
310 if (res == NULL) { \ | |
311 CALL_VM(res = InterpreterRuntime::build_method_counters(THREAD, METHOD), handle_exception); \ | |
312 } | |
313 | |
0 | 314 #define OSR_REQUEST(res, branch_pc) \ |
315 CALL_VM(res=InterpreterRuntime::frequency_counter_overflow(THREAD, branch_pc), handle_exception); | |
316 /* | |
317 * For those opcodes that need to have a GC point on a backwards branch | |
318 */ | |
319 | |
320 // Backedge counting is kind of strange. The asm interpreter will increment | |
321 // the backedge counter as a separate counter but it does it's comparisons | |
322 // to the sum (scaled) of invocation counter and backedge count to make | |
323 // a decision. Seems kind of odd to sum them together like that | |
324 | |
325 // skip is delta from current bcp/bci for target, branch_pc is pre-branch bcp | |
326 | |
327 | |
328 #define DO_BACKEDGE_CHECKS(skip, branch_pc) \ | |
329 if ((skip) <= 0) { \ | |
10233 | 330 MethodCounters* mcs; \ |
331 GET_METHOD_COUNTERS(mcs); \ | |
1078 | 332 if (UseLoopCounter) { \ |
0 | 333 bool do_OSR = UseOnStackReplacement; \ |
10233 | 334 mcs->backedge_counter()->increment(); \ |
335 if (do_OSR) do_OSR = mcs->backedge_counter()->reached_InvocationLimit(); \ | |
0 | 336 if (do_OSR) { \ |
337 nmethod* osr_nmethod; \ | |
338 OSR_REQUEST(osr_nmethod, branch_pc); \ | |
339 if (osr_nmethod != NULL && osr_nmethod->osr_entry_bci() != InvalidOSREntryBci) { \ | |
1078 | 340 intptr_t* buf = SharedRuntime::OSR_migration_begin(THREAD); \ |
0 | 341 istate->set_msg(do_osr); \ |
342 istate->set_osr_buf((address)buf); \ | |
343 istate->set_osr_entry(osr_nmethod->osr_entry()); \ | |
344 return; \ | |
345 } \ | |
346 } \ | |
347 } /* UseCompiler ... */ \ | |
10233 | 348 mcs->invocation_counter()->increment(); \ |
0 | 349 SAFEPOINT; \ |
350 } | |
351 | |
352 /* | |
353 * For those opcodes that need to have a GC point on a backwards branch | |
354 */ | |
355 | |
356 /* | |
357 * Macros for caching and flushing the interpreter state. Some local | |
358 * variables need to be flushed out to the frame before we do certain | |
359 * things (like pushing frames or becomming gc safe) and some need to | |
360 * be recached later (like after popping a frame). We could use one | |
361 * macro to cache or decache everything, but this would be less then | |
362 * optimal because we don't always need to cache or decache everything | |
363 * because some things we know are already cached or decached. | |
364 */ | |
365 #undef DECACHE_TOS | |
366 #undef CACHE_TOS | |
367 #undef CACHE_PREV_TOS | |
368 #define DECACHE_TOS() istate->set_stack(topOfStack); | |
369 | |
370 #define CACHE_TOS() topOfStack = (intptr_t *)istate->stack(); | |
371 | |
372 #undef DECACHE_PC | |
373 #undef CACHE_PC | |
374 #define DECACHE_PC() istate->set_bcp(pc); | |
375 #define CACHE_PC() pc = istate->bcp(); | |
376 #define CACHE_CP() cp = istate->constants(); | |
377 #define CACHE_LOCALS() locals = istate->locals(); | |
378 #undef CACHE_FRAME | |
379 #define CACHE_FRAME() | |
380 | |
381 /* | |
382 * CHECK_NULL - Macro for throwing a NullPointerException if the object | |
383 * passed is a null ref. | |
384 * On some architectures/platforms it should be possible to do this implicitly | |
385 */ | |
386 #undef CHECK_NULL | |
387 #define CHECK_NULL(obj_) \ | |
520
52a431267315
6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents:
196
diff
changeset
|
388 if ((obj_) == NULL) { \ |
0 | 389 VM_JAVA_ERROR(vmSymbols::java_lang_NullPointerException(), ""); \ |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
390 } \ |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
391 VERIFY_OOP(obj_) |
0 | 392 |
393 #define VMdoubleConstZero() 0.0 | |
394 #define VMdoubleConstOne() 1.0 | |
395 #define VMlongConstZero() (max_jlong-max_jlong) | |
396 #define VMlongConstOne() ((max_jlong-max_jlong)+1) | |
397 | |
398 /* | |
399 * Alignment | |
400 */ | |
401 #define VMalignWordUp(val) (((uintptr_t)(val) + 3) & ~3) | |
402 | |
403 // Decache the interpreter state that interpreter modifies directly (i.e. GC is indirect mod) | |
404 #define DECACHE_STATE() DECACHE_PC(); DECACHE_TOS(); | |
405 | |
406 // Reload interpreter state after calling the VM or a possible GC | |
407 #define CACHE_STATE() \ | |
408 CACHE_TOS(); \ | |
409 CACHE_PC(); \ | |
410 CACHE_CP(); \ | |
411 CACHE_LOCALS(); | |
412 | |
413 // Call the VM don't check for pending exceptions | |
414 #define CALL_VM_NOCHECK(func) \ | |
415 DECACHE_STATE(); \ | |
416 SET_LAST_JAVA_FRAME(); \ | |
417 func; \ | |
418 RESET_LAST_JAVA_FRAME(); \ | |
419 CACHE_STATE(); \ | |
420 if (THREAD->pop_frame_pending() && \ | |
421 !THREAD->pop_frame_in_process()) { \ | |
422 goto handle_Pop_Frame; \ | |
423 } | |
424 | |
425 // Call the VM and check for pending exceptions | |
426 #define CALL_VM(func, label) { \ | |
427 CALL_VM_NOCHECK(func); \ | |
428 if (THREAD->has_pending_exception()) goto label; \ | |
429 } | |
430 | |
431 /* | |
432 * BytecodeInterpreter::run(interpreterState istate) | |
433 * BytecodeInterpreter::runWithChecks(interpreterState istate) | |
434 * | |
435 * The real deal. This is where byte codes actually get interpreted. | |
436 * Basically it's a big while loop that iterates until we return from | |
437 * the method passed in. | |
438 * | |
439 * The runWithChecks is used if JVMTI is enabled. | |
440 * | |
441 */ | |
442 #if defined(VM_JVMTI) | |
443 void | |
444 BytecodeInterpreter::runWithChecks(interpreterState istate) { | |
445 #else | |
446 void | |
447 BytecodeInterpreter::run(interpreterState istate) { | |
448 #endif | |
449 | |
450 // In order to simplify some tests based on switches set at runtime | |
451 // we invoke the interpreter a single time after switches are enabled | |
452 // and set simpler to to test variables rather than method calls or complex | |
453 // boolean expressions. | |
454 | |
455 static int initialized = 0; | |
456 static int checkit = 0; | |
457 static intptr_t* c_addr = NULL; | |
458 static intptr_t c_value; | |
459 | |
460 if (checkit && *c_addr != c_value) { | |
461 os::breakpoint(); | |
462 } | |
463 #ifdef VM_JVMTI | |
464 static bool _jvmti_interp_events = 0; | |
465 #endif | |
466 | |
467 static int _compiling; // (UseCompiler || CountCompiledCalls) | |
468 | |
469 #ifdef ASSERT | |
470 if (istate->_msg != initialize) { | |
10393
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
471 // We have a problem here if we are running with a pre-hsx24 JDK (for example during bootstrap) |
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
472 // because in that case, EnableInvokeDynamic is true by default but will be later switched off |
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
473 // if java_lang_invoke_MethodHandle::compute_offsets() detects that the JDK only has the classes |
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
474 // for the old JSR292 implementation. |
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
475 // This leads to a situation where 'istate->_stack_limit' always accounts for |
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
476 // methodOopDesc::extra_stack_entries() because it is computed in |
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
477 // CppInterpreterGenerator::generate_compute_interpreter_state() which was generated while |
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
478 // EnableInvokeDynamic was still true. On the other hand, istate->_method->max_stack() doesn't |
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
479 // account for extra_stack_entries() anymore because at the time when it is called |
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
480 // EnableInvokeDynamic was already set to false. |
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
481 // So we have a second version of the assertion which handles the case where EnableInvokeDynamic was |
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
482 // switched off because of the wrong classes. |
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
483 if (EnableInvokeDynamic || FLAG_IS_CMDLINE(EnableInvokeDynamic)) { |
11046
6a0ead6dc6db
8017531: 8010460 changes broke bytecodeInterpreter.cpp
goetz
parents:
10393
diff
changeset
|
484 assert(labs(istate->_stack_base - istate->_stack_limit) == (istate->_method->max_stack() + 1), "bad stack limit"); |
10393
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
485 } else { |
11046
6a0ead6dc6db
8017531: 8010460 changes broke bytecodeInterpreter.cpp
goetz
parents:
10393
diff
changeset
|
486 const int extra_stack_entries = Method::extra_stack_entries_for_jsr292; |
10393
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
487 assert(labs(istate->_stack_base - istate->_stack_limit) == (istate->_method->max_stack() + extra_stack_entries |
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
488 + 1), "bad stack limit"); |
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10233
diff
changeset
|
489 } |
1729 | 490 #ifndef SHARK |
491 IA32_ONLY(assert(istate->_stack_limit == istate->_thread->last_Java_sp() + 1, "wrong")); | |
492 #endif // !SHARK | |
0 | 493 } |
494 // Verify linkages. | |
495 interpreterState l = istate; | |
496 do { | |
497 assert(l == l->_self_link, "bad link"); | |
498 l = l->_prev_link; | |
499 } while (l != NULL); | |
500 // Screwups with stack management usually cause us to overwrite istate | |
501 // save a copy so we can verify it. | |
502 interpreterState orig = istate; | |
503 #endif | |
504 | |
505 register intptr_t* topOfStack = (intptr_t *)istate->stack(); /* access with STACK macros */ | |
506 register address pc = istate->bcp(); | |
507 register jubyte opcode; | |
508 register intptr_t* locals = istate->locals(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
509 register ConstantPoolCache* cp = istate->constants(); // method()->constants()->cache() |
0 | 510 #ifdef LOTS_OF_REGS |
511 register JavaThread* THREAD = istate->thread(); | |
512 #else | |
513 #undef THREAD | |
514 #define THREAD istate->thread() | |
515 #endif | |
516 | |
517 #ifdef USELABELS | |
518 const static void* const opclabels_data[256] = { | |
519 /* 0x00 */ &&opc_nop, &&opc_aconst_null,&&opc_iconst_m1,&&opc_iconst_0, | |
520 /* 0x04 */ &&opc_iconst_1,&&opc_iconst_2, &&opc_iconst_3, &&opc_iconst_4, | |
521 /* 0x08 */ &&opc_iconst_5,&&opc_lconst_0, &&opc_lconst_1, &&opc_fconst_0, | |
522 /* 0x0C */ &&opc_fconst_1,&&opc_fconst_2, &&opc_dconst_0, &&opc_dconst_1, | |
523 | |
524 /* 0x10 */ &&opc_bipush, &&opc_sipush, &&opc_ldc, &&opc_ldc_w, | |
525 /* 0x14 */ &&opc_ldc2_w, &&opc_iload, &&opc_lload, &&opc_fload, | |
526 /* 0x18 */ &&opc_dload, &&opc_aload, &&opc_iload_0,&&opc_iload_1, | |
527 /* 0x1C */ &&opc_iload_2,&&opc_iload_3,&&opc_lload_0,&&opc_lload_1, | |
528 | |
529 /* 0x20 */ &&opc_lload_2,&&opc_lload_3,&&opc_fload_0,&&opc_fload_1, | |
530 /* 0x24 */ &&opc_fload_2,&&opc_fload_3,&&opc_dload_0,&&opc_dload_1, | |
531 /* 0x28 */ &&opc_dload_2,&&opc_dload_3,&&opc_aload_0,&&opc_aload_1, | |
532 /* 0x2C */ &&opc_aload_2,&&opc_aload_3,&&opc_iaload, &&opc_laload, | |
533 | |
534 /* 0x30 */ &&opc_faload, &&opc_daload, &&opc_aaload, &&opc_baload, | |
535 /* 0x34 */ &&opc_caload, &&opc_saload, &&opc_istore, &&opc_lstore, | |
536 /* 0x38 */ &&opc_fstore, &&opc_dstore, &&opc_astore, &&opc_istore_0, | |
537 /* 0x3C */ &&opc_istore_1,&&opc_istore_2,&&opc_istore_3,&&opc_lstore_0, | |
538 | |
539 /* 0x40 */ &&opc_lstore_1,&&opc_lstore_2,&&opc_lstore_3,&&opc_fstore_0, | |
540 /* 0x44 */ &&opc_fstore_1,&&opc_fstore_2,&&opc_fstore_3,&&opc_dstore_0, | |
541 /* 0x48 */ &&opc_dstore_1,&&opc_dstore_2,&&opc_dstore_3,&&opc_astore_0, | |
542 /* 0x4C */ &&opc_astore_1,&&opc_astore_2,&&opc_astore_3,&&opc_iastore, | |
543 | |
544 /* 0x50 */ &&opc_lastore,&&opc_fastore,&&opc_dastore,&&opc_aastore, | |
545 /* 0x54 */ &&opc_bastore,&&opc_castore,&&opc_sastore,&&opc_pop, | |
546 /* 0x58 */ &&opc_pop2, &&opc_dup, &&opc_dup_x1, &&opc_dup_x2, | |
547 /* 0x5C */ &&opc_dup2, &&opc_dup2_x1,&&opc_dup2_x2,&&opc_swap, | |
548 | |
549 /* 0x60 */ &&opc_iadd,&&opc_ladd,&&opc_fadd,&&opc_dadd, | |
550 /* 0x64 */ &&opc_isub,&&opc_lsub,&&opc_fsub,&&opc_dsub, | |
551 /* 0x68 */ &&opc_imul,&&opc_lmul,&&opc_fmul,&&opc_dmul, | |
552 /* 0x6C */ &&opc_idiv,&&opc_ldiv,&&opc_fdiv,&&opc_ddiv, | |
553 | |
554 /* 0x70 */ &&opc_irem, &&opc_lrem, &&opc_frem,&&opc_drem, | |
555 /* 0x74 */ &&opc_ineg, &&opc_lneg, &&opc_fneg,&&opc_dneg, | |
556 /* 0x78 */ &&opc_ishl, &&opc_lshl, &&opc_ishr,&&opc_lshr, | |
557 /* 0x7C */ &&opc_iushr,&&opc_lushr,&&opc_iand,&&opc_land, | |
558 | |
559 /* 0x80 */ &&opc_ior, &&opc_lor,&&opc_ixor,&&opc_lxor, | |
560 /* 0x84 */ &&opc_iinc,&&opc_i2l,&&opc_i2f, &&opc_i2d, | |
561 /* 0x88 */ &&opc_l2i, &&opc_l2f,&&opc_l2d, &&opc_f2i, | |
562 /* 0x8C */ &&opc_f2l, &&opc_f2d,&&opc_d2i, &&opc_d2l, | |
563 | |
564 /* 0x90 */ &&opc_d2f, &&opc_i2b, &&opc_i2c, &&opc_i2s, | |
565 /* 0x94 */ &&opc_lcmp, &&opc_fcmpl,&&opc_fcmpg,&&opc_dcmpl, | |
566 /* 0x98 */ &&opc_dcmpg,&&opc_ifeq, &&opc_ifne, &&opc_iflt, | |
567 /* 0x9C */ &&opc_ifge, &&opc_ifgt, &&opc_ifle, &&opc_if_icmpeq, | |
568 | |
569 /* 0xA0 */ &&opc_if_icmpne,&&opc_if_icmplt,&&opc_if_icmpge, &&opc_if_icmpgt, | |
570 /* 0xA4 */ &&opc_if_icmple,&&opc_if_acmpeq,&&opc_if_acmpne, &&opc_goto, | |
571 /* 0xA8 */ &&opc_jsr, &&opc_ret, &&opc_tableswitch,&&opc_lookupswitch, | |
572 /* 0xAC */ &&opc_ireturn, &&opc_lreturn, &&opc_freturn, &&opc_dreturn, | |
573 | |
574 /* 0xB0 */ &&opc_areturn, &&opc_return, &&opc_getstatic, &&opc_putstatic, | |
575 /* 0xB4 */ &&opc_getfield, &&opc_putfield, &&opc_invokevirtual,&&opc_invokespecial, | |
2480 | 576 /* 0xB8 */ &&opc_invokestatic,&&opc_invokeinterface,&&opc_invokedynamic,&&opc_new, |
0 | 577 /* 0xBC */ &&opc_newarray, &&opc_anewarray, &&opc_arraylength, &&opc_athrow, |
578 | |
579 /* 0xC0 */ &&opc_checkcast, &&opc_instanceof, &&opc_monitorenter, &&opc_monitorexit, | |
580 /* 0xC4 */ &&opc_wide, &&opc_multianewarray, &&opc_ifnull, &&opc_ifnonnull, | |
123 | 581 /* 0xC8 */ &&opc_goto_w, &&opc_jsr_w, &&opc_breakpoint, &&opc_default, |
582 /* 0xCC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, | |
583 | |
584 /* 0xD0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, | |
0 | 585 /* 0xD4 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, |
586 /* 0xD8 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, | |
587 /* 0xDC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, | |
588 | |
589 /* 0xE0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, | |
2480 | 590 /* 0xE4 */ &&opc_default, &&opc_fast_aldc, &&opc_fast_aldc_w, &&opc_return_register_finalizer, |
6926 | 591 /* 0xE8 */ &&opc_invokehandle,&&opc_default, &&opc_default, &&opc_default, |
0 | 592 /* 0xEC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, |
593 | |
594 /* 0xF0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, | |
595 /* 0xF4 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, | |
596 /* 0xF8 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, | |
597 /* 0xFC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default | |
598 }; | |
599 register uintptr_t *dispatch_table = (uintptr_t*)&opclabels_data[0]; | |
600 #endif /* USELABELS */ | |
601 | |
602 #ifdef ASSERT | |
603 // this will trigger a VERIFY_OOP on entry | |
604 if (istate->msg() != initialize && ! METHOD->is_static()) { | |
605 oop rcvr = LOCALS_OBJECT(0); | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
606 VERIFY_OOP(rcvr); |
0 | 607 } |
608 #endif | |
609 // #define HACK | |
610 #ifdef HACK | |
611 bool interesting = false; | |
612 #endif // HACK | |
613 | |
614 /* QQQ this should be a stack method so we don't know actual direction */ | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
615 guarantee(istate->msg() == initialize || |
0 | 616 topOfStack >= istate->stack_limit() && |
617 topOfStack < istate->stack_base(), | |
618 "Stack top out of range"); | |
619 | |
620 switch (istate->msg()) { | |
621 case initialize: { | |
622 if (initialized++) ShouldNotReachHere(); // Only one initialize call | |
623 _compiling = (UseCompiler || CountCompiledCalls); | |
624 #ifdef VM_JVMTI | |
625 _jvmti_interp_events = JvmtiExport::can_post_interpreter_events(); | |
626 #endif | |
627 return; | |
628 } | |
629 break; | |
630 case method_entry: { | |
631 THREAD->set_do_not_unlock(); | |
632 // count invocations | |
633 assert(initialized, "Interpreter not initialized"); | |
634 if (_compiling) { | |
10233 | 635 MethodCounters* mcs; |
636 GET_METHOD_COUNTERS(mcs); | |
0 | 637 if (ProfileInterpreter) { |
10233 | 638 METHOD->increment_interpreter_invocation_count(THREAD); |
0 | 639 } |
10233 | 640 mcs->invocation_counter()->increment(); |
641 if (mcs->invocation_counter()->reached_InvocationLimit()) { | |
0 | 642 CALL_VM((void)InterpreterRuntime::frequency_counter_overflow(THREAD, NULL), handle_exception); |
643 | |
644 // We no longer retry on a counter overflow | |
645 | |
646 // istate->set_msg(retry_method); | |
647 // THREAD->clr_do_not_unlock(); | |
648 // return; | |
649 } | |
650 SAFEPOINT; | |
651 } | |
652 | |
653 if ((istate->_stack_base - istate->_stack_limit) != istate->method()->max_stack() + 1) { | |
654 // initialize | |
655 os::breakpoint(); | |
656 } | |
657 | |
658 #ifdef HACK | |
659 { | |
660 ResourceMark rm; | |
661 char *method_name = istate->method()->name_and_sig_as_C_string(); | |
662 if (strstr(method_name, "runThese$TestRunner.run()V") != NULL) { | |
663 tty->print_cr("entering: depth %d bci: %d", | |
664 (istate->_stack_base - istate->_stack), | |
665 istate->_bcp - istate->_method->code_base()); | |
666 interesting = true; | |
667 } | |
668 } | |
669 #endif // HACK | |
670 | |
671 | |
672 // lock method if synchronized | |
673 if (METHOD->is_synchronized()) { | |
14395
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
674 // oop rcvr = locals[0].j.r; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
675 oop rcvr; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
676 if (METHOD->is_static()) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
677 rcvr = METHOD->constants()->pool_holder()->java_mirror(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
678 } else { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
679 rcvr = LOCALS_OBJECT(0); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
680 VERIFY_OOP(rcvr); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
681 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
682 // The initial monitor is ours for the taking |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
683 // Monitor not filled in frame manager any longer as this caused race condition with biased locking. |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
684 BasicObjectLock* mon = &istate->monitor_base()[-1]; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
685 mon->set_obj(rcvr); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
686 bool success = false; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
687 uintptr_t epoch_mask_in_place = (uintptr_t)markOopDesc::epoch_mask_in_place; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
688 markOop mark = rcvr->mark(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
689 intptr_t hash = (intptr_t) markOopDesc::no_hash; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
690 // Implies UseBiasedLocking. |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
691 if (mark->has_bias_pattern()) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
692 uintptr_t thread_ident; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
693 uintptr_t anticipated_bias_locking_value; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
694 thread_ident = (uintptr_t)istate->thread(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
695 anticipated_bias_locking_value = |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
696 (((uintptr_t)rcvr->klass()->prototype_header() | thread_ident) ^ (uintptr_t)mark) & |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
697 ~((uintptr_t) markOopDesc::age_mask_in_place); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
698 |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
699 if (anticipated_bias_locking_value == 0) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
700 // Already biased towards this thread, nothing to do. |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
701 if (PrintBiasedLockingStatistics) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
702 (* BiasedLocking::biased_lock_entry_count_addr())++; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
703 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
704 success = true; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
705 } else if ((anticipated_bias_locking_value & markOopDesc::biased_lock_mask_in_place) != 0) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
706 // Try to revoke bias. |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
707 markOop header = rcvr->klass()->prototype_header(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
708 if (hash != markOopDesc::no_hash) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
709 header = header->copy_set_hash(hash); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
710 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
711 if (Atomic::cmpxchg_ptr(header, rcvr->mark_addr(), mark) == mark) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
712 if (PrintBiasedLockingStatistics) |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
713 (*BiasedLocking::revoked_lock_entry_count_addr())++; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
714 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
715 } else if ((anticipated_bias_locking_value & epoch_mask_in_place) != 0) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
716 // Try to rebias. |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
717 markOop new_header = (markOop) ( (intptr_t) rcvr->klass()->prototype_header() | thread_ident); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
718 if (hash != markOopDesc::no_hash) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
719 new_header = new_header->copy_set_hash(hash); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
720 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
721 if (Atomic::cmpxchg_ptr((void*)new_header, rcvr->mark_addr(), mark) == mark) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
722 if (PrintBiasedLockingStatistics) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
723 (* BiasedLocking::rebiased_lock_entry_count_addr())++; |
0 | 724 } |
725 } else { | |
14395
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
726 CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
727 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
728 success = true; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
729 } else { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
730 // Try to bias towards thread in case object is anonymously biased. |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
731 markOop header = (markOop) ((uintptr_t) mark & |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
732 ((uintptr_t)markOopDesc::biased_lock_mask_in_place | |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
733 (uintptr_t)markOopDesc::age_mask_in_place | epoch_mask_in_place)); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
734 if (hash != markOopDesc::no_hash) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
735 header = header->copy_set_hash(hash); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
736 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
737 markOop new_header = (markOop) ((uintptr_t) header | thread_ident); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
738 // Debugging hint. |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
739 DEBUG_ONLY(mon->lock()->set_displaced_header((markOop) (uintptr_t) 0xdeaddead);) |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
740 if (Atomic::cmpxchg_ptr((void*)new_header, rcvr->mark_addr(), header) == header) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
741 if (PrintBiasedLockingStatistics) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
742 (* BiasedLocking::anonymously_biased_lock_entry_count_addr())++; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
743 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
744 } else { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
745 CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
746 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
747 success = true; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
748 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
749 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
750 |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
751 // Traditional lightweight locking. |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
752 if (!success) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
753 markOop displaced = rcvr->mark()->set_unlocked(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
754 mon->lock()->set_displaced_header(displaced); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
755 bool call_vm = UseHeavyMonitors; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
756 if (call_vm || Atomic::cmpxchg_ptr(mon, rcvr->mark_addr(), displaced) != displaced) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
757 // Is it simple recursive case? |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
758 if (!call_vm && THREAD->is_lock_owned((address) displaced->clear_lock_bits())) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
759 mon->lock()->set_displaced_header(NULL); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
760 } else { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
761 CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception); |
0 | 762 } |
763 } | |
14395
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
764 } |
0 | 765 } |
766 THREAD->clr_do_not_unlock(); | |
767 | |
768 // Notify jvmti | |
769 #ifdef VM_JVMTI | |
770 if (_jvmti_interp_events) { | |
771 // Whenever JVMTI puts a thread in interp_only_mode, method | |
772 // entry/exit events are sent for that thread to track stack depth. | |
773 if (THREAD->is_interp_only_mode()) { | |
774 CALL_VM(InterpreterRuntime::post_method_entry(THREAD), | |
775 handle_exception); | |
776 } | |
777 } | |
778 #endif /* VM_JVMTI */ | |
779 | |
780 goto run; | |
781 } | |
782 | |
783 case popping_frame: { | |
784 // returned from a java call to pop the frame, restart the call | |
785 // clear the message so we don't confuse ourselves later | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
786 ShouldNotReachHere(); // we don't return this. |
0 | 787 assert(THREAD->pop_frame_in_process(), "wrong frame pop state"); |
788 istate->set_msg(no_request); | |
789 THREAD->clr_pop_frame_in_process(); | |
790 goto run; | |
791 } | |
792 | |
793 case method_resume: { | |
794 if ((istate->_stack_base - istate->_stack_limit) != istate->method()->max_stack() + 1) { | |
795 // resume | |
796 os::breakpoint(); | |
797 } | |
798 #ifdef HACK | |
799 { | |
800 ResourceMark rm; | |
801 char *method_name = istate->method()->name_and_sig_as_C_string(); | |
802 if (strstr(method_name, "runThese$TestRunner.run()V") != NULL) { | |
803 tty->print_cr("resume: depth %d bci: %d", | |
804 (istate->_stack_base - istate->_stack) , | |
805 istate->_bcp - istate->_method->code_base()); | |
806 interesting = true; | |
807 } | |
808 } | |
809 #endif // HACK | |
810 // returned from a java call, continue executing. | |
811 if (THREAD->pop_frame_pending() && !THREAD->pop_frame_in_process()) { | |
812 goto handle_Pop_Frame; | |
813 } | |
814 | |
815 if (THREAD->has_pending_exception()) goto handle_exception; | |
816 // Update the pc by the saved amount of the invoke bytecode size | |
817 UPDATE_PC(istate->bcp_advance()); | |
818 goto run; | |
819 } | |
820 | |
821 case deopt_resume2: { | |
822 // Returned from an opcode that will reexecute. Deopt was | |
823 // a result of a PopFrame request. | |
824 // | |
825 goto run; | |
826 } | |
827 | |
828 case deopt_resume: { | |
829 // Returned from an opcode that has completed. The stack has | |
830 // the result all we need to do is skip across the bytecode | |
831 // and continue (assuming there is no exception pending) | |
832 // | |
833 // compute continuation length | |
834 // | |
835 // Note: it is possible to deopt at a return_register_finalizer opcode | |
836 // because this requires entering the vm to do the registering. While the | |
837 // opcode is complete we can't advance because there are no more opcodes | |
838 // much like trying to deopt at a poll return. In that has we simply | |
839 // get out of here | |
840 // | |
2142 | 841 if ( Bytecodes::code_at(METHOD, pc) == Bytecodes::_return_register_finalizer) { |
0 | 842 // this will do the right thing even if an exception is pending. |
843 goto handle_return; | |
844 } | |
2142 | 845 UPDATE_PC(Bytecodes::length_at(METHOD, pc)); |
0 | 846 if (THREAD->has_pending_exception()) goto handle_exception; |
847 goto run; | |
848 } | |
849 case got_monitors: { | |
850 // continue locking now that we have a monitor to use | |
851 // we expect to find newly allocated monitor at the "top" of the monitor stack. | |
852 oop lockee = STACK_OBJECT(-1); | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
853 VERIFY_OOP(lockee); |
0 | 854 // derefing's lockee ought to provoke implicit null check |
855 // find a free monitor | |
856 BasicObjectLock* entry = (BasicObjectLock*) istate->stack_base(); | |
857 assert(entry->obj() == NULL, "Frame manager didn't allocate the monitor"); | |
858 entry->set_obj(lockee); | |
14395
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
859 bool success = false; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
860 uintptr_t epoch_mask_in_place = (uintptr_t)markOopDesc::epoch_mask_in_place; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
861 |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
862 markOop mark = lockee->mark(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
863 intptr_t hash = (intptr_t) markOopDesc::no_hash; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
864 // implies UseBiasedLocking |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
865 if (mark->has_bias_pattern()) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
866 uintptr_t thread_ident; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
867 uintptr_t anticipated_bias_locking_value; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
868 thread_ident = (uintptr_t)istate->thread(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
869 anticipated_bias_locking_value = |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
870 (((uintptr_t)lockee->klass()->prototype_header() | thread_ident) ^ (uintptr_t)mark) & |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
871 ~((uintptr_t) markOopDesc::age_mask_in_place); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
872 |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
873 if (anticipated_bias_locking_value == 0) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
874 // already biased towards this thread, nothing to do |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
875 if (PrintBiasedLockingStatistics) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
876 (* BiasedLocking::biased_lock_entry_count_addr())++; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
877 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
878 success = true; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
879 } else if ((anticipated_bias_locking_value & markOopDesc::biased_lock_mask_in_place) != 0) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
880 // try revoke bias |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
881 markOop header = lockee->klass()->prototype_header(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
882 if (hash != markOopDesc::no_hash) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
883 header = header->copy_set_hash(hash); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
884 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
885 if (Atomic::cmpxchg_ptr(header, lockee->mark_addr(), mark) == mark) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
886 if (PrintBiasedLockingStatistics) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
887 (*BiasedLocking::revoked_lock_entry_count_addr())++; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
888 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
889 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
890 } else if ((anticipated_bias_locking_value & epoch_mask_in_place) !=0) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
891 // try rebias |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
892 markOop new_header = (markOop) ( (intptr_t) lockee->klass()->prototype_header() | thread_ident); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
893 if (hash != markOopDesc::no_hash) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
894 new_header = new_header->copy_set_hash(hash); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
895 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
896 if (Atomic::cmpxchg_ptr((void*)new_header, lockee->mark_addr(), mark) == mark) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
897 if (PrintBiasedLockingStatistics) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
898 (* BiasedLocking::rebiased_lock_entry_count_addr())++; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
899 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
900 } else { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
901 CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
902 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
903 success = true; |
0 | 904 } else { |
14395
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
905 // try to bias towards thread in case object is anonymously biased |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
906 markOop header = (markOop) ((uintptr_t) mark & ((uintptr_t)markOopDesc::biased_lock_mask_in_place | |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
907 (uintptr_t)markOopDesc::age_mask_in_place | epoch_mask_in_place)); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
908 if (hash != markOopDesc::no_hash) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
909 header = header->copy_set_hash(hash); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
910 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
911 markOop new_header = (markOop) ((uintptr_t) header | thread_ident); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
912 // debugging hint |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
913 DEBUG_ONLY(entry->lock()->set_displaced_header((markOop) (uintptr_t) 0xdeaddead);) |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
914 if (Atomic::cmpxchg_ptr((void*)new_header, lockee->mark_addr(), header) == header) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
915 if (PrintBiasedLockingStatistics) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
916 (* BiasedLocking::anonymously_biased_lock_entry_count_addr())++; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
917 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
918 } else { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
919 CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
920 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
921 success = true; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
922 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
923 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
924 |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
925 // traditional lightweight locking |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
926 if (!success) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
927 markOop displaced = lockee->mark()->set_unlocked(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
928 entry->lock()->set_displaced_header(displaced); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
929 bool call_vm = UseHeavyMonitors; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
930 if (call_vm || Atomic::cmpxchg_ptr(entry, lockee->mark_addr(), displaced) != displaced) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
931 // Is it simple recursive case? |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
932 if (!call_vm && THREAD->is_lock_owned((address) displaced->clear_lock_bits())) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
933 entry->lock()->set_displaced_header(NULL); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
934 } else { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
935 CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
936 } |
0 | 937 } |
938 } | |
939 UPDATE_PC_AND_TOS(1, -1); | |
940 goto run; | |
941 } | |
942 default: { | |
943 fatal("Unexpected message from frame manager"); | |
944 } | |
945 } | |
946 | |
947 run: | |
948 | |
949 DO_UPDATE_INSTRUCTION_COUNT(*pc) | |
950 DEBUGGER_SINGLE_STEP_NOTIFY(); | |
951 #ifdef PREFETCH_OPCCODE | |
952 opcode = *pc; /* prefetch first opcode */ | |
953 #endif | |
954 | |
955 #ifndef USELABELS | |
956 while (1) | |
957 #endif | |
958 { | |
959 #ifndef PREFETCH_OPCCODE | |
960 opcode = *pc; | |
961 #endif | |
962 // Seems like this happens twice per opcode. At worst this is only | |
963 // need at entry to the loop. | |
964 // DEBUGGER_SINGLE_STEP_NOTIFY(); | |
965 /* Using this labels avoids double breakpoints when quickening and | |
966 * when returing from transition frames. | |
967 */ | |
968 opcode_switch: | |
969 assert(istate == orig, "Corrupted istate"); | |
970 /* QQQ Hmm this has knowledge of direction, ought to be a stack method */ | |
971 assert(topOfStack >= istate->stack_limit(), "Stack overrun"); | |
972 assert(topOfStack < istate->stack_base(), "Stack underrun"); | |
973 | |
974 #ifdef USELABELS | |
975 DISPATCH(opcode); | |
976 #else | |
977 switch (opcode) | |
978 #endif | |
979 { | |
980 CASE(_nop): | |
981 UPDATE_PC_AND_CONTINUE(1); | |
982 | |
983 /* Push miscellaneous constants onto the stack. */ | |
984 | |
985 CASE(_aconst_null): | |
986 SET_STACK_OBJECT(NULL, 0); | |
987 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); | |
988 | |
989 #undef OPC_CONST_n | |
990 #define OPC_CONST_n(opcode, const_type, value) \ | |
991 CASE(opcode): \ | |
992 SET_STACK_ ## const_type(value, 0); \ | |
993 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); | |
994 | |
995 OPC_CONST_n(_iconst_m1, INT, -1); | |
996 OPC_CONST_n(_iconst_0, INT, 0); | |
997 OPC_CONST_n(_iconst_1, INT, 1); | |
998 OPC_CONST_n(_iconst_2, INT, 2); | |
999 OPC_CONST_n(_iconst_3, INT, 3); | |
1000 OPC_CONST_n(_iconst_4, INT, 4); | |
1001 OPC_CONST_n(_iconst_5, INT, 5); | |
1002 OPC_CONST_n(_fconst_0, FLOAT, 0.0); | |
1003 OPC_CONST_n(_fconst_1, FLOAT, 1.0); | |
1004 OPC_CONST_n(_fconst_2, FLOAT, 2.0); | |
1005 | |
1006 #undef OPC_CONST2_n | |
1007 #define OPC_CONST2_n(opcname, value, key, kind) \ | |
1008 CASE(_##opcname): \ | |
1009 { \ | |
1010 SET_STACK_ ## kind(VM##key##Const##value(), 1); \ | |
1011 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); \ | |
1012 } | |
1013 OPC_CONST2_n(dconst_0, Zero, double, DOUBLE); | |
1014 OPC_CONST2_n(dconst_1, One, double, DOUBLE); | |
1015 OPC_CONST2_n(lconst_0, Zero, long, LONG); | |
1016 OPC_CONST2_n(lconst_1, One, long, LONG); | |
1017 | |
1018 /* Load constant from constant pool: */ | |
1019 | |
1020 /* Push a 1-byte signed integer value onto the stack. */ | |
1021 CASE(_bipush): | |
1022 SET_STACK_INT((jbyte)(pc[1]), 0); | |
1023 UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1); | |
1024 | |
1025 /* Push a 2-byte signed integer constant onto the stack. */ | |
1026 CASE(_sipush): | |
1027 SET_STACK_INT((int16_t)Bytes::get_Java_u2(pc + 1), 0); | |
1028 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1); | |
1029 | |
1030 /* load from local variable */ | |
1031 | |
1032 CASE(_aload): | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
1033 VERIFY_OOP(LOCALS_OBJECT(pc[1])); |
0 | 1034 SET_STACK_OBJECT(LOCALS_OBJECT(pc[1]), 0); |
1035 UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1); | |
1036 | |
1037 CASE(_iload): | |
1038 CASE(_fload): | |
1039 SET_STACK_SLOT(LOCALS_SLOT(pc[1]), 0); | |
1040 UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1); | |
1041 | |
1042 CASE(_lload): | |
1043 SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(pc[1]), 1); | |
1044 UPDATE_PC_AND_TOS_AND_CONTINUE(2, 2); | |
1045 | |
1046 CASE(_dload): | |
1047 SET_STACK_DOUBLE_FROM_ADDR(LOCALS_DOUBLE_AT(pc[1]), 1); | |
1048 UPDATE_PC_AND_TOS_AND_CONTINUE(2, 2); | |
1049 | |
1050 #undef OPC_LOAD_n | |
1051 #define OPC_LOAD_n(num) \ | |
1052 CASE(_aload_##num): \ | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
1053 VERIFY_OOP(LOCALS_OBJECT(num)); \ |
0 | 1054 SET_STACK_OBJECT(LOCALS_OBJECT(num), 0); \ |
1055 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); \ | |
1056 \ | |
1057 CASE(_iload_##num): \ | |
1058 CASE(_fload_##num): \ | |
1059 SET_STACK_SLOT(LOCALS_SLOT(num), 0); \ | |
1060 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); \ | |
1061 \ | |
1062 CASE(_lload_##num): \ | |
1063 SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(num), 1); \ | |
1064 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); \ | |
1065 CASE(_dload_##num): \ | |
1066 SET_STACK_DOUBLE_FROM_ADDR(LOCALS_DOUBLE_AT(num), 1); \ | |
1067 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); | |
1068 | |
1069 OPC_LOAD_n(0); | |
1070 OPC_LOAD_n(1); | |
1071 OPC_LOAD_n(2); | |
1072 OPC_LOAD_n(3); | |
1073 | |
1074 /* store to a local variable */ | |
1075 | |
1076 CASE(_astore): | |
1077 astore(topOfStack, -1, locals, pc[1]); | |
1078 UPDATE_PC_AND_TOS_AND_CONTINUE(2, -1); | |
1079 | |
1080 CASE(_istore): | |
1081 CASE(_fstore): | |
1082 SET_LOCALS_SLOT(STACK_SLOT(-1), pc[1]); | |
1083 UPDATE_PC_AND_TOS_AND_CONTINUE(2, -1); | |
1084 | |
1085 CASE(_lstore): | |
1086 SET_LOCALS_LONG(STACK_LONG(-1), pc[1]); | |
1087 UPDATE_PC_AND_TOS_AND_CONTINUE(2, -2); | |
1088 | |
1089 CASE(_dstore): | |
1090 SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), pc[1]); | |
1091 UPDATE_PC_AND_TOS_AND_CONTINUE(2, -2); | |
1092 | |
1093 CASE(_wide): { | |
1094 uint16_t reg = Bytes::get_Java_u2(pc + 2); | |
1095 | |
1096 opcode = pc[1]; | |
1097 switch(opcode) { | |
1098 case Bytecodes::_aload: | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
1099 VERIFY_OOP(LOCALS_OBJECT(reg)); |
0 | 1100 SET_STACK_OBJECT(LOCALS_OBJECT(reg), 0); |
1101 UPDATE_PC_AND_TOS_AND_CONTINUE(4, 1); | |
1102 | |
1103 case Bytecodes::_iload: | |
1104 case Bytecodes::_fload: | |
1105 SET_STACK_SLOT(LOCALS_SLOT(reg), 0); | |
1106 UPDATE_PC_AND_TOS_AND_CONTINUE(4, 1); | |
1107 | |
1108 case Bytecodes::_lload: | |
1109 SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(reg), 1); | |
1110 UPDATE_PC_AND_TOS_AND_CONTINUE(4, 2); | |
1111 | |
1112 case Bytecodes::_dload: | |
1113 SET_STACK_DOUBLE_FROM_ADDR(LOCALS_LONG_AT(reg), 1); | |
1114 UPDATE_PC_AND_TOS_AND_CONTINUE(4, 2); | |
1115 | |
1116 case Bytecodes::_astore: | |
1117 astore(topOfStack, -1, locals, reg); | |
1118 UPDATE_PC_AND_TOS_AND_CONTINUE(4, -1); | |
1119 | |
1120 case Bytecodes::_istore: | |
1121 case Bytecodes::_fstore: | |
1122 SET_LOCALS_SLOT(STACK_SLOT(-1), reg); | |
1123 UPDATE_PC_AND_TOS_AND_CONTINUE(4, -1); | |
1124 | |
1125 case Bytecodes::_lstore: | |
1126 SET_LOCALS_LONG(STACK_LONG(-1), reg); | |
1127 UPDATE_PC_AND_TOS_AND_CONTINUE(4, -2); | |
1128 | |
1129 case Bytecodes::_dstore: | |
1130 SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), reg); | |
1131 UPDATE_PC_AND_TOS_AND_CONTINUE(4, -2); | |
1132 | |
1133 case Bytecodes::_iinc: { | |
1134 int16_t offset = (int16_t)Bytes::get_Java_u2(pc+4); | |
1135 // Be nice to see what this generates.... QQQ | |
1136 SET_LOCALS_INT(LOCALS_INT(reg) + offset, reg); | |
1137 UPDATE_PC_AND_CONTINUE(6); | |
1138 } | |
1139 case Bytecodes::_ret: | |
1140 pc = istate->method()->code_base() + (intptr_t)(LOCALS_ADDR(reg)); | |
1141 UPDATE_PC_AND_CONTINUE(0); | |
1142 default: | |
1143 VM_JAVA_ERROR(vmSymbols::java_lang_InternalError(), "undefined opcode"); | |
1144 } | |
1145 } | |
1146 | |
1147 | |
1148 #undef OPC_STORE_n | |
1149 #define OPC_STORE_n(num) \ | |
1150 CASE(_astore_##num): \ | |
1151 astore(topOfStack, -1, locals, num); \ | |
1152 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \ | |
1153 CASE(_istore_##num): \ | |
1154 CASE(_fstore_##num): \ | |
1155 SET_LOCALS_SLOT(STACK_SLOT(-1), num); \ | |
1156 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); | |
1157 | |
1158 OPC_STORE_n(0); | |
1159 OPC_STORE_n(1); | |
1160 OPC_STORE_n(2); | |
1161 OPC_STORE_n(3); | |
1162 | |
1163 #undef OPC_DSTORE_n | |
1164 #define OPC_DSTORE_n(num) \ | |
1165 CASE(_dstore_##num): \ | |
1166 SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), num); \ | |
1167 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2); \ | |
1168 CASE(_lstore_##num): \ | |
1169 SET_LOCALS_LONG(STACK_LONG(-1), num); \ | |
1170 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2); | |
1171 | |
1172 OPC_DSTORE_n(0); | |
1173 OPC_DSTORE_n(1); | |
1174 OPC_DSTORE_n(2); | |
1175 OPC_DSTORE_n(3); | |
1176 | |
1177 /* stack pop, dup, and insert opcodes */ | |
1178 | |
1179 | |
1180 CASE(_pop): /* Discard the top item on the stack */ | |
1181 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); | |
1182 | |
1183 | |
1184 CASE(_pop2): /* Discard the top 2 items on the stack */ | |
1185 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2); | |
1186 | |
1187 | |
1188 CASE(_dup): /* Duplicate the top item on the stack */ | |
1189 dup(topOfStack); | |
1190 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); | |
1191 | |
1192 CASE(_dup2): /* Duplicate the top 2 items on the stack */ | |
1193 dup2(topOfStack); | |
1194 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); | |
1195 | |
1196 CASE(_dup_x1): /* insert top word two down */ | |
1197 dup_x1(topOfStack); | |
1198 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); | |
1199 | |
1200 CASE(_dup_x2): /* insert top word three down */ | |
1201 dup_x2(topOfStack); | |
1202 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); | |
1203 | |
1204 CASE(_dup2_x1): /* insert top 2 slots three down */ | |
1205 dup2_x1(topOfStack); | |
1206 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); | |
1207 | |
1208 CASE(_dup2_x2): /* insert top 2 slots four down */ | |
1209 dup2_x2(topOfStack); | |
1210 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); | |
1211 | |
1212 CASE(_swap): { /* swap top two elements on the stack */ | |
1213 swap(topOfStack); | |
1214 UPDATE_PC_AND_CONTINUE(1); | |
1215 } | |
1216 | |
1217 /* Perform various binary integer operations */ | |
1218 | |
1219 #undef OPC_INT_BINARY | |
1220 #define OPC_INT_BINARY(opcname, opname, test) \ | |
1221 CASE(_i##opcname): \ | |
1222 if (test && (STACK_INT(-1) == 0)) { \ | |
1223 VM_JAVA_ERROR(vmSymbols::java_lang_ArithmeticException(), \ | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
1224 "/ by zero"); \ |
0 | 1225 } \ |
1226 SET_STACK_INT(VMint##opname(STACK_INT(-2), \ | |
1227 STACK_INT(-1)), \ | |
1228 -2); \ | |
1229 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \ | |
1230 CASE(_l##opcname): \ | |
1231 { \ | |
1232 if (test) { \ | |
1233 jlong l1 = STACK_LONG(-1); \ | |
1234 if (VMlongEqz(l1)) { \ | |
1235 VM_JAVA_ERROR(vmSymbols::java_lang_ArithmeticException(), \ | |
1236 "/ by long zero"); \ | |
1237 } \ | |
1238 } \ | |
1239 /* First long at (-1,-2) next long at (-3,-4) */ \ | |
1240 SET_STACK_LONG(VMlong##opname(STACK_LONG(-3), \ | |
1241 STACK_LONG(-1)), \ | |
1242 -3); \ | |
1243 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2); \ | |
1244 } | |
1245 | |
1246 OPC_INT_BINARY(add, Add, 0); | |
1247 OPC_INT_BINARY(sub, Sub, 0); | |
1248 OPC_INT_BINARY(mul, Mul, 0); | |
1249 OPC_INT_BINARY(and, And, 0); | |
1250 OPC_INT_BINARY(or, Or, 0); | |
1251 OPC_INT_BINARY(xor, Xor, 0); | |
1252 OPC_INT_BINARY(div, Div, 1); | |
1253 OPC_INT_BINARY(rem, Rem, 1); | |
1254 | |
1255 | |
1256 /* Perform various binary floating number operations */ | |
1257 /* On some machine/platforms/compilers div zero check can be implicit */ | |
1258 | |
1259 #undef OPC_FLOAT_BINARY | |
1260 #define OPC_FLOAT_BINARY(opcname, opname) \ | |
1261 CASE(_d##opcname): { \ | |
1262 SET_STACK_DOUBLE(VMdouble##opname(STACK_DOUBLE(-3), \ | |
1263 STACK_DOUBLE(-1)), \ | |
1264 -3); \ | |
1265 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2); \ | |
1266 } \ | |
1267 CASE(_f##opcname): \ | |
1268 SET_STACK_FLOAT(VMfloat##opname(STACK_FLOAT(-2), \ | |
1269 STACK_FLOAT(-1)), \ | |
1270 -2); \ | |
1271 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); | |
1272 | |
1273 | |
1274 OPC_FLOAT_BINARY(add, Add); | |
1275 OPC_FLOAT_BINARY(sub, Sub); | |
1276 OPC_FLOAT_BINARY(mul, Mul); | |
1277 OPC_FLOAT_BINARY(div, Div); | |
1278 OPC_FLOAT_BINARY(rem, Rem); | |
1279 | |
1280 /* Shift operations | |
1281 * Shift left int and long: ishl, lshl | |
1282 * Logical shift right int and long w/zero extension: iushr, lushr | |
1283 * Arithmetic shift right int and long w/sign extension: ishr, lshr | |
1284 */ | |
1285 | |
1286 #undef OPC_SHIFT_BINARY | |
1287 #define OPC_SHIFT_BINARY(opcname, opname) \ | |
1288 CASE(_i##opcname): \ | |
1289 SET_STACK_INT(VMint##opname(STACK_INT(-2), \ | |
1290 STACK_INT(-1)), \ | |
1291 -2); \ | |
1292 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \ | |
1293 CASE(_l##opcname): \ | |
1294 { \ | |
1295 SET_STACK_LONG(VMlong##opname(STACK_LONG(-2), \ | |
1296 STACK_INT(-1)), \ | |
1297 -2); \ | |
1298 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \ | |
1299 } | |
1300 | |
1301 OPC_SHIFT_BINARY(shl, Shl); | |
1302 OPC_SHIFT_BINARY(shr, Shr); | |
1303 OPC_SHIFT_BINARY(ushr, Ushr); | |
1304 | |
1305 /* Increment local variable by constant */ | |
1306 CASE(_iinc): | |
1307 { | |
1308 // locals[pc[1]].j.i += (jbyte)(pc[2]); | |
1309 SET_LOCALS_INT(LOCALS_INT(pc[1]) + (jbyte)(pc[2]), pc[1]); | |
1310 UPDATE_PC_AND_CONTINUE(3); | |
1311 } | |
1312 | |
1313 /* negate the value on the top of the stack */ | |
1314 | |
1315 CASE(_ineg): | |
1316 SET_STACK_INT(VMintNeg(STACK_INT(-1)), -1); | |
1317 UPDATE_PC_AND_CONTINUE(1); | |
1318 | |
1319 CASE(_fneg): | |
1320 SET_STACK_FLOAT(VMfloatNeg(STACK_FLOAT(-1)), -1); | |
1321 UPDATE_PC_AND_CONTINUE(1); | |
1322 | |
1323 CASE(_lneg): | |
1324 { | |
1325 SET_STACK_LONG(VMlongNeg(STACK_LONG(-1)), -1); | |
1326 UPDATE_PC_AND_CONTINUE(1); | |
1327 } | |
1328 | |
1329 CASE(_dneg): | |
1330 { | |
1331 SET_STACK_DOUBLE(VMdoubleNeg(STACK_DOUBLE(-1)), -1); | |
1332 UPDATE_PC_AND_CONTINUE(1); | |
1333 } | |
1334 | |
1335 /* Conversion operations */ | |
1336 | |
1337 CASE(_i2f): /* convert top of stack int to float */ | |
1338 SET_STACK_FLOAT(VMint2Float(STACK_INT(-1)), -1); | |
1339 UPDATE_PC_AND_CONTINUE(1); | |
1340 | |
1341 CASE(_i2l): /* convert top of stack int to long */ | |
1342 { | |
1343 // this is ugly QQQ | |
1344 jlong r = VMint2Long(STACK_INT(-1)); | |
1345 MORE_STACK(-1); // Pop | |
1346 SET_STACK_LONG(r, 1); | |
1347 | |
1348 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); | |
1349 } | |
1350 | |
1351 CASE(_i2d): /* convert top of stack int to double */ | |
1352 { | |
1353 // this is ugly QQQ (why cast to jlong?? ) | |
1354 jdouble r = (jlong)STACK_INT(-1); | |
1355 MORE_STACK(-1); // Pop | |
1356 SET_STACK_DOUBLE(r, 1); | |
1357 | |
1358 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); | |
1359 } | |
1360 | |
1361 CASE(_l2i): /* convert top of stack long to int */ | |
1362 { | |
1363 jint r = VMlong2Int(STACK_LONG(-1)); | |
1364 MORE_STACK(-2); // Pop | |
1365 SET_STACK_INT(r, 0); | |
1366 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); | |
1367 } | |
1368 | |
1369 CASE(_l2f): /* convert top of stack long to float */ | |
1370 { | |
1371 jlong r = STACK_LONG(-1); | |
1372 MORE_STACK(-2); // Pop | |
1373 SET_STACK_FLOAT(VMlong2Float(r), 0); | |
1374 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); | |
1375 } | |
1376 | |
1377 CASE(_l2d): /* convert top of stack long to double */ | |
1378 { | |
1379 jlong r = STACK_LONG(-1); | |
1380 MORE_STACK(-2); // Pop | |
1381 SET_STACK_DOUBLE(VMlong2Double(r), 1); | |
1382 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); | |
1383 } | |
1384 | |
1385 CASE(_f2i): /* Convert top of stack float to int */ | |
1386 SET_STACK_INT(SharedRuntime::f2i(STACK_FLOAT(-1)), -1); | |
1387 UPDATE_PC_AND_CONTINUE(1); | |
1388 | |
1389 CASE(_f2l): /* convert top of stack float to long */ | |
1390 { | |
1391 jlong r = SharedRuntime::f2l(STACK_FLOAT(-1)); | |
1392 MORE_STACK(-1); // POP | |
1393 SET_STACK_LONG(r, 1); | |
1394 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); | |
1395 } | |
1396 | |
1397 CASE(_f2d): /* convert top of stack float to double */ | |
1398 { | |
1399 jfloat f; | |
1400 jdouble r; | |
1401 f = STACK_FLOAT(-1); | |
1402 r = (jdouble) f; | |
1403 MORE_STACK(-1); // POP | |
1404 SET_STACK_DOUBLE(r, 1); | |
1405 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); | |
1406 } | |
1407 | |
1408 CASE(_d2i): /* convert top of stack double to int */ | |
1409 { | |
1410 jint r1 = SharedRuntime::d2i(STACK_DOUBLE(-1)); | |
1411 MORE_STACK(-2); | |
1412 SET_STACK_INT(r1, 0); | |
1413 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); | |
1414 } | |
1415 | |
1416 CASE(_d2f): /* convert top of stack double to float */ | |
1417 { | |
1418 jfloat r1 = VMdouble2Float(STACK_DOUBLE(-1)); | |
1419 MORE_STACK(-2); | |
1420 SET_STACK_FLOAT(r1, 0); | |
1421 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); | |
1422 } | |
1423 | |
1424 CASE(_d2l): /* convert top of stack double to long */ | |
1425 { | |
1426 jlong r1 = SharedRuntime::d2l(STACK_DOUBLE(-1)); | |
1427 MORE_STACK(-2); | |
1428 SET_STACK_LONG(r1, 1); | |
1429 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); | |
1430 } | |
1431 | |
1432 CASE(_i2b): | |
1433 SET_STACK_INT(VMint2Byte(STACK_INT(-1)), -1); | |
1434 UPDATE_PC_AND_CONTINUE(1); | |
1435 | |
1436 CASE(_i2c): | |
1437 SET_STACK_INT(VMint2Char(STACK_INT(-1)), -1); | |
1438 UPDATE_PC_AND_CONTINUE(1); | |
1439 | |
1440 CASE(_i2s): | |
1441 SET_STACK_INT(VMint2Short(STACK_INT(-1)), -1); | |
1442 UPDATE_PC_AND_CONTINUE(1); | |
1443 | |
1444 /* comparison operators */ | |
1445 | |
1446 | |
1447 #define COMPARISON_OP(name, comparison) \ | |
1448 CASE(_if_icmp##name): { \ | |
1449 int skip = (STACK_INT(-2) comparison STACK_INT(-1)) \ | |
1450 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ | |
1451 address branch_pc = pc; \ | |
1452 UPDATE_PC_AND_TOS(skip, -2); \ | |
1453 DO_BACKEDGE_CHECKS(skip, branch_pc); \ | |
1454 CONTINUE; \ | |
1455 } \ | |
1456 CASE(_if##name): { \ | |
1457 int skip = (STACK_INT(-1) comparison 0) \ | |
1458 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ | |
1459 address branch_pc = pc; \ | |
1460 UPDATE_PC_AND_TOS(skip, -1); \ | |
1461 DO_BACKEDGE_CHECKS(skip, branch_pc); \ | |
1462 CONTINUE; \ | |
1463 } | |
1464 | |
1465 #define COMPARISON_OP2(name, comparison) \ | |
1466 COMPARISON_OP(name, comparison) \ | |
1467 CASE(_if_acmp##name): { \ | |
1468 int skip = (STACK_OBJECT(-2) comparison STACK_OBJECT(-1)) \ | |
1469 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ | |
1470 address branch_pc = pc; \ | |
1471 UPDATE_PC_AND_TOS(skip, -2); \ | |
1472 DO_BACKEDGE_CHECKS(skip, branch_pc); \ | |
1473 CONTINUE; \ | |
1474 } | |
1475 | |
1476 #define NULL_COMPARISON_NOT_OP(name) \ | |
1477 CASE(_if##name): { \ | |
520
52a431267315
6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents:
196
diff
changeset
|
1478 int skip = (!(STACK_OBJECT(-1) == NULL)) \ |
0 | 1479 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ |
1480 address branch_pc = pc; \ | |
1481 UPDATE_PC_AND_TOS(skip, -1); \ | |
1482 DO_BACKEDGE_CHECKS(skip, branch_pc); \ | |
1483 CONTINUE; \ | |
1484 } | |
1485 | |
1486 #define NULL_COMPARISON_OP(name) \ | |
1487 CASE(_if##name): { \ | |
520
52a431267315
6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents:
196
diff
changeset
|
1488 int skip = ((STACK_OBJECT(-1) == NULL)) \ |
0 | 1489 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ |
1490 address branch_pc = pc; \ | |
1491 UPDATE_PC_AND_TOS(skip, -1); \ | |
1492 DO_BACKEDGE_CHECKS(skip, branch_pc); \ | |
1493 CONTINUE; \ | |
1494 } | |
1495 COMPARISON_OP(lt, <); | |
1496 COMPARISON_OP(gt, >); | |
1497 COMPARISON_OP(le, <=); | |
1498 COMPARISON_OP(ge, >=); | |
1499 COMPARISON_OP2(eq, ==); /* include ref comparison */ | |
1500 COMPARISON_OP2(ne, !=); /* include ref comparison */ | |
1501 NULL_COMPARISON_OP(null); | |
1502 NULL_COMPARISON_NOT_OP(nonnull); | |
1503 | |
1504 /* Goto pc at specified offset in switch table. */ | |
1505 | |
1506 CASE(_tableswitch): { | |
1507 jint* lpc = (jint*)VMalignWordUp(pc+1); | |
1508 int32_t key = STACK_INT(-1); | |
1509 int32_t low = Bytes::get_Java_u4((address)&lpc[1]); | |
1510 int32_t high = Bytes::get_Java_u4((address)&lpc[2]); | |
1511 int32_t skip; | |
1512 key -= low; | |
1513 skip = ((uint32_t) key > (uint32_t)(high - low)) | |
1514 ? Bytes::get_Java_u4((address)&lpc[0]) | |
1515 : Bytes::get_Java_u4((address)&lpc[key + 3]); | |
1516 // Does this really need a full backedge check (osr?) | |
1517 address branch_pc = pc; | |
1518 UPDATE_PC_AND_TOS(skip, -1); | |
1519 DO_BACKEDGE_CHECKS(skip, branch_pc); | |
1520 CONTINUE; | |
1521 } | |
1522 | |
1523 /* Goto pc whose table entry matches specified key */ | |
1524 | |
1525 CASE(_lookupswitch): { | |
1526 jint* lpc = (jint*)VMalignWordUp(pc+1); | |
1527 int32_t key = STACK_INT(-1); | |
1528 int32_t skip = Bytes::get_Java_u4((address) lpc); /* default amount */ | |
1529 int32_t npairs = Bytes::get_Java_u4((address) &lpc[1]); | |
1530 while (--npairs >= 0) { | |
1531 lpc += 2; | |
1532 if (key == (int32_t)Bytes::get_Java_u4((address)lpc)) { | |
1533 skip = Bytes::get_Java_u4((address)&lpc[1]); | |
1534 break; | |
1535 } | |
1536 } | |
1537 address branch_pc = pc; | |
1538 UPDATE_PC_AND_TOS(skip, -1); | |
1539 DO_BACKEDGE_CHECKS(skip, branch_pc); | |
1540 CONTINUE; | |
1541 } | |
1542 | |
1543 CASE(_fcmpl): | |
1544 CASE(_fcmpg): | |
1545 { | |
1546 SET_STACK_INT(VMfloatCompare(STACK_FLOAT(-2), | |
1547 STACK_FLOAT(-1), | |
1548 (opcode == Bytecodes::_fcmpl ? -1 : 1)), | |
1549 -2); | |
1550 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); | |
1551 } | |
1552 | |
1553 CASE(_dcmpl): | |
1554 CASE(_dcmpg): | |
1555 { | |
1556 int r = VMdoubleCompare(STACK_DOUBLE(-3), | |
1557 STACK_DOUBLE(-1), | |
1558 (opcode == Bytecodes::_dcmpl ? -1 : 1)); | |
1559 MORE_STACK(-4); // Pop | |
1560 SET_STACK_INT(r, 0); | |
1561 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); | |
1562 } | |
1563 | |
1564 CASE(_lcmp): | |
1565 { | |
1566 int r = VMlongCompare(STACK_LONG(-3), STACK_LONG(-1)); | |
1567 MORE_STACK(-4); | |
1568 SET_STACK_INT(r, 0); | |
1569 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); | |
1570 } | |
1571 | |
1572 | |
1573 /* Return from a method */ | |
1574 | |
1575 CASE(_areturn): | |
1576 CASE(_ireturn): | |
1577 CASE(_freturn): | |
1578 { | |
1579 // Allow a safepoint before returning to frame manager. | |
1580 SAFEPOINT; | |
1581 | |
1582 goto handle_return; | |
1583 } | |
1584 | |
1585 CASE(_lreturn): | |
1586 CASE(_dreturn): | |
1587 { | |
1588 // Allow a safepoint before returning to frame manager. | |
1589 SAFEPOINT; | |
1590 goto handle_return; | |
1591 } | |
1592 | |
1593 CASE(_return_register_finalizer): { | |
1594 | |
1595 oop rcvr = LOCALS_OBJECT(0); | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
1596 VERIFY_OOP(rcvr); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1597 if (rcvr->klass()->has_finalizer()) { |
0 | 1598 CALL_VM(InterpreterRuntime::register_finalizer(THREAD, rcvr), handle_exception); |
1599 } | |
1600 goto handle_return; | |
1601 } | |
1602 CASE(_return): { | |
1603 | |
1604 // Allow a safepoint before returning to frame manager. | |
1605 SAFEPOINT; | |
1606 goto handle_return; | |
1607 } | |
1608 | |
1609 /* Array access byte-codes */ | |
1610 | |
1611 /* Every array access byte-code starts out like this */ | |
1612 // arrayOopDesc* arrObj = (arrayOopDesc*)STACK_OBJECT(arrayOff); | |
1613 #define ARRAY_INTRO(arrayOff) \ | |
1614 arrayOop arrObj = (arrayOop)STACK_OBJECT(arrayOff); \ | |
1615 jint index = STACK_INT(arrayOff + 1); \ | |
1616 char message[jintAsStringSize]; \ | |
1617 CHECK_NULL(arrObj); \ | |
1618 if ((uint32_t)index >= (uint32_t)arrObj->length()) { \ | |
1619 sprintf(message, "%d", index); \ | |
1620 VM_JAVA_ERROR(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), \ | |
1621 message); \ | |
1622 } | |
1623 | |
1624 /* 32-bit loads. These handle conversion from < 32-bit types */ | |
1625 #define ARRAY_LOADTO32(T, T2, format, stackRes, extra) \ | |
1626 { \ | |
1627 ARRAY_INTRO(-2); \ | |
1628 extra; \ | |
1629 SET_ ## stackRes(*(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)), \ | |
1630 -2); \ | |
1631 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \ | |
1632 } | |
1633 | |
1634 /* 64-bit loads */ | |
1635 #define ARRAY_LOADTO64(T,T2, stackRes, extra) \ | |
1636 { \ | |
1637 ARRAY_INTRO(-2); \ | |
1638 SET_ ## stackRes(*(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)), -1); \ | |
1639 extra; \ | |
1640 UPDATE_PC_AND_CONTINUE(1); \ | |
1641 } | |
1642 | |
1643 CASE(_iaload): | |
1644 ARRAY_LOADTO32(T_INT, jint, "%d", STACK_INT, 0); | |
1645 CASE(_faload): | |
1646 ARRAY_LOADTO32(T_FLOAT, jfloat, "%f", STACK_FLOAT, 0); | |
14399
48b178ff07b6
8019518: PPC64 (part 103): cppInterpreter: implement support for compressed Oops
goetz
parents:
14398
diff
changeset
|
1647 CASE(_aaload): { |
48b178ff07b6
8019518: PPC64 (part 103): cppInterpreter: implement support for compressed Oops
goetz
parents:
14398
diff
changeset
|
1648 ARRAY_INTRO(-2); |
48b178ff07b6
8019518: PPC64 (part 103): cppInterpreter: implement support for compressed Oops
goetz
parents:
14398
diff
changeset
|
1649 SET_STACK_OBJECT(((objArrayOop) arrObj)->obj_at(index), -2); |
48b178ff07b6
8019518: PPC64 (part 103): cppInterpreter: implement support for compressed Oops
goetz
parents:
14398
diff
changeset
|
1650 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); |
48b178ff07b6
8019518: PPC64 (part 103): cppInterpreter: implement support for compressed Oops
goetz
parents:
14398
diff
changeset
|
1651 } |
0 | 1652 CASE(_baload): |
1653 ARRAY_LOADTO32(T_BYTE, jbyte, "%d", STACK_INT, 0); | |
1654 CASE(_caload): | |
1655 ARRAY_LOADTO32(T_CHAR, jchar, "%d", STACK_INT, 0); | |
1656 CASE(_saload): | |
1657 ARRAY_LOADTO32(T_SHORT, jshort, "%d", STACK_INT, 0); | |
1658 CASE(_laload): | |
1659 ARRAY_LOADTO64(T_LONG, jlong, STACK_LONG, 0); | |
1660 CASE(_daload): | |
1661 ARRAY_LOADTO64(T_DOUBLE, jdouble, STACK_DOUBLE, 0); | |
1662 | |
1663 /* 32-bit stores. These handle conversion to < 32-bit types */ | |
1664 #define ARRAY_STOREFROM32(T, T2, format, stackSrc, extra) \ | |
1665 { \ | |
1666 ARRAY_INTRO(-3); \ | |
1667 extra; \ | |
1668 *(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)) = stackSrc( -1); \ | |
1669 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3); \ | |
1670 } | |
1671 | |
1672 /* 64-bit stores */ | |
1673 #define ARRAY_STOREFROM64(T, T2, stackSrc, extra) \ | |
1674 { \ | |
1675 ARRAY_INTRO(-4); \ | |
1676 extra; \ | |
1677 *(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)) = stackSrc( -1); \ | |
1678 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -4); \ | |
1679 } | |
1680 | |
1681 CASE(_iastore): | |
1682 ARRAY_STOREFROM32(T_INT, jint, "%d", STACK_INT, 0); | |
1683 CASE(_fastore): | |
1684 ARRAY_STOREFROM32(T_FLOAT, jfloat, "%f", STACK_FLOAT, 0); | |
1685 /* | |
1686 * This one looks different because of the assignability check | |
1687 */ | |
1688 CASE(_aastore): { | |
1689 oop rhsObject = STACK_OBJECT(-1); | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
1690 VERIFY_OOP(rhsObject); |
0 | 1691 ARRAY_INTRO( -3); |
1692 // arrObj, index are set | |
1693 if (rhsObject != NULL) { | |
1694 /* Check assignability of rhsObject into arrObj */ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1695 Klass* rhsKlassOop = rhsObject->klass(); // EBX (subclass) |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
1696 Klass* elemKlassOop = ObjArrayKlass::cast(arrObj->klass())->element_klass(); // superklass EAX |
0 | 1697 // |
1698 // Check for compatibilty. This check must not GC!! | |
1699 // Seems way more expensive now that we must dispatch | |
1700 // | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1701 if (rhsKlassOop != elemKlassOop && !rhsKlassOop->is_subtype_of(elemKlassOop)) { // ebx->is... |
0 | 1702 VM_JAVA_ERROR(vmSymbols::java_lang_ArrayStoreException(), ""); |
1703 } | |
1704 } | |
14398
641d55c11d6b
8019517: PPC64 (part 102): cppInterpreter: implement G1 support
goetz
parents:
14396
diff
changeset
|
1705 ((objArrayOopDesc *) arrObj)->obj_at_put(index, rhsObject); |
0 | 1706 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3); |
1707 } | |
1708 CASE(_bastore): | |
1709 ARRAY_STOREFROM32(T_BYTE, jbyte, "%d", STACK_INT, 0); | |
1710 CASE(_castore): | |
1711 ARRAY_STOREFROM32(T_CHAR, jchar, "%d", STACK_INT, 0); | |
1712 CASE(_sastore): | |
1713 ARRAY_STOREFROM32(T_SHORT, jshort, "%d", STACK_INT, 0); | |
1714 CASE(_lastore): | |
1715 ARRAY_STOREFROM64(T_LONG, jlong, STACK_LONG, 0); | |
1716 CASE(_dastore): | |
1717 ARRAY_STOREFROM64(T_DOUBLE, jdouble, STACK_DOUBLE, 0); | |
1718 | |
1719 CASE(_arraylength): | |
1720 { | |
1721 arrayOop ary = (arrayOop) STACK_OBJECT(-1); | |
1722 CHECK_NULL(ary); | |
1723 SET_STACK_INT(ary->length(), -1); | |
1724 UPDATE_PC_AND_CONTINUE(1); | |
1725 } | |
1726 | |
1727 /* monitorenter and monitorexit for locking/unlocking an object */ | |
1728 | |
1729 CASE(_monitorenter): { | |
1730 oop lockee = STACK_OBJECT(-1); | |
1731 // derefing's lockee ought to provoke implicit null check | |
1732 CHECK_NULL(lockee); | |
1733 // find a free monitor or one already allocated for this object | |
1734 // if we find a matching object then we need a new monitor | |
1735 // since this is recursive enter | |
1736 BasicObjectLock* limit = istate->monitor_base(); | |
1737 BasicObjectLock* most_recent = (BasicObjectLock*) istate->stack_base(); | |
1738 BasicObjectLock* entry = NULL; | |
1739 while (most_recent != limit ) { | |
1740 if (most_recent->obj() == NULL) entry = most_recent; | |
1741 else if (most_recent->obj() == lockee) break; | |
1742 most_recent++; | |
1743 } | |
1744 if (entry != NULL) { | |
1745 entry->set_obj(lockee); | |
14395
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1746 int success = false; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1747 uintptr_t epoch_mask_in_place = (uintptr_t)markOopDesc::epoch_mask_in_place; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1748 |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1749 markOop mark = lockee->mark(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1750 intptr_t hash = (intptr_t) markOopDesc::no_hash; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1751 // implies UseBiasedLocking |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1752 if (mark->has_bias_pattern()) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1753 uintptr_t thread_ident; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1754 uintptr_t anticipated_bias_locking_value; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1755 thread_ident = (uintptr_t)istate->thread(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1756 anticipated_bias_locking_value = |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1757 (((uintptr_t)lockee->klass()->prototype_header() | thread_ident) ^ (uintptr_t)mark) & |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1758 ~((uintptr_t) markOopDesc::age_mask_in_place); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1759 |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1760 if (anticipated_bias_locking_value == 0) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1761 // already biased towards this thread, nothing to do |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1762 if (PrintBiasedLockingStatistics) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1763 (* BiasedLocking::biased_lock_entry_count_addr())++; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1764 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1765 success = true; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1766 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1767 else if ((anticipated_bias_locking_value & markOopDesc::biased_lock_mask_in_place) != 0) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1768 // try revoke bias |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1769 markOop header = lockee->klass()->prototype_header(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1770 if (hash != markOopDesc::no_hash) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1771 header = header->copy_set_hash(hash); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1772 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1773 if (Atomic::cmpxchg_ptr(header, lockee->mark_addr(), mark) == mark) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1774 if (PrintBiasedLockingStatistics) |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1775 (*BiasedLocking::revoked_lock_entry_count_addr())++; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1776 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1777 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1778 else if ((anticipated_bias_locking_value & epoch_mask_in_place) !=0) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1779 // try rebias |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1780 markOop new_header = (markOop) ( (intptr_t) lockee->klass()->prototype_header() | thread_ident); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1781 if (hash != markOopDesc::no_hash) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1782 new_header = new_header->copy_set_hash(hash); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1783 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1784 if (Atomic::cmpxchg_ptr((void*)new_header, lockee->mark_addr(), mark) == mark) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1785 if (PrintBiasedLockingStatistics) |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1786 (* BiasedLocking::rebiased_lock_entry_count_addr())++; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1787 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1788 else { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1789 CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1790 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1791 success = true; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1792 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1793 else { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1794 // try to bias towards thread in case object is anonymously biased |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1795 markOop header = (markOop) ((uintptr_t) mark & ((uintptr_t)markOopDesc::biased_lock_mask_in_place | |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1796 (uintptr_t)markOopDesc::age_mask_in_place | |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1797 epoch_mask_in_place)); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1798 if (hash != markOopDesc::no_hash) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1799 header = header->copy_set_hash(hash); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1800 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1801 markOop new_header = (markOop) ((uintptr_t) header | thread_ident); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1802 // debugging hint |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1803 DEBUG_ONLY(entry->lock()->set_displaced_header((markOop) (uintptr_t) 0xdeaddead);) |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1804 if (Atomic::cmpxchg_ptr((void*)new_header, lockee->mark_addr(), header) == header) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1805 if (PrintBiasedLockingStatistics) |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1806 (* BiasedLocking::anonymously_biased_lock_entry_count_addr())++; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1807 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1808 else { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1809 CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1810 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1811 success = true; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1812 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1813 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1814 |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1815 // traditional lightweight locking |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1816 if (!success) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1817 markOop displaced = lockee->mark()->set_unlocked(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1818 entry->lock()->set_displaced_header(displaced); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1819 bool call_vm = UseHeavyMonitors; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1820 if (call_vm || Atomic::cmpxchg_ptr(entry, lockee->mark_addr(), displaced) != displaced) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1821 // Is it simple recursive case? |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1822 if (!call_vm && THREAD->is_lock_owned((address) displaced->clear_lock_bits())) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1823 entry->lock()->set_displaced_header(NULL); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1824 } else { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1825 CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1826 } |
0 | 1827 } |
1828 } | |
1829 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); | |
1830 } else { | |
1831 istate->set_msg(more_monitors); | |
1832 UPDATE_PC_AND_RETURN(0); // Re-execute | |
1833 } | |
1834 } | |
1835 | |
1836 CASE(_monitorexit): { | |
1837 oop lockee = STACK_OBJECT(-1); | |
1838 CHECK_NULL(lockee); | |
1839 // derefing's lockee ought to provoke implicit null check | |
1840 // find our monitor slot | |
1841 BasicObjectLock* limit = istate->monitor_base(); | |
1842 BasicObjectLock* most_recent = (BasicObjectLock*) istate->stack_base(); | |
1843 while (most_recent != limit ) { | |
1844 if ((most_recent)->obj() == lockee) { | |
1845 BasicLock* lock = most_recent->lock(); | |
1846 markOop header = lock->displaced_header(); | |
1847 most_recent->set_obj(NULL); | |
14395
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1848 if (!lockee->mark()->has_bias_pattern()) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1849 bool call_vm = UseHeavyMonitors; |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1850 // If it isn't recursive we either must swap old header or call the runtime |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1851 if (header != NULL || call_vm) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1852 if (call_vm || Atomic::cmpxchg_ptr(header, lockee->mark_addr(), lock) != lock) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1853 // restore object for the slow case |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1854 most_recent->set_obj(lockee); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1855 CALL_VM(InterpreterRuntime::monitorexit(THREAD, most_recent), handle_exception); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
1856 } |
0 | 1857 } |
1858 } | |
1859 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); | |
1860 } | |
1861 most_recent++; | |
1862 } | |
1863 // Need to throw illegal monitor state exception | |
1864 CALL_VM(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD), handle_exception); | |
2480 | 1865 ShouldNotReachHere(); |
0 | 1866 } |
1867 | |
1868 /* All of the non-quick opcodes. */ | |
1869 | |
1870 /* -Set clobbersCpIndex true if the quickened opcode clobbers the | |
1871 * constant pool index in the instruction. | |
1872 */ | |
1873 CASE(_getfield): | |
1874 CASE(_getstatic): | |
1875 { | |
1876 u2 index; | |
1877 ConstantPoolCacheEntry* cache; | |
1878 index = Bytes::get_native_u2(pc+1); | |
1879 | |
1880 // QQQ Need to make this as inlined as possible. Probably need to | |
1881 // split all the bytecode cases out so c++ compiler has a chance | |
1882 // for constant prop to fold everything possible away. | |
1883 | |
1884 cache = cp->entry_at(index); | |
1885 if (!cache->is_resolved((Bytecodes::Code)opcode)) { | |
1886 CALL_VM(InterpreterRuntime::resolve_get_put(THREAD, (Bytecodes::Code)opcode), | |
1887 handle_exception); | |
1888 cache = cp->entry_at(index); | |
1889 } | |
1890 | |
1891 #ifdef VM_JVMTI | |
1892 if (_jvmti_interp_events) { | |
1893 int *count_addr; | |
1894 oop obj; | |
1895 // Check to see if a field modification watch has been set | |
1896 // before we take the time to call into the VM. | |
1897 count_addr = (int *)JvmtiExport::get_field_access_count_addr(); | |
1898 if ( *count_addr > 0 ) { | |
1899 if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) { | |
1900 obj = (oop)NULL; | |
1901 } else { | |
1902 obj = (oop) STACK_OBJECT(-1); | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
1903 VERIFY_OOP(obj); |
0 | 1904 } |
1905 CALL_VM(InterpreterRuntime::post_field_access(THREAD, | |
1906 obj, | |
1907 cache), | |
1908 handle_exception); | |
1909 } | |
1910 } | |
1911 #endif /* VM_JVMTI */ | |
1912 | |
1913 oop obj; | |
1914 if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) { | |
6926 | 1915 Klass* k = cache->f1_as_klass(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1916 obj = k->java_mirror(); |
0 | 1917 MORE_STACK(1); // Assume single slot push |
1918 } else { | |
1919 obj = (oop) STACK_OBJECT(-1); | |
1920 CHECK_NULL(obj); | |
1921 } | |
1922 | |
1923 // | |
1924 // Now store the result on the stack | |
1925 // | |
1926 TosState tos_type = cache->flag_state(); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1927 int field_offset = cache->f2_as_index(); |
0 | 1928 if (cache->is_volatile()) { |
1929 if (tos_type == atos) { | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
1930 VERIFY_OOP(obj->obj_field_acquire(field_offset)); |
0 | 1931 SET_STACK_OBJECT(obj->obj_field_acquire(field_offset), -1); |
1932 } else if (tos_type == itos) { | |
1933 SET_STACK_INT(obj->int_field_acquire(field_offset), -1); | |
1934 } else if (tos_type == ltos) { | |
1935 SET_STACK_LONG(obj->long_field_acquire(field_offset), 0); | |
1936 MORE_STACK(1); | |
1937 } else if (tos_type == btos) { | |
1938 SET_STACK_INT(obj->byte_field_acquire(field_offset), -1); | |
1939 } else if (tos_type == ctos) { | |
1940 SET_STACK_INT(obj->char_field_acquire(field_offset), -1); | |
1941 } else if (tos_type == stos) { | |
1942 SET_STACK_INT(obj->short_field_acquire(field_offset), -1); | |
1943 } else if (tos_type == ftos) { | |
1944 SET_STACK_FLOAT(obj->float_field_acquire(field_offset), -1); | |
1945 } else { | |
1946 SET_STACK_DOUBLE(obj->double_field_acquire(field_offset), 0); | |
1947 MORE_STACK(1); | |
1948 } | |
1949 } else { | |
1950 if (tos_type == atos) { | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
1951 VERIFY_OOP(obj->obj_field(field_offset)); |
0 | 1952 SET_STACK_OBJECT(obj->obj_field(field_offset), -1); |
1953 } else if (tos_type == itos) { | |
1954 SET_STACK_INT(obj->int_field(field_offset), -1); | |
1955 } else if (tos_type == ltos) { | |
1956 SET_STACK_LONG(obj->long_field(field_offset), 0); | |
1957 MORE_STACK(1); | |
1958 } else if (tos_type == btos) { | |
1959 SET_STACK_INT(obj->byte_field(field_offset), -1); | |
1960 } else if (tos_type == ctos) { | |
1961 SET_STACK_INT(obj->char_field(field_offset), -1); | |
1962 } else if (tos_type == stos) { | |
1963 SET_STACK_INT(obj->short_field(field_offset), -1); | |
1964 } else if (tos_type == ftos) { | |
1965 SET_STACK_FLOAT(obj->float_field(field_offset), -1); | |
1966 } else { | |
1967 SET_STACK_DOUBLE(obj->double_field(field_offset), 0); | |
1968 MORE_STACK(1); | |
1969 } | |
1970 } | |
1971 | |
1972 UPDATE_PC_AND_CONTINUE(3); | |
1973 } | |
1974 | |
1975 CASE(_putfield): | |
1976 CASE(_putstatic): | |
1977 { | |
1978 u2 index = Bytes::get_native_u2(pc+1); | |
1979 ConstantPoolCacheEntry* cache = cp->entry_at(index); | |
1980 if (!cache->is_resolved((Bytecodes::Code)opcode)) { | |
1981 CALL_VM(InterpreterRuntime::resolve_get_put(THREAD, (Bytecodes::Code)opcode), | |
1982 handle_exception); | |
1983 cache = cp->entry_at(index); | |
1984 } | |
1985 | |
1986 #ifdef VM_JVMTI | |
1987 if (_jvmti_interp_events) { | |
1988 int *count_addr; | |
1989 oop obj; | |
1990 // Check to see if a field modification watch has been set | |
1991 // before we take the time to call into the VM. | |
1992 count_addr = (int *)JvmtiExport::get_field_modification_count_addr(); | |
1993 if ( *count_addr > 0 ) { | |
1994 if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) { | |
1995 obj = (oop)NULL; | |
1996 } | |
1997 else { | |
1998 if (cache->is_long() || cache->is_double()) { | |
1999 obj = (oop) STACK_OBJECT(-3); | |
2000 } else { | |
2001 obj = (oop) STACK_OBJECT(-2); | |
2002 } | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
2003 VERIFY_OOP(obj); |
0 | 2004 } |
2005 | |
2006 CALL_VM(InterpreterRuntime::post_field_modification(THREAD, | |
2007 obj, | |
2008 cache, | |
2009 (jvalue *)STACK_SLOT(-1)), | |
2010 handle_exception); | |
2011 } | |
2012 } | |
2013 #endif /* VM_JVMTI */ | |
2014 | |
2015 // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases | |
2016 // out so c++ compiler has a chance for constant prop to fold everything possible away. | |
2017 | |
2018 oop obj; | |
2019 int count; | |
2020 TosState tos_type = cache->flag_state(); | |
2021 | |
2022 count = -1; | |
2023 if (tos_type == ltos || tos_type == dtos) { | |
2024 --count; | |
2025 } | |
2026 if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) { | |
6926 | 2027 Klass* k = cache->f1_as_klass(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2028 obj = k->java_mirror(); |
0 | 2029 } else { |
2030 --count; | |
2031 obj = (oop) STACK_OBJECT(count); | |
2032 CHECK_NULL(obj); | |
2033 } | |
2034 | |
2035 // | |
2036 // Now store the result | |
2037 // | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
2038 int field_offset = cache->f2_as_index(); |
0 | 2039 if (cache->is_volatile()) { |
2040 if (tos_type == itos) { | |
2041 obj->release_int_field_put(field_offset, STACK_INT(-1)); | |
2042 } else if (tos_type == atos) { | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
2043 VERIFY_OOP(STACK_OBJECT(-1)); |
0 | 2044 obj->release_obj_field_put(field_offset, STACK_OBJECT(-1)); |
2045 } else if (tos_type == btos) { | |
2046 obj->release_byte_field_put(field_offset, STACK_INT(-1)); | |
2047 } else if (tos_type == ltos) { | |
2048 obj->release_long_field_put(field_offset, STACK_LONG(-1)); | |
2049 } else if (tos_type == ctos) { | |
2050 obj->release_char_field_put(field_offset, STACK_INT(-1)); | |
2051 } else if (tos_type == stos) { | |
2052 obj->release_short_field_put(field_offset, STACK_INT(-1)); | |
2053 } else if (tos_type == ftos) { | |
2054 obj->release_float_field_put(field_offset, STACK_FLOAT(-1)); | |
2055 } else { | |
2056 obj->release_double_field_put(field_offset, STACK_DOUBLE(-1)); | |
2057 } | |
2058 OrderAccess::storeload(); | |
2059 } else { | |
2060 if (tos_type == itos) { | |
2061 obj->int_field_put(field_offset, STACK_INT(-1)); | |
2062 } else if (tos_type == atos) { | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
2063 VERIFY_OOP(STACK_OBJECT(-1)); |
0 | 2064 obj->obj_field_put(field_offset, STACK_OBJECT(-1)); |
2065 } else if (tos_type == btos) { | |
2066 obj->byte_field_put(field_offset, STACK_INT(-1)); | |
2067 } else if (tos_type == ltos) { | |
2068 obj->long_field_put(field_offset, STACK_LONG(-1)); | |
2069 } else if (tos_type == ctos) { | |
2070 obj->char_field_put(field_offset, STACK_INT(-1)); | |
2071 } else if (tos_type == stos) { | |
2072 obj->short_field_put(field_offset, STACK_INT(-1)); | |
2073 } else if (tos_type == ftos) { | |
2074 obj->float_field_put(field_offset, STACK_FLOAT(-1)); | |
2075 } else { | |
2076 obj->double_field_put(field_offset, STACK_DOUBLE(-1)); | |
2077 } | |
2078 } | |
2079 | |
2080 UPDATE_PC_AND_TOS_AND_CONTINUE(3, count); | |
2081 } | |
2082 | |
2083 CASE(_new): { | |
2084 u2 index = Bytes::get_Java_u2(pc+1); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2085 ConstantPool* constants = istate->method()->constants(); |
0 | 2086 if (!constants->tag_at(index).is_unresolved_klass()) { |
2087 // Make sure klass is initialized and doesn't have a finalizer | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2088 Klass* entry = constants->slot_at(index).get_klass(); |
0 | 2089 assert(entry->is_klass(), "Should be resolved klass"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2090 Klass* k_entry = (Klass*) entry; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2091 assert(k_entry->oop_is_instance(), "Should be InstanceKlass"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2092 InstanceKlass* ik = (InstanceKlass*) k_entry; |
0 | 2093 if ( ik->is_initialized() && ik->can_be_fastpath_allocated() ) { |
2094 size_t obj_size = ik->size_helper(); | |
2095 oop result = NULL; | |
2096 // If the TLAB isn't pre-zeroed then we'll have to do it | |
2097 bool need_zero = !ZeroTLAB; | |
2098 if (UseTLAB) { | |
2099 result = (oop) THREAD->tlab().allocate(obj_size); | |
2100 } | |
2101 if (result == NULL) { | |
2102 need_zero = true; | |
2103 // Try allocate in shared eden | |
2104 retry: | |
2105 HeapWord* compare_to = *Universe::heap()->top_addr(); | |
2106 HeapWord* new_top = compare_to + obj_size; | |
2107 if (new_top <= *Universe::heap()->end_addr()) { | |
2108 if (Atomic::cmpxchg_ptr(new_top, Universe::heap()->top_addr(), compare_to) != compare_to) { | |
2109 goto retry; | |
2110 } | |
2111 result = (oop) compare_to; | |
2112 } | |
2113 } | |
2114 if (result != NULL) { | |
2115 // Initialize object (if nonzero size and need) and then the header | |
2116 if (need_zero ) { | |
2117 HeapWord* to_zero = (HeapWord*) result + sizeof(oopDesc) / oopSize; | |
2118 obj_size -= sizeof(oopDesc) / oopSize; | |
2119 if (obj_size > 0 ) { | |
2120 memset(to_zero, 0, obj_size * HeapWordSize); | |
2121 } | |
2122 } | |
2123 if (UseBiasedLocking) { | |
2124 result->set_mark(ik->prototype_header()); | |
2125 } else { | |
2126 result->set_mark(markOopDesc::prototype()); | |
2127 } | |
167
feeb96a45707
6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC
coleenp
parents:
123
diff
changeset
|
2128 result->set_klass_gap(0); |
0 | 2129 result->set_klass(k_entry); |
2130 SET_STACK_OBJECT(result, 0); | |
2131 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1); | |
2132 } | |
2133 } | |
2134 } | |
2135 // Slow case allocation | |
2136 CALL_VM(InterpreterRuntime::_new(THREAD, METHOD->constants(), index), | |
2137 handle_exception); | |
2138 SET_STACK_OBJECT(THREAD->vm_result(), 0); | |
2139 THREAD->set_vm_result(NULL); | |
2140 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1); | |
2141 } | |
2142 CASE(_anewarray): { | |
2143 u2 index = Bytes::get_Java_u2(pc+1); | |
2144 jint size = STACK_INT(-1); | |
2145 CALL_VM(InterpreterRuntime::anewarray(THREAD, METHOD->constants(), index, size), | |
2146 handle_exception); | |
2147 SET_STACK_OBJECT(THREAD->vm_result(), -1); | |
2148 THREAD->set_vm_result(NULL); | |
2149 UPDATE_PC_AND_CONTINUE(3); | |
2150 } | |
2151 CASE(_multianewarray): { | |
2152 jint dims = *(pc+3); | |
2153 jint size = STACK_INT(-1); | |
2154 // stack grows down, dimensions are up! | |
2155 jint *dimarray = | |
1509 | 2156 (jint*)&topOfStack[dims * Interpreter::stackElementWords+ |
2157 Interpreter::stackElementWords-1]; | |
0 | 2158 //adjust pointer to start of stack element |
2159 CALL_VM(InterpreterRuntime::multianewarray(THREAD, dimarray), | |
2160 handle_exception); | |
2161 SET_STACK_OBJECT(THREAD->vm_result(), -dims); | |
2162 THREAD->set_vm_result(NULL); | |
2163 UPDATE_PC_AND_TOS_AND_CONTINUE(4, -(dims-1)); | |
2164 } | |
2165 CASE(_checkcast): | |
2166 if (STACK_OBJECT(-1) != NULL) { | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
2167 VERIFY_OOP(STACK_OBJECT(-1)); |
0 | 2168 u2 index = Bytes::get_Java_u2(pc+1); |
2169 if (ProfileInterpreter) { | |
2170 // needs Profile_checkcast QQQ | |
2171 ShouldNotReachHere(); | |
2172 } | |
2173 // Constant pool may have actual klass or unresolved klass. If it is | |
2174 // unresolved we must resolve it | |
2175 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) { | |
2176 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception); | |
2177 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2178 Klass* klassOf = (Klass*) METHOD->constants()->slot_at(index).get_klass(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2179 Klass* objKlassOop = STACK_OBJECT(-1)->klass(); //ebx |
0 | 2180 // |
2181 // Check for compatibilty. This check must not GC!! | |
2182 // Seems way more expensive now that we must dispatch | |
2183 // | |
2184 if (objKlassOop != klassOf && | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2185 !objKlassOop->is_subtype_of(klassOf)) { |
0 | 2186 ResourceMark rm(THREAD); |
6983 | 2187 const char* objName = objKlassOop->external_name(); |
2188 const char* klassName = klassOf->external_name(); | |
0 | 2189 char* message = SharedRuntime::generate_class_cast_message( |
2190 objName, klassName); | |
2191 VM_JAVA_ERROR(vmSymbols::java_lang_ClassCastException(), message); | |
2192 } | |
2193 } else { | |
2194 if (UncommonNullCast) { | |
2195 // istate->method()->set_null_cast_seen(); | |
2196 // [RGV] Not sure what to do here! | |
2197 | |
2198 } | |
2199 } | |
2200 UPDATE_PC_AND_CONTINUE(3); | |
2201 | |
2202 CASE(_instanceof): | |
2203 if (STACK_OBJECT(-1) == NULL) { | |
2204 SET_STACK_INT(0, -1); | |
2205 } else { | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
2206 VERIFY_OOP(STACK_OBJECT(-1)); |
0 | 2207 u2 index = Bytes::get_Java_u2(pc+1); |
2208 // Constant pool may have actual klass or unresolved klass. If it is | |
2209 // unresolved we must resolve it | |
2210 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) { | |
2211 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception); | |
2212 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2213 Klass* klassOf = (Klass*) METHOD->constants()->slot_at(index).get_klass(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2214 Klass* objKlassOop = STACK_OBJECT(-1)->klass(); |
0 | 2215 // |
2216 // Check for compatibilty. This check must not GC!! | |
2217 // Seems way more expensive now that we must dispatch | |
2218 // | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2219 if ( objKlassOop == klassOf || objKlassOop->is_subtype_of(klassOf)) { |
0 | 2220 SET_STACK_INT(1, -1); |
2221 } else { | |
2222 SET_STACK_INT(0, -1); | |
2223 } | |
2224 } | |
2225 UPDATE_PC_AND_CONTINUE(3); | |
2226 | |
2227 CASE(_ldc_w): | |
2228 CASE(_ldc): | |
2229 { | |
2230 u2 index; | |
2231 bool wide = false; | |
2232 int incr = 2; // frequent case | |
2233 if (opcode == Bytecodes::_ldc) { | |
2234 index = pc[1]; | |
2235 } else { | |
2236 index = Bytes::get_Java_u2(pc+1); | |
2237 incr = 3; | |
2238 wide = true; | |
2239 } | |
2240 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2241 ConstantPool* constants = METHOD->constants(); |
0 | 2242 switch (constants->tag_at(index).value()) { |
2243 case JVM_CONSTANT_Integer: | |
2244 SET_STACK_INT(constants->int_at(index), 0); | |
2245 break; | |
2246 | |
2247 case JVM_CONSTANT_Float: | |
2248 SET_STACK_FLOAT(constants->float_at(index), 0); | |
2249 break; | |
2250 | |
2251 case JVM_CONSTANT_String: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2252 { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2253 oop result = constants->resolved_references()->obj_at(index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2254 if (result == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2255 CALL_VM(InterpreterRuntime::resolve_ldc(THREAD, (Bytecodes::Code) opcode), handle_exception); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2256 SET_STACK_OBJECT(THREAD->vm_result(), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2257 THREAD->set_vm_result(NULL); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2258 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2259 VERIFY_OOP(result); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2260 SET_STACK_OBJECT(result, 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2261 } |
0 | 2262 break; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2263 } |
0 | 2264 |
2265 case JVM_CONSTANT_Class: | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2260
diff
changeset
|
2266 VERIFY_OOP(constants->resolved_klass_at(index)->java_mirror()); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2260
diff
changeset
|
2267 SET_STACK_OBJECT(constants->resolved_klass_at(index)->java_mirror(), 0); |
0 | 2268 break; |
2269 | |
2270 case JVM_CONSTANT_UnresolvedClass: | |
2271 case JVM_CONSTANT_UnresolvedClassInError: | |
2272 CALL_VM(InterpreterRuntime::ldc(THREAD, wide), handle_exception); | |
2273 SET_STACK_OBJECT(THREAD->vm_result(), 0); | |
2274 THREAD->set_vm_result(NULL); | |
2275 break; | |
2276 | |
2277 default: ShouldNotReachHere(); | |
2278 } | |
2279 UPDATE_PC_AND_TOS_AND_CONTINUE(incr, 1); | |
2280 } | |
2281 | |
2282 CASE(_ldc2_w): | |
2283 { | |
2284 u2 index = Bytes::get_Java_u2(pc+1); | |
2285 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2286 ConstantPool* constants = METHOD->constants(); |
0 | 2287 switch (constants->tag_at(index).value()) { |
2288 | |
2289 case JVM_CONSTANT_Long: | |
2290 SET_STACK_LONG(constants->long_at(index), 1); | |
2291 break; | |
2292 | |
2293 case JVM_CONSTANT_Double: | |
2294 SET_STACK_DOUBLE(constants->double_at(index), 1); | |
2295 break; | |
2296 default: ShouldNotReachHere(); | |
2297 } | |
2298 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 2); | |
2299 } | |
2300 | |
2480 | 2301 CASE(_fast_aldc_w): |
2302 CASE(_fast_aldc): { | |
2303 u2 index; | |
2304 int incr; | |
2305 if (opcode == Bytecodes::_fast_aldc) { | |
2306 index = pc[1]; | |
2307 incr = 2; | |
2308 } else { | |
2309 index = Bytes::get_native_u2(pc+1); | |
2310 incr = 3; | |
2311 } | |
2312 | |
2313 // We are resolved if the f1 field contains a non-null object (CallSite, etc.) | |
2314 // This kind of CP cache entry does not need to match the flags byte, because | |
2315 // there is a 1-1 relation between bytecode type and CP entry type. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2316 ConstantPool* constants = METHOD->constants(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2317 oop result = constants->resolved_references()->obj_at(index); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
2318 if (result == NULL) { |
2480 | 2319 CALL_VM(InterpreterRuntime::resolve_ldc(THREAD, (Bytecodes::Code) opcode), |
2320 handle_exception); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2321 result = THREAD->vm_result(); |
2480 | 2322 } |
2323 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
2324 VERIFY_OOP(result); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
2325 SET_STACK_OBJECT(result, 0); |
2480 | 2326 UPDATE_PC_AND_TOS_AND_CONTINUE(incr, 1); |
2327 } | |
2328 | |
2329 CASE(_invokedynamic): { | |
6926 | 2330 |
2480 | 2331 if (!EnableInvokeDynamic) { |
2332 // We should not encounter this bytecode if !EnableInvokeDynamic. | |
2333 // The verifier will stop it. However, if we get past the verifier, | |
2334 // this will stop the thread in a reasonable way, without crashing the JVM. | |
2335 CALL_VM(InterpreterRuntime::throw_IncompatibleClassChangeError(THREAD), | |
2336 handle_exception); | |
2337 ShouldNotReachHere(); | |
2338 } | |
2339 | |
6926 | 2340 u4 index = Bytes::get_native_u4(pc+1); |
2341 ConstantPoolCacheEntry* cache = cp->constant_pool()->invokedynamic_cp_cache_entry_at(index); | |
2480 | 2342 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2343 // We are resolved if the resolved_references field contains a non-null object (CallSite, etc.) |
2480 | 2344 // This kind of CP cache entry does not need to match the flags byte, because |
2345 // there is a 1-1 relation between bytecode type and CP entry type. | |
6926 | 2346 if (! cache->is_resolved((Bytecodes::Code) opcode)) { |
2480 | 2347 CALL_VM(InterpreterRuntime::resolve_invokedynamic(THREAD), |
2348 handle_exception); | |
6926 | 2349 cache = cp->constant_pool()->invokedynamic_cp_cache_entry_at(index); |
2350 } | |
2351 | |
2352 Method* method = cache->f1_as_method(); | |
11046
6a0ead6dc6db
8017531: 8010460 changes broke bytecodeInterpreter.cpp
goetz
parents:
10393
diff
changeset
|
2353 if (VerifyOops) method->verify(); |
6926 | 2354 |
2355 if (cache->has_appendix()) { | |
2356 ConstantPool* constants = METHOD->constants(); | |
2357 SET_STACK_OBJECT(cache->appendix_if_resolved(constants), 0); | |
2358 MORE_STACK(1); | |
2359 } | |
2360 | |
2361 istate->set_msg(call_method); | |
2362 istate->set_callee(method); | |
2363 istate->set_callee_entry_point(method->from_interpreted_entry()); | |
2364 istate->set_bcp_advance(5); | |
2365 | |
2366 UPDATE_PC_AND_RETURN(0); // I'll be back... | |
2367 } | |
2368 | |
2369 CASE(_invokehandle): { | |
2370 | |
2371 if (!EnableInvokeDynamic) { | |
2372 ShouldNotReachHere(); | |
2480 | 2373 } |
2374 | |
6926 | 2375 u2 index = Bytes::get_native_u2(pc+1); |
2376 ConstantPoolCacheEntry* cache = cp->entry_at(index); | |
2377 | |
2378 if (! cache->is_resolved((Bytecodes::Code) opcode)) { | |
2379 CALL_VM(InterpreterRuntime::resolve_invokehandle(THREAD), | |
2380 handle_exception); | |
2381 cache = cp->entry_at(index); | |
2382 } | |
2383 | |
2384 Method* method = cache->f1_as_method(); | |
11046
6a0ead6dc6db
8017531: 8010460 changes broke bytecodeInterpreter.cpp
goetz
parents:
10393
diff
changeset
|
2385 if (VerifyOops) method->verify(); |
6926 | 2386 |
2387 if (cache->has_appendix()) { | |
2388 ConstantPool* constants = METHOD->constants(); | |
2389 SET_STACK_OBJECT(cache->appendix_if_resolved(constants), 0); | |
2390 MORE_STACK(1); | |
2391 } | |
2392 | |
2393 istate->set_msg(call_method); | |
2394 istate->set_callee(method); | |
2395 istate->set_callee_entry_point(method->from_interpreted_entry()); | |
2396 istate->set_bcp_advance(3); | |
2480 | 2397 |
2398 UPDATE_PC_AND_RETURN(0); // I'll be back... | |
2399 } | |
2400 | |
0 | 2401 CASE(_invokeinterface): { |
2402 u2 index = Bytes::get_native_u2(pc+1); | |
2403 | |
2404 // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases | |
2405 // out so c++ compiler has a chance for constant prop to fold everything possible away. | |
2406 | |
2407 ConstantPoolCacheEntry* cache = cp->entry_at(index); | |
2408 if (!cache->is_resolved((Bytecodes::Code)opcode)) { | |
2409 CALL_VM(InterpreterRuntime::resolve_invoke(THREAD, (Bytecodes::Code)opcode), | |
2410 handle_exception); | |
2411 cache = cp->entry_at(index); | |
2412 } | |
2413 | |
2414 istate->set_msg(call_method); | |
2415 | |
2416 // Special case of invokeinterface called for virtual method of | |
2417 // java.lang.Object. See cpCacheOop.cpp for details. | |
2418 // This code isn't produced by javac, but could be produced by | |
2419 // another compliant java compiler. | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
2420 if (cache->is_forced_virtual()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2421 Method* callee; |
0 | 2422 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); |
2423 if (cache->is_vfinal()) { | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
2424 callee = cache->f2_as_vfinal_method(); |
0 | 2425 } else { |
2426 // get receiver | |
2427 int parms = cache->parameter_size(); | |
2428 // Same comments as invokevirtual apply here | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
2429 VERIFY_OOP(STACK_OBJECT(-parms)); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2430 InstanceKlass* rcvrKlass = (InstanceKlass*) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2431 STACK_OBJECT(-parms)->klass(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2432 callee = (Method*) rcvrKlass->start_of_vtable()[ cache->f2_as_index()]; |
0 | 2433 } |
2434 istate->set_callee(callee); | |
2435 istate->set_callee_entry_point(callee->from_interpreted_entry()); | |
2436 #ifdef VM_JVMTI | |
2437 if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) { | |
2438 istate->set_callee_entry_point(callee->interpreter_entry()); | |
2439 } | |
2440 #endif /* VM_JVMTI */ | |
2441 istate->set_bcp_advance(5); | |
2442 UPDATE_PC_AND_RETURN(0); // I'll be back... | |
2443 } | |
2444 | |
2445 // this could definitely be cleaned up QQQ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2446 Method* callee; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2447 Klass* iclass = cache->f1_as_klass(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2448 // InstanceKlass* interface = (InstanceKlass*) iclass; |
0 | 2449 // get receiver |
2450 int parms = cache->parameter_size(); | |
2451 oop rcvr = STACK_OBJECT(-parms); | |
2452 CHECK_NULL(rcvr); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2453 InstanceKlass* int2 = (InstanceKlass*) rcvr->klass(); |
0 | 2454 itableOffsetEntry* ki = (itableOffsetEntry*) int2->start_of_itable(); |
2455 int i; | |
2456 for ( i = 0 ; i < int2->itable_length() ; i++, ki++ ) { | |
2457 if (ki->interface_klass() == iclass) break; | |
2458 } | |
2459 // If the interface isn't found, this class doesn't implement this | |
2460 // interface. The link resolver checks this but only for the first | |
2461 // time this interface is called. | |
2462 if (i == int2->itable_length()) { | |
2463 VM_JAVA_ERROR(vmSymbols::java_lang_IncompatibleClassChangeError(), ""); | |
2464 } | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
2465 int mindex = cache->f2_as_index(); |
0 | 2466 itableMethodEntry* im = ki->first_method_entry(rcvr->klass()); |
2467 callee = im[mindex].method(); | |
2468 if (callee == NULL) { | |
2469 VM_JAVA_ERROR(vmSymbols::java_lang_AbstractMethodError(), ""); | |
2470 } | |
2471 | |
2472 istate->set_callee(callee); | |
2473 istate->set_callee_entry_point(callee->from_interpreted_entry()); | |
2474 #ifdef VM_JVMTI | |
2475 if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) { | |
2476 istate->set_callee_entry_point(callee->interpreter_entry()); | |
2477 } | |
2478 #endif /* VM_JVMTI */ | |
2479 istate->set_bcp_advance(5); | |
2480 UPDATE_PC_AND_RETURN(0); // I'll be back... | |
2481 } | |
2482 | |
2483 CASE(_invokevirtual): | |
2484 CASE(_invokespecial): | |
2485 CASE(_invokestatic): { | |
2486 u2 index = Bytes::get_native_u2(pc+1); | |
2487 | |
2488 ConstantPoolCacheEntry* cache = cp->entry_at(index); | |
2489 // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases | |
2490 // out so c++ compiler has a chance for constant prop to fold everything possible away. | |
2491 | |
2492 if (!cache->is_resolved((Bytecodes::Code)opcode)) { | |
2493 CALL_VM(InterpreterRuntime::resolve_invoke(THREAD, (Bytecodes::Code)opcode), | |
2494 handle_exception); | |
2495 cache = cp->entry_at(index); | |
2496 } | |
2497 | |
2498 istate->set_msg(call_method); | |
2499 { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2500 Method* callee; |
0 | 2501 if ((Bytecodes::Code)opcode == Bytecodes::_invokevirtual) { |
2502 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
2503 if (cache->is_vfinal()) callee = cache->f2_as_vfinal_method(); |
0 | 2504 else { |
2505 // get receiver | |
2506 int parms = cache->parameter_size(); | |
2507 // this works but needs a resourcemark and seems to create a vtable on every call: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2508 // Method* callee = rcvr->klass()->vtable()->method_at(cache->f2_as_index()); |
0 | 2509 // |
2510 // this fails with an assert | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2511 // InstanceKlass* rcvrKlass = InstanceKlass::cast(STACK_OBJECT(-parms)->klass()); |
0 | 2512 // but this works |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
2513 VERIFY_OOP(STACK_OBJECT(-parms)); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2514 InstanceKlass* rcvrKlass = (InstanceKlass*) STACK_OBJECT(-parms)->klass(); |
0 | 2515 /* |
2516 Executing this code in java.lang.String: | |
2517 public String(char value[]) { | |
2518 this.count = value.length; | |
2519 this.value = (char[])value.clone(); | |
2520 } | |
2521 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2522 a find on rcvr->klass() reports: |
0 | 2523 {type array char}{type array class} |
2524 - klass: {other class} | |
2525 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2526 but using InstanceKlass::cast(STACK_OBJECT(-parms)->klass()) causes in assertion failure |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2527 because rcvr->klass()->oop_is_instance() == 0 |
0 | 2528 However it seems to have a vtable in the right location. Huh? |
2529 | |
2530 */ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2531 callee = (Method*) rcvrKlass->start_of_vtable()[ cache->f2_as_index()]; |
0 | 2532 } |
2533 } else { | |
2534 if ((Bytecodes::Code)opcode == Bytecodes::_invokespecial) { | |
2535 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); | |
2536 } | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
2537 callee = cache->f1_as_method(); |
0 | 2538 } |
2539 | |
2540 istate->set_callee(callee); | |
2541 istate->set_callee_entry_point(callee->from_interpreted_entry()); | |
2542 #ifdef VM_JVMTI | |
2543 if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) { | |
2544 istate->set_callee_entry_point(callee->interpreter_entry()); | |
2545 } | |
2546 #endif /* VM_JVMTI */ | |
2547 istate->set_bcp_advance(3); | |
2548 UPDATE_PC_AND_RETURN(0); // I'll be back... | |
2549 } | |
2550 } | |
2551 | |
2552 /* Allocate memory for a new java object. */ | |
2553 | |
2554 CASE(_newarray): { | |
2555 BasicType atype = (BasicType) *(pc+1); | |
2556 jint size = STACK_INT(-1); | |
2557 CALL_VM(InterpreterRuntime::newarray(THREAD, atype, size), | |
2558 handle_exception); | |
2559 SET_STACK_OBJECT(THREAD->vm_result(), -1); | |
2560 THREAD->set_vm_result(NULL); | |
2561 | |
2562 UPDATE_PC_AND_CONTINUE(2); | |
2563 } | |
2564 | |
2565 /* Throw an exception. */ | |
2566 | |
2567 CASE(_athrow): { | |
2568 oop except_oop = STACK_OBJECT(-1); | |
2569 CHECK_NULL(except_oop); | |
2570 // set pending_exception so we use common code | |
2571 THREAD->set_pending_exception(except_oop, NULL, 0); | |
2572 goto handle_exception; | |
2573 } | |
2574 | |
2575 /* goto and jsr. They are exactly the same except jsr pushes | |
2576 * the address of the next instruction first. | |
2577 */ | |
2578 | |
2579 CASE(_jsr): { | |
2580 /* push bytecode index on stack */ | |
2581 SET_STACK_ADDR(((address)pc - (intptr_t)(istate->method()->code_base()) + 3), 0); | |
2582 MORE_STACK(1); | |
2583 /* FALL THROUGH */ | |
2584 } | |
2585 | |
2586 CASE(_goto): | |
2587 { | |
2588 int16_t offset = (int16_t)Bytes::get_Java_u2(pc + 1); | |
2589 address branch_pc = pc; | |
2590 UPDATE_PC(offset); | |
2591 DO_BACKEDGE_CHECKS(offset, branch_pc); | |
2592 CONTINUE; | |
2593 } | |
2594 | |
2595 CASE(_jsr_w): { | |
2596 /* push return address on the stack */ | |
2597 SET_STACK_ADDR(((address)pc - (intptr_t)(istate->method()->code_base()) + 5), 0); | |
2598 MORE_STACK(1); | |
2599 /* FALL THROUGH */ | |
2600 } | |
2601 | |
2602 CASE(_goto_w): | |
2603 { | |
2604 int32_t offset = Bytes::get_Java_u4(pc + 1); | |
2605 address branch_pc = pc; | |
2606 UPDATE_PC(offset); | |
2607 DO_BACKEDGE_CHECKS(offset, branch_pc); | |
2608 CONTINUE; | |
2609 } | |
2610 | |
2611 /* return from a jsr or jsr_w */ | |
2612 | |
2613 CASE(_ret): { | |
2614 pc = istate->method()->code_base() + (intptr_t)(LOCALS_ADDR(pc[1])); | |
2615 UPDATE_PC_AND_CONTINUE(0); | |
2616 } | |
2617 | |
2618 /* debugger breakpoint */ | |
2619 | |
2620 CASE(_breakpoint): { | |
2621 Bytecodes::Code original_bytecode; | |
2622 DECACHE_STATE(); | |
2623 SET_LAST_JAVA_FRAME(); | |
2624 original_bytecode = InterpreterRuntime::get_original_bytecode_at(THREAD, | |
2625 METHOD, pc); | |
2626 RESET_LAST_JAVA_FRAME(); | |
2627 CACHE_STATE(); | |
2628 if (THREAD->has_pending_exception()) goto handle_exception; | |
2629 CALL_VM(InterpreterRuntime::_breakpoint(THREAD, METHOD, pc), | |
2630 handle_exception); | |
2631 | |
2632 opcode = (jubyte)original_bytecode; | |
2633 goto opcode_switch; | |
2634 } | |
2635 | |
2636 DEFAULT: | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1347
diff
changeset
|
2637 fatal(err_msg("Unimplemented opcode %d = %s", opcode, |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1347
diff
changeset
|
2638 Bytecodes::name((Bytecodes::Code)opcode))); |
0 | 2639 goto finish; |
2640 | |
2641 } /* switch(opc) */ | |
2642 | |
2643 | |
2644 #ifdef USELABELS | |
2645 check_for_exception: | |
2646 #endif | |
2647 { | |
2648 if (!THREAD->has_pending_exception()) { | |
2649 CONTINUE; | |
2650 } | |
2651 /* We will be gcsafe soon, so flush our state. */ | |
2652 DECACHE_PC(); | |
2653 goto handle_exception; | |
2654 } | |
2655 do_continue: ; | |
2656 | |
2657 } /* while (1) interpreter loop */ | |
2658 | |
2659 | |
2660 // An exception exists in the thread state see whether this activation can handle it | |
2661 handle_exception: { | |
2662 | |
2663 HandleMarkCleaner __hmc(THREAD); | |
2664 Handle except_oop(THREAD, THREAD->pending_exception()); | |
2665 // Prevent any subsequent HandleMarkCleaner in the VM | |
2666 // from freeing the except_oop handle. | |
2667 HandleMark __hm(THREAD); | |
2668 | |
2669 THREAD->clear_pending_exception(); | |
2670 assert(except_oop(), "No exception to process"); | |
2671 intptr_t continuation_bci; | |
2672 // expression stack is emptied | |
1509 | 2673 topOfStack = istate->stack_base() - Interpreter::stackElementWords; |
0 | 2674 CALL_VM(continuation_bci = (intptr_t)InterpreterRuntime::exception_handler_for_exception(THREAD, except_oop()), |
2675 handle_exception); | |
2676 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2677 except_oop = THREAD->vm_result(); |
0 | 2678 THREAD->set_vm_result(NULL); |
2679 if (continuation_bci >= 0) { | |
2680 // Place exception on top of stack | |
2681 SET_STACK_OBJECT(except_oop(), 0); | |
2682 MORE_STACK(1); | |
2683 pc = METHOD->code_base() + continuation_bci; | |
2684 if (TraceExceptions) { | |
2685 ttyLocker ttyl; | |
2686 ResourceMark rm; | |
2687 tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), except_oop()); | |
2688 tty->print_cr(" thrown in interpreter method <%s>", METHOD->print_value_string()); | |
2689 tty->print_cr(" at bci %d, continuing at %d for thread " INTPTR_FORMAT, | |
2690 pc - (intptr_t)METHOD->code_base(), | |
2691 continuation_bci, THREAD); | |
2692 } | |
2693 // for AbortVMOnException flag | |
2694 NOT_PRODUCT(Exceptions::debug_check_abort(except_oop)); | |
2695 goto run; | |
2696 } | |
2697 if (TraceExceptions) { | |
2698 ttyLocker ttyl; | |
2699 ResourceMark rm; | |
2700 tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), except_oop()); | |
2701 tty->print_cr(" thrown in interpreter method <%s>", METHOD->print_value_string()); | |
2702 tty->print_cr(" at bci %d, unwinding for thread " INTPTR_FORMAT, | |
2703 pc - (intptr_t) METHOD->code_base(), | |
2704 THREAD); | |
2705 } | |
2706 // for AbortVMOnException flag | |
2707 NOT_PRODUCT(Exceptions::debug_check_abort(except_oop)); | |
2708 // No handler in this activation, unwind and try again | |
2709 THREAD->set_pending_exception(except_oop(), NULL, 0); | |
2710 goto handle_return; | |
2711 } /* handle_exception: */ | |
2712 | |
2713 | |
2714 | |
2715 // Return from an interpreter invocation with the result of the interpretation | |
2716 // on the top of the Java Stack (or a pending exception) | |
2717 | |
2718 handle_Pop_Frame: | |
2719 | |
2720 // We don't really do anything special here except we must be aware | |
2721 // that we can get here without ever locking the method (if sync). | |
2722 // Also we skip the notification of the exit. | |
2723 | |
2724 istate->set_msg(popping_frame); | |
2725 // Clear pending so while the pop is in process | |
2726 // we don't start another one if a call_vm is done. | |
2727 THREAD->clr_pop_frame_pending(); | |
2728 // Let interpreter (only) see the we're in the process of popping a frame | |
2729 THREAD->set_pop_frame_in_process(); | |
2730 | |
2731 handle_return: | |
2732 { | |
2733 DECACHE_STATE(); | |
2734 | |
2735 bool suppress_error = istate->msg() == popping_frame; | |
2736 bool suppress_exit_event = THREAD->has_pending_exception() || suppress_error; | |
2737 Handle original_exception(THREAD, THREAD->pending_exception()); | |
2738 Handle illegal_state_oop(THREAD, NULL); | |
2739 | |
2740 // We'd like a HandleMark here to prevent any subsequent HandleMarkCleaner | |
2741 // in any following VM entries from freeing our live handles, but illegal_state_oop | |
2742 // isn't really allocated yet and so doesn't become live until later and | |
2743 // in unpredicatable places. Instead we must protect the places where we enter the | |
2744 // VM. It would be much simpler (and safer) if we could allocate a real handle with | |
2745 // a NULL oop in it and then overwrite the oop later as needed. This isn't | |
2746 // unfortunately isn't possible. | |
2747 | |
2748 THREAD->clear_pending_exception(); | |
2749 | |
2750 // | |
2751 // As far as we are concerned we have returned. If we have a pending exception | |
2752 // that will be returned as this invocation's result. However if we get any | |
2753 // exception(s) while checking monitor state one of those IllegalMonitorStateExceptions | |
2754 // will be our final result (i.e. monitor exception trumps a pending exception). | |
2755 // | |
2756 | |
2757 // If we never locked the method (or really passed the point where we would have), | |
2758 // there is no need to unlock it (or look for other monitors), since that | |
2759 // could not have happened. | |
2760 | |
2761 if (THREAD->do_not_unlock()) { | |
2762 | |
2763 // Never locked, reset the flag now because obviously any caller must | |
2764 // have passed their point of locking for us to have gotten here. | |
2765 | |
2766 THREAD->clr_do_not_unlock(); | |
2767 } else { | |
2768 // At this point we consider that we have returned. We now check that the | |
2769 // locks were properly block structured. If we find that they were not | |
2770 // used properly we will return with an illegal monitor exception. | |
2771 // The exception is checked by the caller not the callee since this | |
2772 // checking is considered to be part of the invocation and therefore | |
2773 // in the callers scope (JVM spec 8.13). | |
2774 // | |
2775 // Another weird thing to watch for is if the method was locked | |
2776 // recursively and then not exited properly. This means we must | |
2777 // examine all the entries in reverse time(and stack) order and | |
2778 // unlock as we find them. If we find the method monitor before | |
2779 // we are at the initial entry then we should throw an exception. | |
2780 // It is not clear the template based interpreter does this | |
2781 // correctly | |
2782 | |
2783 BasicObjectLock* base = istate->monitor_base(); | |
2784 BasicObjectLock* end = (BasicObjectLock*) istate->stack_base(); | |
2785 bool method_unlock_needed = METHOD->is_synchronized(); | |
2786 // We know the initial monitor was used for the method don't check that | |
2787 // slot in the loop | |
2788 if (method_unlock_needed) base--; | |
2789 | |
2790 // Check all the monitors to see they are unlocked. Install exception if found to be locked. | |
2791 while (end < base) { | |
2792 oop lockee = end->obj(); | |
2793 if (lockee != NULL) { | |
2794 BasicLock* lock = end->lock(); | |
2795 markOop header = lock->displaced_header(); | |
2796 end->set_obj(NULL); | |
14395
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2797 |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2798 if (!lockee->mark()->has_bias_pattern()) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2799 // If it isn't recursive we either must swap old header or call the runtime |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2800 if (header != NULL) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2801 if (Atomic::cmpxchg_ptr(header, lockee->mark_addr(), lock) != lock) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2802 // restore object for the slow case |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2803 end->set_obj(lockee); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2804 { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2805 // Prevent any HandleMarkCleaner from freeing our live handles |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2806 HandleMark __hm(THREAD); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2807 CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, end)); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2808 } |
0 | 2809 } |
2810 } | |
2811 } | |
2812 // One error is plenty | |
2813 if (illegal_state_oop() == NULL && !suppress_error) { | |
2814 { | |
2815 // Prevent any HandleMarkCleaner from freeing our live handles | |
2816 HandleMark __hm(THREAD); | |
2817 CALL_VM_NOCHECK(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD)); | |
2818 } | |
2819 assert(THREAD->has_pending_exception(), "Lost our exception!"); | |
2820 illegal_state_oop = THREAD->pending_exception(); | |
2821 THREAD->clear_pending_exception(); | |
2822 } | |
2823 } | |
2824 end++; | |
2825 } | |
2826 // Unlock the method if needed | |
2827 if (method_unlock_needed) { | |
2828 if (base->obj() == NULL) { | |
2829 // The method is already unlocked this is not good. | |
2830 if (illegal_state_oop() == NULL && !suppress_error) { | |
2831 { | |
2832 // Prevent any HandleMarkCleaner from freeing our live handles | |
2833 HandleMark __hm(THREAD); | |
2834 CALL_VM_NOCHECK(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD)); | |
2835 } | |
2836 assert(THREAD->has_pending_exception(), "Lost our exception!"); | |
2837 illegal_state_oop = THREAD->pending_exception(); | |
2838 THREAD->clear_pending_exception(); | |
2839 } | |
2840 } else { | |
2841 // | |
2842 // The initial monitor is always used for the method | |
2843 // However if that slot is no longer the oop for the method it was unlocked | |
2844 // and reused by something that wasn't unlocked! | |
2845 // | |
2846 // deopt can come in with rcvr dead because c2 knows | |
2847 // its value is preserved in the monitor. So we can't use locals[0] at all | |
2848 // and must use first monitor slot. | |
2849 // | |
2850 oop rcvr = base->obj(); | |
2851 if (rcvr == NULL) { | |
2852 if (!suppress_error) { | |
2853 VM_JAVA_ERROR_NO_JUMP(vmSymbols::java_lang_NullPointerException(), ""); | |
2854 illegal_state_oop = THREAD->pending_exception(); | |
2855 THREAD->clear_pending_exception(); | |
2856 } | |
14395
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2857 } else if (UseHeavyMonitors) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2858 { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2859 // Prevent any HandleMarkCleaner from freeing our live handles. |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2860 HandleMark __hm(THREAD); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2861 CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, base)); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2862 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2863 if (THREAD->has_pending_exception()) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2864 if (!suppress_error) illegal_state_oop = THREAD->pending_exception(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2865 THREAD->clear_pending_exception(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2866 } |
0 | 2867 } else { |
2868 BasicLock* lock = base->lock(); | |
2869 markOop header = lock->displaced_header(); | |
2870 base->set_obj(NULL); | |
14395
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2871 |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2872 if (!rcvr->mark()->has_bias_pattern()) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2873 base->set_obj(NULL); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2874 // If it isn't recursive we either must swap old header or call the runtime |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2875 if (header != NULL) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2876 if (Atomic::cmpxchg_ptr(header, rcvr->mark_addr(), lock) != lock) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2877 // restore object for the slow case |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2878 base->set_obj(rcvr); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2879 { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2880 // Prevent any HandleMarkCleaner from freeing our live handles |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2881 HandleMark __hm(THREAD); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2882 CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, base)); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2883 } |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2884 if (THREAD->has_pending_exception()) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2885 if (!suppress_error) illegal_state_oop = THREAD->pending_exception(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2886 THREAD->clear_pending_exception(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2887 } |
0 | 2888 } |
2889 } | |
2890 } | |
2891 } | |
2892 } | |
2893 } | |
2894 } | |
14395
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2895 // Clear the do_not_unlock flag now. |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
2896 THREAD->clr_do_not_unlock(); |
0 | 2897 |
2898 // | |
2899 // Notify jvmti/jvmdi | |
2900 // | |
2901 // NOTE: we do not notify a method_exit if we have a pending exception, | |
2902 // including an exception we generate for unlocking checks. In the former | |
2903 // case, JVMDI has already been notified by our call for the exception handler | |
2904 // and in both cases as far as JVMDI is concerned we have already returned. | |
2905 // If we notify it again JVMDI will be all confused about how many frames | |
2906 // are still on the stack (4340444). | |
2907 // | |
2908 // NOTE Further! It turns out the the JVMTI spec in fact expects to see | |
2909 // method_exit events whenever we leave an activation unless it was done | |
2910 // for popframe. This is nothing like jvmdi. However we are passing the | |
2911 // tests at the moment (apparently because they are jvmdi based) so rather | |
2912 // than change this code and possibly fail tests we will leave it alone | |
2913 // (with this note) in anticipation of changing the vm and the tests | |
2914 // simultaneously. | |
2915 | |
2916 | |
2917 // | |
2918 suppress_exit_event = suppress_exit_event || illegal_state_oop() != NULL; | |
2919 | |
2920 | |
2921 | |
2922 #ifdef VM_JVMTI | |
2923 if (_jvmti_interp_events) { | |
2924 // Whenever JVMTI puts a thread in interp_only_mode, method | |
2925 // entry/exit events are sent for that thread to track stack depth. | |
2926 if ( !suppress_exit_event && THREAD->is_interp_only_mode() ) { | |
2927 { | |
2928 // Prevent any HandleMarkCleaner from freeing our live handles | |
2929 HandleMark __hm(THREAD); | |
2930 CALL_VM_NOCHECK(InterpreterRuntime::post_method_exit(THREAD)); | |
2931 } | |
2932 } | |
2933 } | |
2934 #endif /* VM_JVMTI */ | |
2935 | |
2936 // | |
2937 // See if we are returning any exception | |
2938 // A pending exception that was pending prior to a possible popping frame | |
2939 // overrides the popping frame. | |
2940 // | |
2941 assert(!suppress_error || suppress_error && illegal_state_oop() == NULL, "Error was not suppressed"); | |
2942 if (illegal_state_oop() != NULL || original_exception() != NULL) { | |
2943 // inform the frame manager we have no result | |
2944 istate->set_msg(throwing_exception); | |
2945 if (illegal_state_oop() != NULL) | |
2946 THREAD->set_pending_exception(illegal_state_oop(), NULL, 0); | |
2947 else | |
2948 THREAD->set_pending_exception(original_exception(), NULL, 0); | |
2949 istate->set_return_kind((Bytecodes::Code)opcode); | |
2950 UPDATE_PC_AND_RETURN(0); | |
2951 } | |
2952 | |
2953 if (istate->msg() == popping_frame) { | |
2954 // Make it simpler on the assembly code and set the message for the frame pop. | |
2955 // returns | |
2956 if (istate->prev() == NULL) { | |
2957 // We must be returning to a deoptimized frame (because popframe only happens between | |
2958 // two interpreted frames). We need to save the current arguments in C heap so that | |
2959 // the deoptimized frame when it restarts can copy the arguments to its expression | |
2960 // stack and re-execute the call. We also have to notify deoptimization that this | |
605 | 2961 // has occurred and to pick the preserved args copy them to the deoptimized frame's |
0 | 2962 // java expression stack. Yuck. |
2963 // | |
2964 THREAD->popframe_preserve_args(in_ByteSize(METHOD->size_of_parameters() * wordSize), | |
2965 LOCALS_SLOT(METHOD->size_of_parameters() - 1)); | |
2966 THREAD->set_popframe_condition_bit(JavaThread::popframe_force_deopt_reexecution_bit); | |
2967 } | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
2968 THREAD->clr_pop_frame_in_process(); |
0 | 2969 } |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
2970 |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
2971 // Normal return |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
2972 // Advance the pc and return to frame manager |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
2973 istate->set_msg(return_from_method); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
2974 istate->set_return_kind((Bytecodes::Code)opcode); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
2975 UPDATE_PC_AND_RETURN(1); |
0 | 2976 } /* handle_return: */ |
2977 | |
2978 // This is really a fatal error return | |
2979 | |
2980 finish: | |
2981 DECACHE_TOS(); | |
2982 DECACHE_PC(); | |
2983 | |
2984 return; | |
2985 } | |
2986 | |
2987 /* | |
2988 * All the code following this point is only produced once and is not present | |
2989 * in the JVMTI version of the interpreter | |
2990 */ | |
2991 | |
2992 #ifndef VM_JVMTI | |
2993 | |
2994 // This constructor should only be used to contruct the object to signal | |
2995 // interpreter initialization. All other instances should be created by | |
2996 // the frame manager. | |
2997 BytecodeInterpreter::BytecodeInterpreter(messages msg) { | |
2998 if (msg != initialize) ShouldNotReachHere(); | |
2999 _msg = msg; | |
3000 _self_link = this; | |
3001 _prev_link = NULL; | |
3002 } | |
3003 | |
3004 // Inline static functions for Java Stack and Local manipulation | |
3005 | |
3006 // The implementations are platform dependent. We have to worry about alignment | |
3007 // issues on some machines which can change on the same platform depending on | |
3008 // whether it is an LP64 machine also. | |
3009 address BytecodeInterpreter::stack_slot(intptr_t *tos, int offset) { | |
3010 return (address) tos[Interpreter::expr_index_at(-offset)]; | |
3011 } | |
3012 | |
3013 jint BytecodeInterpreter::stack_int(intptr_t *tos, int offset) { | |
3014 return *((jint*) &tos[Interpreter::expr_index_at(-offset)]); | |
3015 } | |
3016 | |
3017 jfloat BytecodeInterpreter::stack_float(intptr_t *tos, int offset) { | |
3018 return *((jfloat *) &tos[Interpreter::expr_index_at(-offset)]); | |
3019 } | |
3020 | |
3021 oop BytecodeInterpreter::stack_object(intptr_t *tos, int offset) { | |
3022 return (oop)tos [Interpreter::expr_index_at(-offset)]; | |
3023 } | |
3024 | |
3025 jdouble BytecodeInterpreter::stack_double(intptr_t *tos, int offset) { | |
3026 return ((VMJavaVal64*) &tos[Interpreter::expr_index_at(-offset)])->d; | |
3027 } | |
3028 | |
3029 jlong BytecodeInterpreter::stack_long(intptr_t *tos, int offset) { | |
3030 return ((VMJavaVal64 *) &tos[Interpreter::expr_index_at(-offset)])->l; | |
3031 } | |
3032 | |
3033 // only used for value types | |
3034 void BytecodeInterpreter::set_stack_slot(intptr_t *tos, address value, | |
3035 int offset) { | |
3036 *((address *)&tos[Interpreter::expr_index_at(-offset)]) = value; | |
3037 } | |
3038 | |
3039 void BytecodeInterpreter::set_stack_int(intptr_t *tos, int value, | |
3040 int offset) { | |
3041 *((jint *)&tos[Interpreter::expr_index_at(-offset)]) = value; | |
3042 } | |
3043 | |
3044 void BytecodeInterpreter::set_stack_float(intptr_t *tos, jfloat value, | |
3045 int offset) { | |
3046 *((jfloat *)&tos[Interpreter::expr_index_at(-offset)]) = value; | |
3047 } | |
3048 | |
3049 void BytecodeInterpreter::set_stack_object(intptr_t *tos, oop value, | |
3050 int offset) { | |
3051 *((oop *)&tos[Interpreter::expr_index_at(-offset)]) = value; | |
3052 } | |
3053 | |
3054 // needs to be platform dep for the 32 bit platforms. | |
3055 void BytecodeInterpreter::set_stack_double(intptr_t *tos, jdouble value, | |
3056 int offset) { | |
3057 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->d = value; | |
3058 } | |
3059 | |
3060 void BytecodeInterpreter::set_stack_double_from_addr(intptr_t *tos, | |
3061 address addr, int offset) { | |
3062 (((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->d = | |
3063 ((VMJavaVal64*)addr)->d); | |
3064 } | |
3065 | |
3066 void BytecodeInterpreter::set_stack_long(intptr_t *tos, jlong value, | |
3067 int offset) { | |
3068 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset+1)])->l = 0xdeedbeeb; | |
3069 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->l = value; | |
3070 } | |
3071 | |
3072 void BytecodeInterpreter::set_stack_long_from_addr(intptr_t *tos, | |
3073 address addr, int offset) { | |
3074 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset+1)])->l = 0xdeedbeeb; | |
3075 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->l = | |
3076 ((VMJavaVal64*)addr)->l; | |
3077 } | |
3078 | |
3079 // Locals | |
3080 | |
3081 address BytecodeInterpreter::locals_slot(intptr_t* locals, int offset) { | |
3082 return (address)locals[Interpreter::local_index_at(-offset)]; | |
3083 } | |
3084 jint BytecodeInterpreter::locals_int(intptr_t* locals, int offset) { | |
3085 return (jint)locals[Interpreter::local_index_at(-offset)]; | |
3086 } | |
3087 jfloat BytecodeInterpreter::locals_float(intptr_t* locals, int offset) { | |
3088 return (jfloat)locals[Interpreter::local_index_at(-offset)]; | |
3089 } | |
3090 oop BytecodeInterpreter::locals_object(intptr_t* locals, int offset) { | |
3091 return (oop)locals[Interpreter::local_index_at(-offset)]; | |
3092 } | |
3093 jdouble BytecodeInterpreter::locals_double(intptr_t* locals, int offset) { | |
3094 return ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d; | |
3095 } | |
3096 jlong BytecodeInterpreter::locals_long(intptr_t* locals, int offset) { | |
3097 return ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l; | |
3098 } | |
3099 | |
3100 // Returns the address of locals value. | |
3101 address BytecodeInterpreter::locals_long_at(intptr_t* locals, int offset) { | |
3102 return ((address)&locals[Interpreter::local_index_at(-(offset+1))]); | |
3103 } | |
3104 address BytecodeInterpreter::locals_double_at(intptr_t* locals, int offset) { | |
3105 return ((address)&locals[Interpreter::local_index_at(-(offset+1))]); | |
3106 } | |
3107 | |
3108 // Used for local value or returnAddress | |
3109 void BytecodeInterpreter::set_locals_slot(intptr_t *locals, | |
3110 address value, int offset) { | |
3111 *((address*)&locals[Interpreter::local_index_at(-offset)]) = value; | |
3112 } | |
3113 void BytecodeInterpreter::set_locals_int(intptr_t *locals, | |
3114 jint value, int offset) { | |
3115 *((jint *)&locals[Interpreter::local_index_at(-offset)]) = value; | |
3116 } | |
3117 void BytecodeInterpreter::set_locals_float(intptr_t *locals, | |
3118 jfloat value, int offset) { | |
3119 *((jfloat *)&locals[Interpreter::local_index_at(-offset)]) = value; | |
3120 } | |
3121 void BytecodeInterpreter::set_locals_object(intptr_t *locals, | |
3122 oop value, int offset) { | |
3123 *((oop *)&locals[Interpreter::local_index_at(-offset)]) = value; | |
3124 } | |
3125 void BytecodeInterpreter::set_locals_double(intptr_t *locals, | |
3126 jdouble value, int offset) { | |
3127 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d = value; | |
3128 } | |
3129 void BytecodeInterpreter::set_locals_long(intptr_t *locals, | |
3130 jlong value, int offset) { | |
3131 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l = value; | |
3132 } | |
3133 void BytecodeInterpreter::set_locals_double_from_addr(intptr_t *locals, | |
3134 address addr, int offset) { | |
3135 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d = ((VMJavaVal64*)addr)->d; | |
3136 } | |
3137 void BytecodeInterpreter::set_locals_long_from_addr(intptr_t *locals, | |
3138 address addr, int offset) { | |
3139 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l = ((VMJavaVal64*)addr)->l; | |
3140 } | |
3141 | |
3142 void BytecodeInterpreter::astore(intptr_t* tos, int stack_offset, | |
3143 intptr_t* locals, int locals_offset) { | |
3144 intptr_t value = tos[Interpreter::expr_index_at(-stack_offset)]; | |
3145 locals[Interpreter::local_index_at(-locals_offset)] = value; | |
3146 } | |
3147 | |
3148 | |
3149 void BytecodeInterpreter::copy_stack_slot(intptr_t *tos, int from_offset, | |
3150 int to_offset) { | |
3151 tos[Interpreter::expr_index_at(-to_offset)] = | |
3152 (intptr_t)tos[Interpreter::expr_index_at(-from_offset)]; | |
3153 } | |
3154 | |
3155 void BytecodeInterpreter::dup(intptr_t *tos) { | |
3156 copy_stack_slot(tos, -1, 0); | |
3157 } | |
3158 void BytecodeInterpreter::dup2(intptr_t *tos) { | |
3159 copy_stack_slot(tos, -2, 0); | |
3160 copy_stack_slot(tos, -1, 1); | |
3161 } | |
3162 | |
3163 void BytecodeInterpreter::dup_x1(intptr_t *tos) { | |
3164 /* insert top word two down */ | |
3165 copy_stack_slot(tos, -1, 0); | |
3166 copy_stack_slot(tos, -2, -1); | |
3167 copy_stack_slot(tos, 0, -2); | |
3168 } | |
3169 | |
3170 void BytecodeInterpreter::dup_x2(intptr_t *tos) { | |
3171 /* insert top word three down */ | |
3172 copy_stack_slot(tos, -1, 0); | |
3173 copy_stack_slot(tos, -2, -1); | |
3174 copy_stack_slot(tos, -3, -2); | |
3175 copy_stack_slot(tos, 0, -3); | |
3176 } | |
3177 void BytecodeInterpreter::dup2_x1(intptr_t *tos) { | |
3178 /* insert top 2 slots three down */ | |
3179 copy_stack_slot(tos, -1, 1); | |
3180 copy_stack_slot(tos, -2, 0); | |
3181 copy_stack_slot(tos, -3, -1); | |
3182 copy_stack_slot(tos, 1, -2); | |
3183 copy_stack_slot(tos, 0, -3); | |
3184 } | |
3185 void BytecodeInterpreter::dup2_x2(intptr_t *tos) { | |
3186 /* insert top 2 slots four down */ | |
3187 copy_stack_slot(tos, -1, 1); | |
3188 copy_stack_slot(tos, -2, 0); | |
3189 copy_stack_slot(tos, -3, -1); | |
3190 copy_stack_slot(tos, -4, -2); | |
3191 copy_stack_slot(tos, 1, -3); | |
3192 copy_stack_slot(tos, 0, -4); | |
3193 } | |
3194 | |
3195 | |
3196 void BytecodeInterpreter::swap(intptr_t *tos) { | |
3197 // swap top two elements | |
3198 intptr_t val = tos[Interpreter::expr_index_at(1)]; | |
3199 // Copy -2 entry to -1 | |
3200 copy_stack_slot(tos, -2, -1); | |
3201 // Store saved -1 entry into -2 | |
3202 tos[Interpreter::expr_index_at(2)] = val; | |
3203 } | |
3204 // -------------------------------------------------------------------------------- | |
3205 // Non-product code | |
3206 #ifndef PRODUCT | |
3207 | |
3208 const char* BytecodeInterpreter::C_msg(BytecodeInterpreter::messages msg) { | |
3209 switch (msg) { | |
3210 case BytecodeInterpreter::no_request: return("no_request"); | |
3211 case BytecodeInterpreter::initialize: return("initialize"); | |
3212 // status message to C++ interpreter | |
3213 case BytecodeInterpreter::method_entry: return("method_entry"); | |
3214 case BytecodeInterpreter::method_resume: return("method_resume"); | |
3215 case BytecodeInterpreter::got_monitors: return("got_monitors"); | |
3216 case BytecodeInterpreter::rethrow_exception: return("rethrow_exception"); | |
3217 // requests to frame manager from C++ interpreter | |
3218 case BytecodeInterpreter::call_method: return("call_method"); | |
3219 case BytecodeInterpreter::return_from_method: return("return_from_method"); | |
3220 case BytecodeInterpreter::more_monitors: return("more_monitors"); | |
3221 case BytecodeInterpreter::throwing_exception: return("throwing_exception"); | |
3222 case BytecodeInterpreter::popping_frame: return("popping_frame"); | |
3223 case BytecodeInterpreter::do_osr: return("do_osr"); | |
3224 // deopt | |
3225 case BytecodeInterpreter::deopt_resume: return("deopt_resume"); | |
3226 case BytecodeInterpreter::deopt_resume2: return("deopt_resume2"); | |
3227 default: return("BAD MSG"); | |
3228 } | |
3229 } | |
3230 void | |
3231 BytecodeInterpreter::print() { | |
3232 tty->print_cr("thread: " INTPTR_FORMAT, (uintptr_t) this->_thread); | |
3233 tty->print_cr("bcp: " INTPTR_FORMAT, (uintptr_t) this->_bcp); | |
3234 tty->print_cr("locals: " INTPTR_FORMAT, (uintptr_t) this->_locals); | |
3235 tty->print_cr("constants: " INTPTR_FORMAT, (uintptr_t) this->_constants); | |
3236 { | |
3237 ResourceMark rm; | |
3238 char *method_name = _method->name_and_sig_as_C_string(); | |
3239 tty->print_cr("method: " INTPTR_FORMAT "[ %s ]", (uintptr_t) this->_method, method_name); | |
3240 } | |
3241 tty->print_cr("mdx: " INTPTR_FORMAT, (uintptr_t) this->_mdx); | |
3242 tty->print_cr("stack: " INTPTR_FORMAT, (uintptr_t) this->_stack); | |
3243 tty->print_cr("msg: %s", C_msg(this->_msg)); | |
3244 tty->print_cr("result_to_call._callee: " INTPTR_FORMAT, (uintptr_t) this->_result._to_call._callee); | |
3245 tty->print_cr("result_to_call._callee_entry_point: " INTPTR_FORMAT, (uintptr_t) this->_result._to_call._callee_entry_point); | |
3246 tty->print_cr("result_to_call._bcp_advance: %d ", this->_result._to_call._bcp_advance); | |
3247 tty->print_cr("osr._osr_buf: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_buf); | |
3248 tty->print_cr("osr._osr_entry: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_entry); | |
3249 tty->print_cr("result_return_kind 0x%x ", (int) this->_result._return_kind); | |
3250 tty->print_cr("prev_link: " INTPTR_FORMAT, (uintptr_t) this->_prev_link); | |
3251 tty->print_cr("native_mirror: " INTPTR_FORMAT, (uintptr_t) this->_oop_temp); | |
3252 tty->print_cr("stack_base: " INTPTR_FORMAT, (uintptr_t) this->_stack_base); | |
3253 tty->print_cr("stack_limit: " INTPTR_FORMAT, (uintptr_t) this->_stack_limit); | |
3254 tty->print_cr("monitor_base: " INTPTR_FORMAT, (uintptr_t) this->_monitor_base); | |
3255 #ifdef SPARC | |
3256 tty->print_cr("last_Java_pc: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_pc); | |
3257 tty->print_cr("frame_bottom: " INTPTR_FORMAT, (uintptr_t) this->_frame_bottom); | |
3258 tty->print_cr("&native_fresult: " INTPTR_FORMAT, (uintptr_t) &this->_native_fresult); | |
3259 tty->print_cr("native_lresult: " INTPTR_FORMAT, (uintptr_t) this->_native_lresult); | |
3260 #endif | |
7994 | 3261 #if !defined(ZERO) |
0 | 3262 tty->print_cr("last_Java_fp: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_fp); |
7994 | 3263 #endif // !ZERO |
0 | 3264 tty->print_cr("self_link: " INTPTR_FORMAT, (uintptr_t) this->_self_link); |
3265 } | |
3266 | |
3267 extern "C" { | |
14395
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
3268 void PI(uintptr_t arg) { |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
3269 ((BytecodeInterpreter*)arg)->print(); |
48d3d0eb193b
8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents:
10393
diff
changeset
|
3270 } |
0 | 3271 } |
3272 #endif // PRODUCT | |
3273 | |
3274 #endif // JVMTI | |
3275 #endif // CC_INTERP |