src/hotspot/share/runtime/sharedRuntime.cpp
changeset 59056 15936b142f86
parent 58957 00244fd3169a
child 59165 2c55c2fc08f5
equal deleted inserted replaced
59055:57ad70bcf06c 59056:15936b142f86
  1020   vframeStream vfst(thread, true);  // Do not skip and javaCalls
  1020   vframeStream vfst(thread, true);  // Do not skip and javaCalls
  1021 
  1021 
  1022   return find_callee_info_helper(thread, vfst, bc, callinfo, THREAD);
  1022   return find_callee_info_helper(thread, vfst, bc, callinfo, THREAD);
  1023 }
  1023 }
  1024 
  1024 
  1025 methodHandle SharedRuntime::extract_attached_method(vframeStream& vfst) {
  1025 Method* SharedRuntime::extract_attached_method(vframeStream& vfst) {
  1026   CompiledMethod* caller = vfst.nm();
  1026   CompiledMethod* caller = vfst.nm();
  1027 
  1027 
  1028   nmethodLocker caller_lock(caller);
  1028   nmethodLocker caller_lock(caller);
  1029 
  1029 
  1030   address pc = vfst.frame_pc();
  1030   address pc = vfst.frame_pc();
  1053 
  1053 
  1054   Bytecode_invoke bytecode(caller, bci);
  1054   Bytecode_invoke bytecode(caller, bci);
  1055   int bytecode_index = bytecode.index();
  1055   int bytecode_index = bytecode.index();
  1056   bc = bytecode.invoke_code();
  1056   bc = bytecode.invoke_code();
  1057 
  1057 
  1058   methodHandle attached_method = extract_attached_method(vfst);
  1058   methodHandle attached_method(THREAD, extract_attached_method(vfst));
  1059   if (attached_method.not_null()) {
  1059   if (attached_method.not_null()) {
  1060     methodHandle callee = bytecode.static_target(CHECK_NH);
  1060     Method* callee = bytecode.static_target(CHECK_NH);
  1061     vmIntrinsics::ID id = callee->intrinsic_id();
  1061     vmIntrinsics::ID id = callee->intrinsic_id();
  1062     // When VM replaces MH.invokeBasic/linkTo* call with a direct/virtual call,
  1062     // When VM replaces MH.invokeBasic/linkTo* call with a direct/virtual call,
  1063     // it attaches statically resolved method to the call site.
  1063     // it attaches statically resolved method to the call site.
  1064     if (MethodHandles::is_signature_polymorphic(id) &&
  1064     if (MethodHandles::is_signature_polymorphic(id) &&
  1065         MethodHandles::is_signature_polymorphic_intrinsic(id)) {
  1065         MethodHandles::is_signature_polymorphic_intrinsic(id)) {
  1103     frame stubFrame   = thread->last_frame();
  1103     frame stubFrame   = thread->last_frame();
  1104     // Caller-frame is a compiled frame
  1104     // Caller-frame is a compiled frame
  1105     frame callerFrame = stubFrame.sender(&reg_map2);
  1105     frame callerFrame = stubFrame.sender(&reg_map2);
  1106 
  1106 
  1107     if (attached_method.is_null()) {
  1107     if (attached_method.is_null()) {
  1108       methodHandle callee = bytecode.static_target(CHECK_NH);
  1108       Method* callee = bytecode.static_target(CHECK_NH);
  1109       if (callee.is_null()) {
  1109       if (callee == NULL) {
  1110         THROW_(vmSymbols::java_lang_NoSuchMethodException(), nullHandle);
  1110         THROW_(vmSymbols::java_lang_NoSuchMethodException(), nullHandle);
  1111       }
  1111       }
  1112     }
  1112     }
  1113 
  1113 
  1114     // Retrieve from a compiled argument list
  1114     // Retrieve from a compiled argument list
  1142       // Klass is already loaded.
  1142       // Klass is already loaded.
  1143       constantPoolHandle constants(THREAD, caller->constants());
  1143       constantPoolHandle constants(THREAD, caller->constants());
  1144       rk = constants->klass_ref_at(bytecode_index, CHECK_NH);
  1144       rk = constants->klass_ref_at(bytecode_index, CHECK_NH);
  1145     }
  1145     }
  1146     Klass* static_receiver_klass = rk;
  1146     Klass* static_receiver_klass = rk;
  1147     methodHandle callee = callinfo.selected_method();
       
  1148     assert(receiver_klass->is_subtype_of(static_receiver_klass),
  1147     assert(receiver_klass->is_subtype_of(static_receiver_klass),
  1149            "actual receiver must be subclass of static receiver klass");
  1148            "actual receiver must be subclass of static receiver klass");
  1150     if (receiver_klass->is_instance_klass()) {
  1149     if (receiver_klass->is_instance_klass()) {
  1151       if (InstanceKlass::cast(receiver_klass)->is_not_initialized()) {
  1150       if (InstanceKlass::cast(receiver_klass)->is_not_initialized()) {
  1152         tty->print_cr("ERROR: Klass not yet initialized!!");
  1151         tty->print_cr("ERROR: Klass not yet initialized!!");
  1180     callee_method = methodHandle(THREAD, fr.entry_frame_call_wrapper()->callee_method());
  1179     callee_method = methodHandle(THREAD, fr.entry_frame_call_wrapper()->callee_method());
  1181   } else {
  1180   } else {
  1182     Bytecodes::Code bc;
  1181     Bytecodes::Code bc;
  1183     CallInfo callinfo;
  1182     CallInfo callinfo;
  1184     find_callee_info_helper(thread, vfst, bc, callinfo, CHECK_(methodHandle()));
  1183     find_callee_info_helper(thread, vfst, bc, callinfo, CHECK_(methodHandle()));
  1185     callee_method = callinfo.selected_method();
  1184     callee_method = methodHandle(THREAD, callinfo.selected_method());
  1186   }
  1185   }
  1187   assert(callee_method()->is_method(), "must be");
  1186   assert(callee_method()->is_method(), "must be");
  1188   return callee_method;
  1187   return callee_method;
  1189 }
  1188 }
  1190 
  1189 
  1323   //       b) an exception is thrown if receiver is NULL for non-static calls
  1322   //       b) an exception is thrown if receiver is NULL for non-static calls
  1324   CallInfo call_info;
  1323   CallInfo call_info;
  1325   Bytecodes::Code invoke_code = Bytecodes::_illegal;
  1324   Bytecodes::Code invoke_code = Bytecodes::_illegal;
  1326   Handle receiver = find_callee_info(thread, invoke_code,
  1325   Handle receiver = find_callee_info(thread, invoke_code,
  1327                                      call_info, CHECK_(methodHandle()));
  1326                                      call_info, CHECK_(methodHandle()));
  1328   methodHandle callee_method = call_info.selected_method();
  1327   methodHandle callee_method(THREAD, call_info.selected_method());
  1329 
  1328 
  1330   assert((!is_virtual && invoke_code == Bytecodes::_invokestatic ) ||
  1329   assert((!is_virtual && invoke_code == Bytecodes::_invokestatic ) ||
  1331          (!is_virtual && invoke_code == Bytecodes::_invokespecial) ||
  1330          (!is_virtual && invoke_code == Bytecodes::_invokespecial) ||
  1332          (!is_virtual && invoke_code == Bytecodes::_invokehandle ) ||
  1331          (!is_virtual && invoke_code == Bytecodes::_invokehandle ) ||
  1333          (!is_virtual && invoke_code == Bytecodes::_invokedynamic) ||
  1332          (!is_virtual && invoke_code == Bytecodes::_invokedynamic) ||
  1477 JRT_BLOCK_ENTRY(address, SharedRuntime::handle_wrong_method_abstract(JavaThread* thread))
  1476 JRT_BLOCK_ENTRY(address, SharedRuntime::handle_wrong_method_abstract(JavaThread* thread))
  1478   // Verbose error message for AbstractMethodError.
  1477   // Verbose error message for AbstractMethodError.
  1479   // Get the called method from the invoke bytecode.
  1478   // Get the called method from the invoke bytecode.
  1480   vframeStream vfst(thread, true);
  1479   vframeStream vfst(thread, true);
  1481   assert(!vfst.at_end(), "Java frame must exist");
  1480   assert(!vfst.at_end(), "Java frame must exist");
  1482   methodHandle caller(vfst.method());
  1481   methodHandle caller(thread, vfst.method());
  1483   Bytecode_invoke invoke(caller, vfst.bci());
  1482   Bytecode_invoke invoke(caller, vfst.bci());
  1484   DEBUG_ONLY( invoke.verify(); )
  1483   DEBUG_ONLY( invoke.verify(); )
  1485 
  1484 
  1486   // Find the compiled caller frame.
  1485   // Find the compiled caller frame.
  1487   RegisterMap reg_map(thread);
  1486   RegisterMap reg_map(thread);
  1491   assert(callerFrame.is_compiled_frame(), "must be");
  1490   assert(callerFrame.is_compiled_frame(), "must be");
  1492 
  1491 
  1493   // Install exception and return forward entry.
  1492   // Install exception and return forward entry.
  1494   address res = StubRoutines::throw_AbstractMethodError_entry();
  1493   address res = StubRoutines::throw_AbstractMethodError_entry();
  1495   JRT_BLOCK
  1494   JRT_BLOCK
  1496     methodHandle callee = invoke.static_target(thread);
  1495     methodHandle callee(thread, invoke.static_target(thread));
  1497     if (!callee.is_null()) {
  1496     if (!callee.is_null()) {
  1498       oop recv = callerFrame.retrieve_receiver(&reg_map);
  1497       oop recv = callerFrame.retrieve_receiver(&reg_map);
  1499       Klass *recv_klass = (recv != NULL) ? recv->klass() : NULL;
  1498       Klass *recv_klass = (recv != NULL) ? recv->klass() : NULL;
  1500       LinkResolver::throw_abstract_method_error(callee, recv_klass, thread);
  1499       LinkResolver::throw_abstract_method_error(callee, recv_klass, thread);
  1501       res = StubRoutines::forward_exception_entry();
  1500       res = StubRoutines::forward_exception_entry();
  1655       tty->print_cr(" code: " INTPTR_FORMAT, p2i(callee_method->code()));
  1654       tty->print_cr(" code: " INTPTR_FORMAT, p2i(callee_method->code()));
  1656     }
  1655     }
  1657     return callee_method;
  1656     return callee_method;
  1658   }
  1657   }
  1659 
  1658 
  1660   methodHandle callee_method = call_info.selected_method();
  1659   methodHandle callee_method(thread, call_info.selected_method());
  1661 
  1660 
  1662 #ifndef PRODUCT
  1661 #ifndef PRODUCT
  1663   Atomic::inc(&_ic_miss_ctr);
  1662   Atomic::inc(&_ic_miss_ctr);
  1664 
  1663 
  1665   // Statistics & Tracing
  1664   // Statistics & Tracing