Mercurial > hg > truffle
annotate src/share/vm/interpreter/interpreterRuntime.cpp @ 2118:dd031b2226de
4930919: race condition in MDO creation at back branch locations
Summary: Reuse set_method_data_for_bcp() to setup mdp after MDO creation.
Reviewed-by: kvn, never
author | iveresov |
---|---|
date | Mon, 10 Jan 2011 18:46:29 -0800 |
parents | 9bc798875b2a |
children | 633a44a9fc45 |
rev | line source |
---|---|
0 | 1 /* |
2118
dd031b2226de
4930919: race condition in MDO creation at back branch locations
iveresov
parents:
1986
diff
changeset
|
2 * Copyright (c) 1997, 2011, 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:
1507
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1507
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:
1507
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/systemDictionary.hpp" | |
27 #include "classfile/vmSymbols.hpp" | |
28 #include "compiler/compileBroker.hpp" | |
29 #include "gc_interface/collectedHeap.hpp" | |
30 #include "interpreter/interpreter.hpp" | |
31 #include "interpreter/interpreterRuntime.hpp" | |
32 #include "interpreter/linkResolver.hpp" | |
33 #include "interpreter/templateTable.hpp" | |
34 #include "memory/oopFactory.hpp" | |
35 #include "memory/universe.inline.hpp" | |
36 #include "oops/constantPoolOop.hpp" | |
37 #include "oops/cpCacheOop.hpp" | |
38 #include "oops/instanceKlass.hpp" | |
39 #include "oops/methodDataOop.hpp" | |
40 #include "oops/objArrayKlass.hpp" | |
41 #include "oops/oop.inline.hpp" | |
42 #include "oops/symbolOop.hpp" | |
43 #include "prims/jvmtiExport.hpp" | |
44 #include "prims/nativeLookup.hpp" | |
45 #include "runtime/biasedLocking.hpp" | |
46 #include "runtime/compilationPolicy.hpp" | |
47 #include "runtime/deoptimization.hpp" | |
48 #include "runtime/fieldDescriptor.hpp" | |
49 #include "runtime/handles.inline.hpp" | |
50 #include "runtime/interfaceSupport.hpp" | |
51 #include "runtime/java.hpp" | |
52 #include "runtime/jfieldIDWorkaround.hpp" | |
53 #include "runtime/osThread.hpp" | |
54 #include "runtime/sharedRuntime.hpp" | |
55 #include "runtime/stubRoutines.hpp" | |
56 #include "runtime/synchronizer.hpp" | |
57 #include "runtime/threadCritical.hpp" | |
58 #include "utilities/events.hpp" | |
59 #ifdef TARGET_ARCH_x86 | |
60 # include "vm_version_x86.hpp" | |
61 #endif | |
62 #ifdef TARGET_ARCH_sparc | |
63 # include "vm_version_sparc.hpp" | |
64 #endif | |
65 #ifdef TARGET_ARCH_zero | |
66 # include "vm_version_zero.hpp" | |
67 #endif | |
68 #ifdef COMPILER2 | |
69 #include "opto/runtime.hpp" | |
70 #endif | |
0 | 71 |
72 class UnlockFlagSaver { | |
73 private: | |
74 JavaThread* _thread; | |
75 bool _do_not_unlock; | |
76 public: | |
77 UnlockFlagSaver(JavaThread* t) { | |
78 _thread = t; | |
79 _do_not_unlock = t->do_not_unlock_if_synchronized(); | |
80 t->set_do_not_unlock_if_synchronized(false); | |
81 } | |
82 ~UnlockFlagSaver() { | |
83 _thread->set_do_not_unlock_if_synchronized(_do_not_unlock); | |
84 } | |
85 }; | |
86 | |
87 //------------------------------------------------------------------------------------------------------------------------ | |
88 // State accessors | |
89 | |
90 void InterpreterRuntime::set_bcp_and_mdp(address bcp, JavaThread *thread) { | |
91 last_frame(thread).interpreter_frame_set_bcp(bcp); | |
92 if (ProfileInterpreter) { | |
93 // ProfileTraps uses MDOs independently of ProfileInterpreter. | |
94 // That is why we must check both ProfileInterpreter and mdo != NULL. | |
95 methodDataOop mdo = last_frame(thread).interpreter_frame_method()->method_data(); | |
96 if (mdo != NULL) { | |
97 NEEDS_CLEANUP; | |
98 last_frame(thread).interpreter_frame_set_mdp(mdo->bci_to_dp(last_frame(thread).interpreter_frame_bci())); | |
99 } | |
100 } | |
101 } | |
102 | |
103 //------------------------------------------------------------------------------------------------------------------------ | |
104 // Constants | |
105 | |
106 | |
107 IRT_ENTRY(void, InterpreterRuntime::ldc(JavaThread* thread, bool wide)) | |
108 // access constant pool | |
109 constantPoolOop pool = method(thread)->constants(); | |
1565 | 110 int index = wide ? get_index_u2(thread, Bytecodes::_ldc_w) : get_index_u1(thread, Bytecodes::_ldc); |
0 | 111 constantTag tag = pool->tag_at(index); |
112 | |
113 if (tag.is_unresolved_klass() || tag.is_klass()) { | |
114 klassOop klass = pool->klass_at(index, CHECK); | |
115 oop java_class = klass->klass_part()->java_mirror(); | |
116 thread->set_vm_result(java_class); | |
117 } else { | |
118 #ifdef ASSERT | |
119 // If we entered this runtime routine, we believed the tag contained | |
120 // an unresolved string, an unresolved class or a resolved class. | |
121 // However, another thread could have resolved the unresolved string | |
122 // or class by the time we go there. | |
123 assert(tag.is_unresolved_string()|| tag.is_string(), "expected string"); | |
124 #endif | |
125 oop s_oop = pool->string_at(index, CHECK); | |
126 thread->set_vm_result(s_oop); | |
127 } | |
128 IRT_END | |
129 | |
1602 | 130 IRT_ENTRY(void, InterpreterRuntime::resolve_ldc(JavaThread* thread, Bytecodes::Code bytecode)) { |
131 assert(bytecode == Bytecodes::_fast_aldc || | |
132 bytecode == Bytecodes::_fast_aldc_w, "wrong bc"); | |
133 ResourceMark rm(thread); | |
134 methodHandle m (thread, method(thread)); | |
135 Bytecode_loadconstant* ldc = Bytecode_loadconstant_at(m, bci(thread)); | |
136 oop result = ldc->resolve_constant(THREAD); | |
137 DEBUG_ONLY(ConstantPoolCacheEntry* cpce = m->constants()->cache()->entry_at(ldc->cache_index())); | |
138 assert(result == cpce->f1(), "expected result for assembly code"); | |
139 } | |
140 IRT_END | |
141 | |
0 | 142 |
143 //------------------------------------------------------------------------------------------------------------------------ | |
144 // Allocation | |
145 | |
146 IRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* thread, constantPoolOopDesc* pool, int index)) | |
147 klassOop k_oop = pool->klass_at(index, CHECK); | |
148 instanceKlassHandle klass (THREAD, k_oop); | |
149 | |
150 // Make sure we are not instantiating an abstract klass | |
151 klass->check_valid_for_instantiation(true, CHECK); | |
152 | |
153 // Make sure klass is initialized | |
154 klass->initialize(CHECK); | |
155 | |
156 // At this point the class may not be fully initialized | |
157 // because of recursive initialization. If it is fully | |
158 // initialized & has_finalized is not set, we rewrite | |
159 // it into its fast version (Note: no locking is needed | |
160 // here since this is an atomic byte write and can be | |
161 // done more than once). | |
162 // | |
163 // Note: In case of classes with has_finalized we don't | |
164 // rewrite since that saves us an extra check in | |
165 // the fast version which then would call the | |
166 // slow version anyway (and do a call back into | |
167 // Java). | |
168 // If we have a breakpoint, then we don't rewrite | |
169 // because the _breakpoint bytecode would be lost. | |
170 oop obj = klass->allocate_instance(CHECK); | |
171 thread->set_vm_result(obj); | |
172 IRT_END | |
173 | |
174 | |
175 IRT_ENTRY(void, InterpreterRuntime::newarray(JavaThread* thread, BasicType type, jint size)) | |
176 oop obj = oopFactory::new_typeArray(type, size, CHECK); | |
177 thread->set_vm_result(obj); | |
178 IRT_END | |
179 | |
180 | |
181 IRT_ENTRY(void, InterpreterRuntime::anewarray(JavaThread* thread, constantPoolOopDesc* pool, int index, jint size)) | |
182 // Note: no oopHandle for pool & klass needed since they are not used | |
183 // anymore after new_objArray() and no GC can happen before. | |
184 // (This may have to change if this code changes!) | |
185 klassOop klass = pool->klass_at(index, CHECK); | |
186 objArrayOop obj = oopFactory::new_objArray(klass, size, CHECK); | |
187 thread->set_vm_result(obj); | |
188 IRT_END | |
189 | |
190 | |
191 IRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* thread, jint* first_size_address)) | |
192 // We may want to pass in more arguments - could make this slightly faster | |
193 constantPoolOop constants = method(thread)->constants(); | |
1565 | 194 int i = get_index_u2(thread, Bytecodes::_multianewarray); |
0 | 195 klassOop klass = constants->klass_at(i, CHECK); |
196 int nof_dims = number_of_dimensions(thread); | |
197 assert(oop(klass)->is_klass(), "not a class"); | |
198 assert(nof_dims >= 1, "multianewarray rank must be nonzero"); | |
199 | |
200 // We must create an array of jints to pass to multi_allocate. | |
201 ResourceMark rm(thread); | |
202 const int small_dims = 10; | |
203 jint dim_array[small_dims]; | |
204 jint *dims = &dim_array[0]; | |
205 if (nof_dims > small_dims) { | |
206 dims = (jint*) NEW_RESOURCE_ARRAY(jint, nof_dims); | |
207 } | |
208 for (int index = 0; index < nof_dims; index++) { | |
209 // offset from first_size_address is addressed as local[index] | |
210 int n = Interpreter::local_offset_in_bytes(index)/jintSize; | |
211 dims[index] = first_size_address[n]; | |
212 } | |
213 oop obj = arrayKlass::cast(klass)->multi_allocate(nof_dims, dims, CHECK); | |
214 thread->set_vm_result(obj); | |
215 IRT_END | |
216 | |
217 | |
218 IRT_ENTRY(void, InterpreterRuntime::register_finalizer(JavaThread* thread, oopDesc* obj)) | |
219 assert(obj->is_oop(), "must be a valid oop"); | |
220 assert(obj->klass()->klass_part()->has_finalizer(), "shouldn't be here otherwise"); | |
221 instanceKlass::register_finalizer(instanceOop(obj), CHECK); | |
222 IRT_END | |
223 | |
224 | |
225 // Quicken instance-of and check-cast bytecodes | |
226 IRT_ENTRY(void, InterpreterRuntime::quicken_io_cc(JavaThread* thread)) | |
227 // Force resolving; quicken the bytecode | |
1565 | 228 int which = get_index_u2(thread, Bytecodes::_checkcast); |
0 | 229 constantPoolOop cpool = method(thread)->constants(); |
230 // We'd expect to assert that we're only here to quicken bytecodes, but in a multithreaded | |
231 // program we might have seen an unquick'd bytecode in the interpreter but have another | |
232 // thread quicken the bytecode before we get here. | |
233 // assert( cpool->tag_at(which).is_unresolved_klass(), "should only come here to quicken bytecodes" ); | |
234 klassOop klass = cpool->klass_at(which, CHECK); | |
235 thread->set_vm_result(klass); | |
236 IRT_END | |
237 | |
238 | |
239 //------------------------------------------------------------------------------------------------------------------------ | |
240 // Exceptions | |
241 | |
242 // Assume the compiler is (or will be) interested in this event. | |
243 // If necessary, create an MDO to hold the information, and record it. | |
244 void InterpreterRuntime::note_trap(JavaThread* thread, int reason, TRAPS) { | |
245 assert(ProfileTraps, "call me only if profiling"); | |
246 methodHandle trap_method(thread, method(thread)); | |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1783
diff
changeset
|
247 |
0 | 248 if (trap_method.not_null()) { |
249 methodDataHandle trap_mdo(thread, trap_method->method_data()); | |
250 if (trap_mdo.is_null()) { | |
251 methodOopDesc::build_interpreter_method_data(trap_method, THREAD); | |
252 if (HAS_PENDING_EXCEPTION) { | |
253 assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here"); | |
254 CLEAR_PENDING_EXCEPTION; | |
255 } | |
256 trap_mdo = methodDataHandle(thread, trap_method->method_data()); | |
257 // and fall through... | |
258 } | |
259 if (trap_mdo.not_null()) { | |
260 // Update per-method count of trap events. The interpreter | |
261 // is updating the MDO to simulate the effect of compiler traps. | |
262 int trap_bci = trap_method->bci_from(bcp(thread)); | |
263 Deoptimization::update_method_data_from_interpreter(trap_mdo, trap_bci, reason); | |
264 } | |
265 } | |
266 } | |
267 | |
268 static Handle get_preinitialized_exception(klassOop k, TRAPS) { | |
269 // get klass | |
270 instanceKlass* klass = instanceKlass::cast(k); | |
271 assert(klass->is_initialized(), | |
272 "this klass should have been initialized during VM initialization"); | |
273 // create instance - do not call constructor since we may have no | |
274 // (java) stack space left (should assert constructor is empty) | |
275 Handle exception; | |
276 oop exception_oop = klass->allocate_instance(CHECK_(exception)); | |
277 exception = Handle(THREAD, exception_oop); | |
278 if (StackTraceInThrowable) { | |
279 java_lang_Throwable::fill_in_stack_trace(exception); | |
280 } | |
281 return exception; | |
282 } | |
283 | |
284 // Special handling for stack overflow: since we don't have any (java) stack | |
285 // space left we use the pre-allocated & pre-initialized StackOverflowError | |
286 // klass to create an stack overflow error instance. We do not call its | |
287 // constructor for the same reason (it is empty, anyway). | |
288 IRT_ENTRY(void, InterpreterRuntime::throw_StackOverflowError(JavaThread* thread)) | |
289 Handle exception = get_preinitialized_exception( | |
290 SystemDictionary::StackOverflowError_klass(), | |
291 CHECK); | |
292 THROW_HANDLE(exception); | |
293 IRT_END | |
294 | |
295 | |
296 IRT_ENTRY(void, InterpreterRuntime::create_exception(JavaThread* thread, char* name, char* message)) | |
297 // lookup exception klass | |
298 symbolHandle s = oopFactory::new_symbol_handle(name, CHECK); | |
299 if (ProfileTraps) { | |
300 if (s == vmSymbols::java_lang_ArithmeticException()) { | |
301 note_trap(thread, Deoptimization::Reason_div0_check, CHECK); | |
302 } else if (s == vmSymbols::java_lang_NullPointerException()) { | |
303 note_trap(thread, Deoptimization::Reason_null_check, CHECK); | |
304 } | |
305 } | |
306 // create exception | |
307 Handle exception = Exceptions::new_exception(thread, s(), message); | |
308 thread->set_vm_result(exception()); | |
309 IRT_END | |
310 | |
311 | |
312 IRT_ENTRY(void, InterpreterRuntime::create_klass_exception(JavaThread* thread, char* name, oopDesc* obj)) | |
313 ResourceMark rm(thread); | |
314 const char* klass_name = Klass::cast(obj->klass())->external_name(); | |
315 // lookup exception klass | |
316 symbolHandle s = oopFactory::new_symbol_handle(name, CHECK); | |
317 if (ProfileTraps) { | |
318 note_trap(thread, Deoptimization::Reason_class_check, CHECK); | |
319 } | |
320 // create exception, with klass name as detail message | |
321 Handle exception = Exceptions::new_exception(thread, s(), klass_name); | |
322 thread->set_vm_result(exception()); | |
323 IRT_END | |
324 | |
325 | |
326 IRT_ENTRY(void, InterpreterRuntime::throw_ArrayIndexOutOfBoundsException(JavaThread* thread, char* name, jint index)) | |
327 char message[jintAsStringSize]; | |
328 // lookup exception klass | |
329 symbolHandle s = oopFactory::new_symbol_handle(name, CHECK); | |
330 if (ProfileTraps) { | |
331 note_trap(thread, Deoptimization::Reason_range_check, CHECK); | |
332 } | |
333 // create exception | |
334 sprintf(message, "%d", index); | |
335 THROW_MSG(s(), message); | |
336 IRT_END | |
337 | |
338 IRT_ENTRY(void, InterpreterRuntime::throw_ClassCastException( | |
339 JavaThread* thread, oopDesc* obj)) | |
340 | |
341 ResourceMark rm(thread); | |
342 char* message = SharedRuntime::generate_class_cast_message( | |
343 thread, Klass::cast(obj->klass())->external_name()); | |
344 | |
345 if (ProfileTraps) { | |
346 note_trap(thread, Deoptimization::Reason_class_check, CHECK); | |
347 } | |
348 | |
349 // create exception | |
350 THROW_MSG(vmSymbols::java_lang_ClassCastException(), message); | |
351 IRT_END | |
352 | |
710 | 353 // required can be either a MethodType, or a Class (for a single argument) |
354 // actual (if not null) can be either a MethodHandle, or an arbitrary value (for a single argument) | |
355 IRT_ENTRY(void, InterpreterRuntime::throw_WrongMethodTypeException(JavaThread* thread, | |
356 oopDesc* required, | |
357 oopDesc* actual)) { | |
358 ResourceMark rm(thread); | |
359 char* message = SharedRuntime::generate_wrong_method_type_message(thread, required, actual); | |
360 | |
361 if (ProfileTraps) { | |
362 note_trap(thread, Deoptimization::Reason_constraint, CHECK); | |
363 } | |
364 | |
365 // create exception | |
366 THROW_MSG(vmSymbols::java_dyn_WrongMethodTypeException(), message); | |
367 } | |
368 IRT_END | |
369 | |
370 | |
0 | 371 |
372 // exception_handler_for_exception(...) returns the continuation address, | |
373 // the exception oop (via TLS) and sets the bci/bcp for the continuation. | |
374 // The exception oop is returned to make sure it is preserved over GC (it | |
375 // is only on the stack if the exception was thrown explicitly via athrow). | |
376 // During this operation, the expression stack contains the values for the | |
377 // bci where the exception happened. If the exception was propagated back | |
378 // from a call, the expression stack contains the values for the bci at the | |
379 // invoke w/o arguments (i.e., as if one were inside the call). | |
380 IRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThread* thread, oopDesc* exception)) | |
381 | |
382 Handle h_exception(thread, exception); | |
383 methodHandle h_method (thread, method(thread)); | |
384 constantPoolHandle h_constants(thread, h_method->constants()); | |
385 typeArrayHandle h_extable (thread, h_method->exception_table()); | |
386 bool should_repeat; | |
387 int handler_bci; | |
1602 | 388 int current_bci = bci(thread); |
0 | 389 |
390 // Need to do this check first since when _do_not_unlock_if_synchronized | |
391 // is set, we don't want to trigger any classloading which may make calls | |
392 // into java, or surprisingly find a matching exception handler for bci 0 | |
393 // since at this moment the method hasn't been "officially" entered yet. | |
394 if (thread->do_not_unlock_if_synchronized()) { | |
395 ResourceMark rm; | |
396 assert(current_bci == 0, "bci isn't zero for do_not_unlock_if_synchronized"); | |
397 thread->set_vm_result(exception); | |
398 #ifdef CC_INTERP | |
399 return (address) -1; | |
400 #else | |
401 return Interpreter::remove_activation_entry(); | |
402 #endif | |
403 } | |
404 | |
405 do { | |
406 should_repeat = false; | |
407 | |
408 // assertions | |
409 #ifdef ASSERT | |
410 assert(h_exception.not_null(), "NULL exceptions should be handled by athrow"); | |
411 assert(h_exception->is_oop(), "just checking"); | |
412 // Check that exception is a subclass of Throwable, otherwise we have a VerifyError | |
1142 | 413 if (!(h_exception->is_a(SystemDictionary::Throwable_klass()))) { |
0 | 414 if (ExitVMOnVerifyError) vm_exit(-1); |
415 ShouldNotReachHere(); | |
416 } | |
417 #endif | |
418 | |
419 // tracing | |
420 if (TraceExceptions) { | |
421 ttyLocker ttyl; | |
422 ResourceMark rm(thread); | |
423 tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", h_exception->print_value_string(), (address)h_exception()); | |
424 tty->print_cr(" thrown in interpreter method <%s>", h_method->print_value_string()); | |
425 tty->print_cr(" at bci %d for thread " INTPTR_FORMAT, current_bci, thread); | |
426 } | |
427 // Don't go paging in something which won't be used. | |
428 // else if (h_extable->length() == 0) { | |
429 // // disabled for now - interpreter is not using shortcut yet | |
430 // // (shortcut is not to call runtime if we have no exception handlers) | |
431 // // warning("performance bug: should not call runtime if method has no exception handlers"); | |
432 // } | |
433 // for AbortVMOnException flag | |
434 NOT_PRODUCT(Exceptions::debug_check_abort(h_exception)); | |
435 | |
436 // exception handler lookup | |
437 KlassHandle h_klass(THREAD, h_exception->klass()); | |
438 handler_bci = h_method->fast_exception_handler_bci_for(h_klass, current_bci, THREAD); | |
439 if (HAS_PENDING_EXCEPTION) { | |
440 // We threw an exception while trying to find the exception handler. | |
441 // Transfer the new exception to the exception handle which will | |
442 // be set into thread local storage, and do another lookup for an | |
443 // exception handler for this exception, this time starting at the | |
444 // BCI of the exception handler which caused the exception to be | |
445 // thrown (bug 4307310). | |
446 h_exception = Handle(THREAD, PENDING_EXCEPTION); | |
447 CLEAR_PENDING_EXCEPTION; | |
448 if (handler_bci >= 0) { | |
449 current_bci = handler_bci; | |
450 should_repeat = true; | |
451 } | |
452 } | |
453 } while (should_repeat == true); | |
454 | |
455 // notify JVMTI of an exception throw; JVMTI will detect if this is a first | |
456 // time throw or a stack unwinding throw and accordingly notify the debugger | |
1213
6deeaebad47a
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
1142
diff
changeset
|
457 if (JvmtiExport::can_post_on_exceptions()) { |
0 | 458 JvmtiExport::post_exception_throw(thread, h_method(), bcp(thread), h_exception()); |
459 } | |
460 | |
461 #ifdef CC_INTERP | |
462 address continuation = (address)(intptr_t) handler_bci; | |
463 #else | |
464 address continuation = NULL; | |
465 #endif | |
466 address handler_pc = NULL; | |
467 if (handler_bci < 0 || !thread->reguard_stack((address) &continuation)) { | |
468 // Forward exception to callee (leaving bci/bcp untouched) because (a) no | |
469 // handler in this method, or (b) after a stack overflow there is not yet | |
470 // enough stack space available to reprotect the stack. | |
471 #ifndef CC_INTERP | |
472 continuation = Interpreter::remove_activation_entry(); | |
473 #endif | |
474 // Count this for compilation purposes | |
475 h_method->interpreter_throwout_increment(); | |
476 } else { | |
477 // handler in this method => change bci/bcp to handler bci/bcp and continue there | |
478 handler_pc = h_method->code_base() + handler_bci; | |
479 #ifndef CC_INTERP | |
480 set_bcp_and_mdp(handler_pc, thread); | |
481 continuation = Interpreter::dispatch_table(vtos)[*handler_pc]; | |
482 #endif | |
483 } | |
484 // notify debugger of an exception catch | |
485 // (this is good for exceptions caught in native methods as well) | |
1213
6deeaebad47a
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
1142
diff
changeset
|
486 if (JvmtiExport::can_post_on_exceptions()) { |
0 | 487 JvmtiExport::notice_unwind_due_to_exception(thread, h_method(), handler_pc, h_exception(), (handler_pc != NULL)); |
488 } | |
489 | |
490 thread->set_vm_result(h_exception()); | |
491 return continuation; | |
492 IRT_END | |
493 | |
494 | |
495 IRT_ENTRY(void, InterpreterRuntime::throw_pending_exception(JavaThread* thread)) | |
496 assert(thread->has_pending_exception(), "must only ne called if there's an exception pending"); | |
497 // nothing to do - eventually we should remove this code entirely (see comments @ call sites) | |
498 IRT_END | |
499 | |
500 | |
501 IRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodError(JavaThread* thread)) | |
502 THROW(vmSymbols::java_lang_AbstractMethodError()); | |
503 IRT_END | |
504 | |
505 | |
506 IRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeError(JavaThread* thread)) | |
507 THROW(vmSymbols::java_lang_IncompatibleClassChangeError()); | |
508 IRT_END | |
509 | |
510 | |
511 //------------------------------------------------------------------------------------------------------------------------ | |
512 // Fields | |
513 // | |
514 | |
515 IRT_ENTRY(void, InterpreterRuntime::resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode)) | |
516 // resolve field | |
517 FieldAccessInfo info; | |
518 constantPoolHandle pool(thread, method(thread)->constants()); | |
519 bool is_static = (bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic); | |
520 | |
521 { | |
522 JvmtiHideSingleStepping jhss(thread); | |
1565 | 523 LinkResolver::resolve_field(info, pool, get_index_u2_cpcache(thread, bytecode), |
0 | 524 bytecode, false, CHECK); |
525 } // end JvmtiHideSingleStepping | |
526 | |
527 // check if link resolution caused cpCache to be updated | |
528 if (already_resolved(thread)) return; | |
529 | |
530 // compute auxiliary field attributes | |
531 TosState state = as_TosState(info.field_type()); | |
532 | |
533 // We need to delay resolving put instructions on final fields | |
534 // until we actually invoke one. This is required so we throw | |
535 // exceptions at the correct place. If we do not resolve completely | |
536 // in the current pass, leaving the put_code set to zero will | |
537 // cause the next put instruction to reresolve. | |
538 bool is_put = (bytecode == Bytecodes::_putfield || | |
539 bytecode == Bytecodes::_putstatic); | |
540 Bytecodes::Code put_code = (Bytecodes::Code)0; | |
541 | |
542 // We also need to delay resolving getstatic instructions until the | |
543 // class is intitialized. This is required so that access to the static | |
544 // field will call the initialization function every time until the class | |
545 // is completely initialized ala. in 2.17.5 in JVM Specification. | |
546 instanceKlass *klass = instanceKlass::cast(info.klass()->as_klassOop()); | |
547 bool uninitialized_static = ((bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic) && | |
548 !klass->is_initialized()); | |
549 Bytecodes::Code get_code = (Bytecodes::Code)0; | |
550 | |
551 | |
552 if (!uninitialized_static) { | |
553 get_code = ((is_static) ? Bytecodes::_getstatic : Bytecodes::_getfield); | |
554 if (is_put || !info.access_flags().is_final()) { | |
555 put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield); | |
556 } | |
557 } | |
558 | |
559 cache_entry(thread)->set_field( | |
560 get_code, | |
561 put_code, | |
562 info.klass(), | |
563 info.field_index(), | |
564 info.field_offset(), | |
565 state, | |
566 info.access_flags().is_final(), | |
567 info.access_flags().is_volatile() | |
568 ); | |
569 IRT_END | |
570 | |
571 | |
572 //------------------------------------------------------------------------------------------------------------------------ | |
573 // Synchronization | |
574 // | |
575 // The interpreter's synchronization code is factored out so that it can | |
576 // be shared by method invocation and synchronized blocks. | |
577 //%note synchronization_3 | |
578 | |
579 static void trace_locking(Handle& h_locking_obj, bool is_locking) { | |
580 ObjectSynchronizer::trace_locking(h_locking_obj, false, true, is_locking); | |
581 } | |
582 | |
583 | |
584 //%note monitor_1 | |
585 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem)) | |
586 #ifdef ASSERT | |
587 thread->last_frame().interpreter_frame_verify_monitor(elem); | |
588 #endif | |
589 if (PrintBiasedLockingStatistics) { | |
590 Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); | |
591 } | |
592 Handle h_obj(thread, elem->obj()); | |
593 assert(Universe::heap()->is_in_reserved_or_null(h_obj()), | |
594 "must be NULL or an object"); | |
595 if (UseBiasedLocking) { | |
596 // Retry fast entry if bias is revoked to avoid unnecessary inflation | |
597 ObjectSynchronizer::fast_enter(h_obj, elem->lock(), true, CHECK); | |
598 } else { | |
599 ObjectSynchronizer::slow_enter(h_obj, elem->lock(), CHECK); | |
600 } | |
601 assert(Universe::heap()->is_in_reserved_or_null(elem->obj()), | |
602 "must be NULL or an object"); | |
603 #ifdef ASSERT | |
604 thread->last_frame().interpreter_frame_verify_monitor(elem); | |
605 #endif | |
606 IRT_END | |
607 | |
608 | |
609 //%note monitor_1 | |
610 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorexit(JavaThread* thread, BasicObjectLock* elem)) | |
611 #ifdef ASSERT | |
612 thread->last_frame().interpreter_frame_verify_monitor(elem); | |
613 #endif | |
614 Handle h_obj(thread, elem->obj()); | |
615 assert(Universe::heap()->is_in_reserved_or_null(h_obj()), | |
616 "must be NULL or an object"); | |
617 if (elem == NULL || h_obj()->is_unlocked()) { | |
618 THROW(vmSymbols::java_lang_IllegalMonitorStateException()); | |
619 } | |
620 ObjectSynchronizer::slow_exit(h_obj(), elem->lock(), thread); | |
621 // Free entry. This must be done here, since a pending exception might be installed on | |
622 // exit. If it is not cleared, the exception handling code will try to unlock the monitor again. | |
623 elem->set_obj(NULL); | |
624 #ifdef ASSERT | |
625 thread->last_frame().interpreter_frame_verify_monitor(elem); | |
626 #endif | |
627 IRT_END | |
628 | |
629 | |
630 IRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* thread)) | |
631 THROW(vmSymbols::java_lang_IllegalMonitorStateException()); | |
632 IRT_END | |
633 | |
634 | |
635 IRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThread* thread)) | |
636 // Returns an illegal exception to install into the current thread. The | |
637 // pending_exception flag is cleared so normal exception handling does not | |
638 // trigger. Any current installed exception will be overwritten. This | |
639 // method will be called during an exception unwind. | |
640 | |
641 assert(!HAS_PENDING_EXCEPTION, "no pending exception"); | |
642 Handle exception(thread, thread->vm_result()); | |
643 assert(exception() != NULL, "vm result should be set"); | |
644 thread->set_vm_result(NULL); // clear vm result before continuing (may cause memory leaks and assert failures) | |
1142 | 645 if (!exception->is_a(SystemDictionary::ThreadDeath_klass())) { |
0 | 646 exception = get_preinitialized_exception( |
647 SystemDictionary::IllegalMonitorStateException_klass(), | |
648 CATCH); | |
649 } | |
650 thread->set_vm_result(exception()); | |
651 IRT_END | |
652 | |
653 | |
654 //------------------------------------------------------------------------------------------------------------------------ | |
655 // Invokes | |
656 | |
657 IRT_ENTRY(Bytecodes::Code, InterpreterRuntime::get_original_bytecode_at(JavaThread* thread, methodOopDesc* method, address bcp)) | |
658 return method->orig_bytecode_at(method->bci_from(bcp)); | |
659 IRT_END | |
660 | |
661 IRT_ENTRY(void, InterpreterRuntime::set_original_bytecode_at(JavaThread* thread, methodOopDesc* method, address bcp, Bytecodes::Code new_code)) | |
662 method->set_orig_bytecode_at(method->bci_from(bcp), new_code); | |
663 IRT_END | |
664 | |
665 IRT_ENTRY(void, InterpreterRuntime::_breakpoint(JavaThread* thread, methodOopDesc* method, address bcp)) | |
666 JvmtiExport::post_raw_breakpoint(thread, method, bcp); | |
667 IRT_END | |
668 | |
669 IRT_ENTRY(void, InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code bytecode)) | |
670 // extract receiver from the outgoing argument list if necessary | |
671 Handle receiver(thread, NULL); | |
672 if (bytecode == Bytecodes::_invokevirtual || bytecode == Bytecodes::_invokeinterface) { | |
673 ResourceMark rm(thread); | |
674 methodHandle m (thread, method(thread)); | |
1602 | 675 Bytecode_invoke* call = Bytecode_invoke_at(m, bci(thread)); |
0 | 676 symbolHandle signature (thread, call->signature()); |
677 receiver = Handle(thread, | |
678 thread->last_frame().interpreter_callee_receiver(signature)); | |
679 assert(Universe::heap()->is_in_reserved_or_null(receiver()), | |
680 "sanity check"); | |
681 assert(receiver.is_null() || | |
682 Universe::heap()->is_in_reserved(receiver->klass()), | |
683 "sanity check"); | |
684 } | |
685 | |
686 // resolve method | |
687 CallInfo info; | |
688 constantPoolHandle pool(thread, method(thread)->constants()); | |
689 | |
690 { | |
691 JvmtiHideSingleStepping jhss(thread); | |
692 LinkResolver::resolve_invoke(info, receiver, pool, | |
1565 | 693 get_index_u2_cpcache(thread, bytecode), bytecode, CHECK); |
0 | 694 if (JvmtiExport::can_hotswap_or_post_breakpoint()) { |
695 int retry_count = 0; | |
696 while (info.resolved_method()->is_old()) { | |
697 // It is very unlikely that method is redefined more than 100 times | |
698 // in the middle of resolve. If it is looping here more than 100 times | |
699 // means then there could be a bug here. | |
700 guarantee((retry_count++ < 100), | |
701 "Could not resolve to latest version of redefined method"); | |
702 // method is redefined in the middle of resolve so re-try. | |
703 LinkResolver::resolve_invoke(info, receiver, pool, | |
1565 | 704 get_index_u2_cpcache(thread, bytecode), bytecode, CHECK); |
0 | 705 } |
706 } | |
707 } // end JvmtiHideSingleStepping | |
708 | |
709 // check if link resolution caused cpCache to be updated | |
710 if (already_resolved(thread)) return; | |
711 | |
712 if (bytecode == Bytecodes::_invokeinterface) { | |
713 | |
714 if (TraceItables && Verbose) { | |
715 ResourceMark rm(thread); | |
716 tty->print_cr("Resolving: klass: %s to method: %s", info.resolved_klass()->name()->as_C_string(), info.resolved_method()->name()->as_C_string()); | |
717 } | |
718 if (info.resolved_method()->method_holder() == | |
1142 | 719 SystemDictionary::Object_klass()) { |
0 | 720 // NOTE: THIS IS A FIX FOR A CORNER CASE in the JVM spec |
721 // (see also cpCacheOop.cpp for details) | |
722 methodHandle rm = info.resolved_method(); | |
723 assert(rm->is_final() || info.has_vtable_index(), | |
724 "should have been set already"); | |
725 cache_entry(thread)->set_method(bytecode, rm, info.vtable_index()); | |
726 } else { | |
727 // Setup itable entry | |
728 int index = klassItable::compute_itable_index(info.resolved_method()()); | |
729 cache_entry(thread)->set_interface_call(info.resolved_method(), index); | |
730 } | |
731 } else { | |
732 cache_entry(thread)->set_method( | |
733 bytecode, | |
734 info.resolved_method(), | |
735 info.vtable_index()); | |
736 } | |
737 IRT_END | |
738 | |
739 | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
941
diff
changeset
|
740 // First time execution: Resolve symbols, create a permanent CallSite object. |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
741 IRT_ENTRY(void, InterpreterRuntime::resolve_invokedynamic(JavaThread* thread)) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
742 ResourceMark rm(thread); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
743 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
744 assert(EnableInvokeDynamic, ""); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
745 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
746 const Bytecodes::Code bytecode = Bytecodes::_invokedynamic; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
747 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
748 methodHandle caller_method(thread, method(thread)); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
749 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
750 constantPoolHandle pool(thread, caller_method->constants()); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
751 pool->set_invokedynamic(); // mark header to flag active call sites |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
752 |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
753 int caller_bci = 0; |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
754 int site_index = 0; |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
755 { address caller_bcp = bcp(thread); |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
756 caller_bci = caller_method->bci_from(caller_bcp); |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
757 site_index = Bytes::get_native_u4(caller_bcp+1); |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
758 } |
1565 | 759 assert(site_index == InterpreterRuntime::bytecode(thread)->get_index_u4(bytecode), ""); |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
760 assert(constantPoolCacheOopDesc::is_secondary_index(site_index), "proper format"); |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
941
diff
changeset
|
761 // there is a second CPC entries that is of interest; it caches signature info: |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
941
diff
changeset
|
762 int main_index = pool->cache()->secondary_entry_at(site_index)->main_entry_index(); |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1903
diff
changeset
|
763 int pool_index = pool->cache()->entry_at(main_index)->constant_pool_index(); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
764 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
765 // first resolve the signature to a MH.invoke methodOop |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
766 if (!pool->cache()->entry_at(main_index)->is_resolved(bytecode)) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
767 JvmtiHideSingleStepping jhss(thread); |
1903 | 768 CallInfo callinfo; |
769 LinkResolver::resolve_invoke(callinfo, Handle(), pool, | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
941
diff
changeset
|
770 site_index, bytecode, CHECK); |
1660
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1603
diff
changeset
|
771 // The main entry corresponds to a JVM_CONSTANT_InvokeDynamic, and serves |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
772 // as a common reference point for all invokedynamic call sites with |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
773 // that exact call descriptor. We will link it in the CP cache exactly |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
774 // as if it were an invokevirtual of MethodHandle.invoke. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
775 pool->cache()->entry_at(main_index)->set_method( |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
776 bytecode, |
1903 | 777 callinfo.resolved_method(), |
778 callinfo.vtable_index()); | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
779 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
780 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
781 // The method (f2 entry) of the main entry is the MH.invoke for the |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
782 // invokedynamic target call signature. |
1660
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1603
diff
changeset
|
783 oop f1_value = pool->cache()->entry_at(main_index)->f1(); |
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1603
diff
changeset
|
784 methodHandle signature_invoker(THREAD, (methodOop) f1_value); |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
785 assert(signature_invoker.not_null() && signature_invoker->is_method() && signature_invoker->is_method_handle_invoke(), |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
786 "correct result from LinkResolver::resolve_invokedynamic"); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
787 |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1903
diff
changeset
|
788 Handle info; // optional argument(s) in JVM_CONSTANT_InvokeDynamic |
1660
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1603
diff
changeset
|
789 Handle bootm = SystemDictionary::find_bootstrap_method(caller_method, caller_bci, |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1903
diff
changeset
|
790 main_index, info, CHECK); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1903
diff
changeset
|
791 if (!java_dyn_MethodHandle::is_instance(bootm())) { |
1660
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1603
diff
changeset
|
792 THROW_MSG(vmSymbols::java_lang_IllegalStateException(), |
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1603
diff
changeset
|
793 "no bootstrap method found for invokedynamic"); |
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1603
diff
changeset
|
794 } |
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1603
diff
changeset
|
795 |
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1603
diff
changeset
|
796 // Short circuit if CallSite has been bound already: |
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1603
diff
changeset
|
797 if (!pool->cache()->secondary_entry_at(site_index)->is_f1_null()) |
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1603
diff
changeset
|
798 return; |
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1603
diff
changeset
|
799 |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
941
diff
changeset
|
800 symbolHandle call_site_name(THREAD, pool->name_ref_at(site_index)); |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
801 |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
802 Handle call_site |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
803 = SystemDictionary::make_dynamic_call_site(bootm, |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
804 // Callee information: |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
805 call_site_name, |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
806 signature_invoker, |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
807 info, |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
808 // Caller information: |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
809 caller_method, |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
810 caller_bci, |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
811 CHECK); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
812 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
813 // In the secondary entry, the f1 field is the call site, and the f2 (index) |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
814 // field is some data about the invoke site. Currently, it is just the BCI. |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
815 // Later, it might be changed to help manage inlining dependencies. |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
816 pool->cache()->secondary_entry_at(site_index)->set_dynamic_call(call_site, signature_invoker); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
817 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
818 IRT_END |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
819 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
820 |
0 | 821 //------------------------------------------------------------------------------------------------------------------------ |
822 // Miscellaneous | |
823 | |
824 | |
941 | 825 nmethod* InterpreterRuntime::frequency_counter_overflow(JavaThread* thread, address branch_bcp) { |
826 nmethod* nm = frequency_counter_overflow_inner(thread, branch_bcp); | |
827 assert(branch_bcp != NULL || nm == NULL, "always returns null for non OSR requests"); | |
828 if (branch_bcp != NULL && nm != NULL) { | |
829 // This was a successful request for an OSR nmethod. Because | |
830 // frequency_counter_overflow_inner ends with a safepoint check, | |
831 // nm could have been unloaded so look it up again. It's unsafe | |
832 // to examine nm directly since it might have been freed and used | |
833 // for something else. | |
834 frame fr = thread->last_frame(); | |
835 methodOop method = fr.interpreter_frame_method(); | |
836 int bci = method->bci_from(fr.interpreter_frame_bcp()); | |
1783 | 837 nm = method->lookup_osr_nmethod_for(bci, CompLevel_none, false); |
941 | 838 } |
839 return nm; | |
840 } | |
841 | |
0 | 842 IRT_ENTRY(nmethod*, |
941 | 843 InterpreterRuntime::frequency_counter_overflow_inner(JavaThread* thread, address branch_bcp)) |
0 | 844 // use UnlockFlagSaver to clear and restore the _do_not_unlock_if_synchronized |
845 // flag, in case this method triggers classloading which will call into Java. | |
846 UnlockFlagSaver fs(thread); | |
847 | |
848 frame fr = thread->last_frame(); | |
849 assert(fr.is_interpreted_frame(), "must come from interpreter"); | |
850 methodHandle method(thread, fr.interpreter_frame_method()); | |
1783 | 851 const int branch_bci = branch_bcp != NULL ? method->bci_from(branch_bcp) : InvocationEntryBci; |
852 const int bci = branch_bcp != NULL ? method->bci_from(fr.interpreter_frame_bcp()) : InvocationEntryBci; | |
853 | |
854 nmethod* osr_nm = CompilationPolicy::policy()->event(method, method, branch_bci, bci, CompLevel_none, thread); | |
0 | 855 |
1783 | 856 if (osr_nm != NULL) { |
857 // We may need to do on-stack replacement which requires that no | |
858 // monitors in the activation are biased because their | |
859 // BasicObjectLocks will need to migrate during OSR. Force | |
860 // unbiasing of all monitors in the activation now (even though | |
861 // the OSR nmethod might be invalidated) because we don't have a | |
862 // safepoint opportunity later once the migration begins. | |
863 if (UseBiasedLocking) { | |
864 ResourceMark rm; | |
865 GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>(); | |
866 for( BasicObjectLock *kptr = fr.interpreter_frame_monitor_end(); | |
867 kptr < fr.interpreter_frame_monitor_begin(); | |
868 kptr = fr.next_monitor_in_interpreter_frame(kptr) ) { | |
869 if( kptr->obj() != NULL ) { | |
870 objects_to_revoke->append(Handle(THREAD, kptr->obj())); | |
871 } | |
0 | 872 } |
1783 | 873 BiasedLocking::revoke(objects_to_revoke); |
0 | 874 } |
875 } | |
1783 | 876 return osr_nm; |
0 | 877 IRT_END |
878 | |
879 IRT_LEAF(jint, InterpreterRuntime::bcp_to_di(methodOopDesc* method, address cur_bcp)) | |
880 assert(ProfileInterpreter, "must be profiling interpreter"); | |
881 int bci = method->bci_from(cur_bcp); | |
882 methodDataOop mdo = method->method_data(); | |
883 if (mdo == NULL) return 0; | |
884 return mdo->bci_to_di(bci); | |
885 IRT_END | |
886 | |
2118
dd031b2226de
4930919: race condition in MDO creation at back branch locations
iveresov
parents:
1986
diff
changeset
|
887 IRT_ENTRY(void, InterpreterRuntime::profile_method(JavaThread* thread)) |
0 | 888 // use UnlockFlagSaver to clear and restore the _do_not_unlock_if_synchronized |
889 // flag, in case this method triggers classloading which will call into Java. | |
890 UnlockFlagSaver fs(thread); | |
891 | |
892 assert(ProfileInterpreter, "must be profiling interpreter"); | |
893 frame fr = thread->last_frame(); | |
894 assert(fr.is_interpreted_frame(), "must come from interpreter"); | |
895 methodHandle method(thread, fr.interpreter_frame_method()); | |
896 methodOopDesc::build_interpreter_method_data(method, THREAD); | |
897 if (HAS_PENDING_EXCEPTION) { | |
898 assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here"); | |
899 CLEAR_PENDING_EXCEPTION; | |
900 // and fall through... | |
901 } | |
902 IRT_END | |
903 | |
904 | |
905 #ifdef ASSERT | |
906 IRT_LEAF(void, InterpreterRuntime::verify_mdp(methodOopDesc* method, address bcp, address mdp)) | |
907 assert(ProfileInterpreter, "must be profiling interpreter"); | |
908 | |
909 methodDataOop mdo = method->method_data(); | |
910 assert(mdo != NULL, "must not be null"); | |
911 | |
912 int bci = method->bci_from(bcp); | |
913 | |
914 address mdp2 = mdo->bci_to_dp(bci); | |
915 if (mdp != mdp2) { | |
916 ResourceMark rm; | |
917 ResetNoHandleMark rnm; // In a LEAF entry. | |
918 HandleMark hm; | |
919 tty->print_cr("FAILED verify : actual mdp %p expected mdp %p @ bci %d", mdp, mdp2, bci); | |
920 int current_di = mdo->dp_to_di(mdp); | |
921 int expected_di = mdo->dp_to_di(mdp2); | |
922 tty->print_cr(" actual di %d expected di %d", current_di, expected_di); | |
923 int expected_approx_bci = mdo->data_at(expected_di)->bci(); | |
924 int approx_bci = -1; | |
925 if (current_di >= 0) { | |
926 approx_bci = mdo->data_at(current_di)->bci(); | |
927 } | |
928 tty->print_cr(" actual bci is %d expected bci %d", approx_bci, expected_approx_bci); | |
929 mdo->print_on(tty); | |
930 method->print_codes(); | |
931 } | |
932 assert(mdp == mdp2, "wrong mdp"); | |
933 IRT_END | |
934 #endif // ASSERT | |
935 | |
936 IRT_ENTRY(void, InterpreterRuntime::update_mdp_for_ret(JavaThread* thread, int return_bci)) | |
937 assert(ProfileInterpreter, "must be profiling interpreter"); | |
938 ResourceMark rm(thread); | |
939 HandleMark hm(thread); | |
940 frame fr = thread->last_frame(); | |
941 assert(fr.is_interpreted_frame(), "must come from interpreter"); | |
942 methodDataHandle h_mdo(thread, fr.interpreter_frame_method()->method_data()); | |
943 | |
944 // Grab a lock to ensure atomic access to setting the return bci and | |
945 // the displacement. This can block and GC, invalidating all naked oops. | |
946 MutexLocker ml(RetData_lock); | |
947 | |
948 // ProfileData is essentially a wrapper around a derived oop, so we | |
949 // need to take the lock before making any ProfileData structures. | |
950 ProfileData* data = h_mdo->data_at(h_mdo->dp_to_di(fr.interpreter_frame_mdp())); | |
951 RetData* rdata = data->as_RetData(); | |
952 address new_mdp = rdata->fixup_ret(return_bci, h_mdo); | |
953 fr.interpreter_frame_set_mdp(new_mdp); | |
954 IRT_END | |
955 | |
956 | |
957 IRT_ENTRY(void, InterpreterRuntime::at_safepoint(JavaThread* thread)) | |
958 // We used to need an explict preserve_arguments here for invoke bytecodes. However, | |
959 // stack traversal automatically takes care of preserving arguments for invoke, so | |
960 // this is no longer needed. | |
961 | |
962 // IRT_END does an implicit safepoint check, hence we are guaranteed to block | |
963 // if this is called during a safepoint | |
964 | |
965 if (JvmtiExport::should_post_single_step()) { | |
966 // We are called during regular safepoints and when the VM is | |
967 // single stepping. If any thread is marked for single stepping, | |
968 // then we may have JVMTI work to do. | |
969 JvmtiExport::at_single_stepping_point(thread, method(thread), bcp(thread)); | |
970 } | |
971 IRT_END | |
972 | |
973 IRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread *thread, oopDesc* obj, | |
974 ConstantPoolCacheEntry *cp_entry)) | |
975 | |
976 // check the access_flags for the field in the klass | |
977 instanceKlass* ik = instanceKlass::cast((klassOop)cp_entry->f1()); | |
978 typeArrayOop fields = ik->fields(); | |
979 int index = cp_entry->field_index(); | |
980 assert(index < fields->length(), "holders field index is out of range"); | |
981 // bail out if field accesses are not watched | |
982 if ((fields->ushort_at(index) & JVM_ACC_FIELD_ACCESS_WATCHED) == 0) return; | |
983 | |
984 switch(cp_entry->flag_state()) { | |
985 case btos: // fall through | |
986 case ctos: // fall through | |
987 case stos: // fall through | |
988 case itos: // fall through | |
989 case ftos: // fall through | |
990 case ltos: // fall through | |
991 case dtos: // fall through | |
992 case atos: break; | |
993 default: ShouldNotReachHere(); return; | |
994 } | |
995 bool is_static = (obj == NULL); | |
996 HandleMark hm(thread); | |
997 | |
998 Handle h_obj; | |
999 if (!is_static) { | |
1000 // non-static field accessors have an object, but we need a handle | |
1001 h_obj = Handle(thread, obj); | |
1002 } | |
1003 instanceKlassHandle h_cp_entry_f1(thread, (klassOop)cp_entry->f1()); | |
1004 jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_cp_entry_f1, cp_entry->f2(), is_static); | |
1005 JvmtiExport::post_field_access(thread, method(thread), bcp(thread), h_cp_entry_f1, h_obj, fid); | |
1006 IRT_END | |
1007 | |
1008 IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread, | |
1009 oopDesc* obj, ConstantPoolCacheEntry *cp_entry, jvalue *value)) | |
1010 | |
1011 klassOop k = (klassOop)cp_entry->f1(); | |
1012 | |
1013 // check the access_flags for the field in the klass | |
1014 instanceKlass* ik = instanceKlass::cast(k); | |
1015 typeArrayOop fields = ik->fields(); | |
1016 int index = cp_entry->field_index(); | |
1017 assert(index < fields->length(), "holders field index is out of range"); | |
1018 // bail out if field modifications are not watched | |
1019 if ((fields->ushort_at(index) & JVM_ACC_FIELD_MODIFICATION_WATCHED) == 0) return; | |
1020 | |
1021 char sig_type = '\0'; | |
1022 | |
1023 switch(cp_entry->flag_state()) { | |
1024 case btos: sig_type = 'Z'; break; | |
1025 case ctos: sig_type = 'C'; break; | |
1026 case stos: sig_type = 'S'; break; | |
1027 case itos: sig_type = 'I'; break; | |
1028 case ftos: sig_type = 'F'; break; | |
1029 case atos: sig_type = 'L'; break; | |
1030 case ltos: sig_type = 'J'; break; | |
1031 case dtos: sig_type = 'D'; break; | |
1032 default: ShouldNotReachHere(); return; | |
1033 } | |
1034 bool is_static = (obj == NULL); | |
1035 | |
1036 HandleMark hm(thread); | |
1037 instanceKlassHandle h_klass(thread, k); | |
1038 jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_klass, cp_entry->f2(), is_static); | |
1039 jvalue fvalue; | |
1040 #ifdef _LP64 | |
1041 fvalue = *value; | |
1042 #else | |
1043 // Long/double values are stored unaligned and also noncontiguously with | |
1044 // tagged stacks. We can't just do a simple assignment even in the non- | |
1045 // J/D cases because a C++ compiler is allowed to assume that a jvalue is | |
1046 // 8-byte aligned, and interpreter stack slots are only 4-byte aligned. | |
1047 // We assume that the two halves of longs/doubles are stored in interpreter | |
1048 // stack slots in platform-endian order. | |
1049 jlong_accessor u; | |
1050 jint* newval = (jint*)value; | |
1051 u.words[0] = newval[0]; | |
1506 | 1052 u.words[1] = newval[Interpreter::stackElementWords]; // skip if tag |
0 | 1053 fvalue.j = u.long_value; |
1054 #endif // _LP64 | |
1055 | |
1056 Handle h_obj; | |
1057 if (!is_static) { | |
1058 // non-static field accessors have an object, but we need a handle | |
1059 h_obj = Handle(thread, obj); | |
1060 } | |
1061 | |
1062 JvmtiExport::post_raw_field_modification(thread, method(thread), bcp(thread), h_klass, h_obj, | |
1063 fid, sig_type, &fvalue); | |
1064 IRT_END | |
1065 | |
1066 IRT_ENTRY(void, InterpreterRuntime::post_method_entry(JavaThread *thread)) | |
1067 JvmtiExport::post_method_entry(thread, InterpreterRuntime::method(thread), InterpreterRuntime::last_frame(thread)); | |
1068 IRT_END | |
1069 | |
1070 | |
1071 IRT_ENTRY(void, InterpreterRuntime::post_method_exit(JavaThread *thread)) | |
1072 JvmtiExport::post_method_exit(thread, InterpreterRuntime::method(thread), InterpreterRuntime::last_frame(thread)); | |
1073 IRT_END | |
1074 | |
1075 IRT_LEAF(int, InterpreterRuntime::interpreter_contains(address pc)) | |
1076 { | |
1077 return (Interpreter::contains(pc) ? 1 : 0); | |
1078 } | |
1079 IRT_END | |
1080 | |
1081 | |
1082 // Implementation of SignatureHandlerLibrary | |
1083 | |
1084 address SignatureHandlerLibrary::set_handler_blob() { | |
1085 BufferBlob* handler_blob = BufferBlob::create("native signature handlers", blob_size); | |
1086 if (handler_blob == NULL) { | |
1087 return NULL; | |
1088 } | |
1748 | 1089 address handler = handler_blob->code_begin(); |
0 | 1090 _handler_blob = handler_blob; |
1091 _handler = handler; | |
1092 return handler; | |
1093 } | |
1094 | |
1095 void SignatureHandlerLibrary::initialize() { | |
1096 if (_fingerprints != NULL) { | |
1097 return; | |
1098 } | |
1099 if (set_handler_blob() == NULL) { | |
1100 vm_exit_out_of_memory(blob_size, "native signature handlers"); | |
1101 } | |
1102 | |
1103 BufferBlob* bb = BufferBlob::create("Signature Handler Temp Buffer", | |
1104 SignatureHandlerLibrary::buffer_size); | |
1748 | 1105 _buffer = bb->code_begin(); |
0 | 1106 |
1107 _fingerprints = new(ResourceObj::C_HEAP)GrowableArray<uint64_t>(32, true); | |
1108 _handlers = new(ResourceObj::C_HEAP)GrowableArray<address>(32, true); | |
1109 } | |
1110 | |
1111 address SignatureHandlerLibrary::set_handler(CodeBuffer* buffer) { | |
1112 address handler = _handler; | |
1748 | 1113 int insts_size = buffer->pure_insts_size(); |
1114 if (handler + insts_size > _handler_blob->code_end()) { | |
0 | 1115 // get a new handler blob |
1116 handler = set_handler_blob(); | |
1117 } | |
1118 if (handler != NULL) { | |
1748 | 1119 memcpy(handler, buffer->insts_begin(), insts_size); |
0 | 1120 pd_set_handler(handler); |
1748 | 1121 ICache::invalidate_range(handler, insts_size); |
1122 _handler = handler + insts_size; | |
0 | 1123 } |
1124 return handler; | |
1125 } | |
1126 | |
1127 void SignatureHandlerLibrary::add(methodHandle method) { | |
1128 if (method->signature_handler() == NULL) { | |
1129 // use slow signature handler if we can't do better | |
1130 int handler_index = -1; | |
1131 // check if we can use customized (fast) signature handler | |
1132 if (UseFastSignatureHandlers && method->size_of_parameters() <= Fingerprinter::max_size_of_parameters) { | |
1133 // use customized signature handler | |
1134 MutexLocker mu(SignatureHandlerLibrary_lock); | |
1135 // make sure data structure is initialized | |
1136 initialize(); | |
1137 // lookup method signature's fingerprint | |
1138 uint64_t fingerprint = Fingerprinter(method).fingerprint(); | |
1139 handler_index = _fingerprints->find(fingerprint); | |
1140 // create handler if necessary | |
1141 if (handler_index < 0) { | |
1142 ResourceMark rm; | |
1143 ptrdiff_t align_offset = (address) | |
1144 round_to((intptr_t)_buffer, CodeEntryAlignment) - (address)_buffer; | |
1145 CodeBuffer buffer((address)(_buffer + align_offset), | |
1146 SignatureHandlerLibrary::buffer_size - align_offset); | |
1147 InterpreterRuntime::SignatureHandlerGenerator(method, &buffer).generate(fingerprint); | |
1148 // copy into code heap | |
1149 address handler = set_handler(&buffer); | |
1150 if (handler == NULL) { | |
1151 // use slow signature handler | |
1152 } else { | |
1153 // debugging suppport | |
1154 if (PrintSignatureHandlers) { | |
1155 tty->cr(); | |
1156 tty->print_cr("argument handler #%d for: %s %s (fingerprint = " UINT64_FORMAT ", %d bytes generated)", | |
1157 _handlers->length(), | |
1158 (method->is_static() ? "static" : "receiver"), | |
1159 method->name_and_sig_as_C_string(), | |
1160 fingerprint, | |
1748 | 1161 buffer.insts_size()); |
1162 Disassembler::decode(handler, handler + buffer.insts_size()); | |
0 | 1163 #ifndef PRODUCT |
1164 tty->print_cr(" --- associated result handler ---"); | |
1165 address rh_begin = Interpreter::result_handler(method()->result_type()); | |
1166 address rh_end = rh_begin; | |
1167 while (*(int*)rh_end != 0) { | |
1168 rh_end += sizeof(int); | |
1169 } | |
1170 Disassembler::decode(rh_begin, rh_end); | |
1171 #endif | |
1172 } | |
1173 // add handler to library | |
1174 _fingerprints->append(fingerprint); | |
1175 _handlers->append(handler); | |
1176 // set handler index | |
1177 assert(_fingerprints->length() == _handlers->length(), "sanity check"); | |
1178 handler_index = _fingerprints->length() - 1; | |
1179 } | |
1180 } | |
1181 } else { | |
1182 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); | |
1183 } | |
1184 if (handler_index < 0) { | |
1185 // use generic signature handler | |
1186 method->set_signature_handler(Interpreter::slow_signature_handler()); | |
1187 } else { | |
1188 // set handler | |
1189 method->set_signature_handler(_handlers->at(handler_index)); | |
1190 } | |
1191 } | |
1986
9bc798875b2a
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
1972
diff
changeset
|
1192 #ifdef ASSERT |
9bc798875b2a
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
1972
diff
changeset
|
1193 int handler_index, fingerprint_index; |
9bc798875b2a
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
1972
diff
changeset
|
1194 { |
9bc798875b2a
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
1972
diff
changeset
|
1195 // '_handlers' and '_fingerprints' are 'GrowableArray's and are NOT synchronized |
9bc798875b2a
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
1972
diff
changeset
|
1196 // in any way if accessed from multiple threads. To avoid races with another |
9bc798875b2a
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
1972
diff
changeset
|
1197 // thread which may change the arrays in the above, mutex protected block, we |
9bc798875b2a
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
1972
diff
changeset
|
1198 // have to protect this read access here with the same mutex as well! |
9bc798875b2a
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
1972
diff
changeset
|
1199 MutexLocker mu(SignatureHandlerLibrary_lock); |
9bc798875b2a
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
1972
diff
changeset
|
1200 handler_index = _handlers->find(method->signature_handler()); |
9bc798875b2a
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
1972
diff
changeset
|
1201 fingerprint_index = _fingerprints->find(Fingerprinter(method).fingerprint()); |
9bc798875b2a
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
1972
diff
changeset
|
1202 } |
0 | 1203 assert(method->signature_handler() == Interpreter::slow_signature_handler() || |
1986
9bc798875b2a
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
1972
diff
changeset
|
1204 handler_index == fingerprint_index, "sanity check"); |
9bc798875b2a
6704010: Internal Error (src/share/vm/interpreter/interpreterRuntime.cpp:1106)
coleenp
parents:
1972
diff
changeset
|
1205 #endif |
0 | 1206 } |
1207 | |
1208 | |
1209 BufferBlob* SignatureHandlerLibrary::_handler_blob = NULL; | |
1210 address SignatureHandlerLibrary::_handler = NULL; | |
1211 GrowableArray<uint64_t>* SignatureHandlerLibrary::_fingerprints = NULL; | |
1212 GrowableArray<address>* SignatureHandlerLibrary::_handlers = NULL; | |
1213 address SignatureHandlerLibrary::_buffer = NULL; | |
1214 | |
1215 | |
1216 IRT_ENTRY(void, InterpreterRuntime::prepare_native_call(JavaThread* thread, methodOopDesc* method)) | |
1217 methodHandle m(thread, method); | |
1218 assert(m->is_native(), "sanity check"); | |
1219 // lookup native function entry point if it doesn't exist | |
1220 bool in_base_library; | |
1221 if (!m->has_native_function()) { | |
1222 NativeLookup::lookup(m, in_base_library, CHECK); | |
1223 } | |
1224 // make sure signature handler is installed | |
1225 SignatureHandlerLibrary::add(m); | |
1226 // The interpreter entry point checks the signature handler first, | |
1227 // before trying to fetch the native entry point and klass mirror. | |
1228 // We must set the signature handler last, so that multiple processors | |
1229 // preparing the same method will be sure to see non-null entry & mirror. | |
1230 IRT_END | |
1231 | |
1232 #if defined(IA32) || defined(AMD64) | |
1233 IRT_LEAF(void, InterpreterRuntime::popframe_move_outgoing_args(JavaThread* thread, void* src_address, void* dest_address)) | |
1234 if (src_address == dest_address) { | |
1235 return; | |
1236 } | |
1237 ResetNoHandleMark rnm; // In a LEAF entry. | |
1238 HandleMark hm; | |
1239 ResourceMark rm; | |
1240 frame fr = thread->last_frame(); | |
1241 assert(fr.is_interpreted_frame(), ""); | |
1242 jint bci = fr.interpreter_frame_bci(); | |
1243 methodHandle mh(thread, fr.interpreter_frame_method()); | |
1244 Bytecode_invoke* invoke = Bytecode_invoke_at(mh, bci); | |
1245 ArgumentSizeComputer asc(invoke->signature()); | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1059
diff
changeset
|
1246 int size_of_arguments = (asc.size() + (invoke->has_receiver() ? 1 : 0)); // receiver |
1603
d93949c5bdcc
6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents:
1602
diff
changeset
|
1247 Copy::conjoint_jbytes(src_address, dest_address, |
1506 | 1248 size_of_arguments * Interpreter::stackElementSize); |
0 | 1249 IRT_END |
1250 #endif |