src/share/vm/interpreter/interpreterRuntime.cpp

Mon, 07 Jul 2014 10:12:40 +0200

author
stefank
date
Mon, 07 Jul 2014 10:12:40 +0200
changeset 6992
2c6ef90f030a
parent 6680
78bbf4d43a14
child 6876
710a3c8b516e
child 7181
134f18d0174b
permissions
-rw-r--r--

8049421: G1 Class Unloading after completing a concurrent mark cycle
Reviewed-by: tschatzl, ehelin, brutisso, coleenp, roland, iveresov
Contributed-by: stefan.karlsson@oracle.com, mikael.gerdin@oracle.com

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

mercurial