< prev index next >

src/hotspot/share/runtime/sharedRuntime.cpp

Print this page




1037   }
1038   return NULL;
1039 }
1040 
1041 // Finds receiver, CallInfo (i.e. receiver method), and calling bytecode
1042 // for a call current in progress, i.e., arguments has been pushed on stack
1043 // but callee has not been invoked yet.  Caller frame must be compiled.
1044 Handle SharedRuntime::find_callee_info_helper(JavaThread* thread,
1045                                               vframeStream& vfst,
1046                                               Bytecodes::Code& bc,
1047                                               CallInfo& callinfo, TRAPS) {
1048   Handle receiver;
1049   Handle nullHandle;  //create a handy null handle for exception returns
1050 
1051   assert(!vfst.at_end(), "Java frame must exist");
1052 
1053   // Find caller and bci from vframe
1054   methodHandle caller(THREAD, vfst.method());
1055   int          bci   = vfst.bci();
1056 















1057   Bytecode_invoke bytecode(caller, bci);
1058   int bytecode_index = bytecode.index();
1059   bc = bytecode.invoke_code();
1060 
1061   methodHandle attached_method = extract_attached_method(vfst);
1062   if (attached_method.not_null()) {
1063     methodHandle callee = bytecode.static_target(CHECK_NH);
1064     vmIntrinsics::ID id = callee->intrinsic_id();
1065     // When VM replaces MH.invokeBasic/linkTo* call with a direct/virtual call,
1066     // it attaches statically resolved method to the call site.
1067     if (MethodHandles::is_signature_polymorphic(id) &&
1068         MethodHandles::is_signature_polymorphic_intrinsic(id)) {
1069       bc = MethodHandles::signature_polymorphic_intrinsic_bytecode(id);
1070 
1071       // Adjust invocation mode according to the attached method.
1072       switch (bc) {
1073         case Bytecodes::_invokevirtual:
1074           if (attached_method->method_holder()->is_interface()) {
1075             bc = Bytecodes::_invokeinterface;
1076           }


1339 // Resolves a call.  The compilers generate code for calls that go here
1340 // and are patched with the real destination of the call.
1341 methodHandle SharedRuntime::resolve_sub_helper(JavaThread *thread,
1342                                                bool is_virtual,
1343                                                bool is_optimized,
1344                                                bool* caller_is_c1, TRAPS) {
1345 
1346   ResourceMark rm(thread);
1347   RegisterMap cbl_map(thread, false);
1348   frame caller_frame = thread->last_frame().sender(&cbl_map);
1349 
1350   CodeBlob* caller_cb = caller_frame.cb();
1351   guarantee(caller_cb != NULL && caller_cb->is_compiled(), "must be called from compiled method");
1352   CompiledMethod* caller_nm = caller_cb->as_compiled_method_or_null();
1353   *caller_is_c1 = caller_nm->is_compiled_by_c1();
1354 
1355   // make sure caller is not getting deoptimized
1356   // and removed before we are done with it.
1357   // CLEANUP - with lazy deopt shouldn't need this lock
1358   nmethodLocker caller_lock(caller_nm);
1359 
1360   if (!is_virtual && !is_optimized) {
1361     SimpleScopeDesc ssd(caller_nm, caller_frame.pc());
1362     Bytecode bc(ssd.method(), ssd.method()->bcp_from(ssd.bci()));
1363     // Substitutability test implementation piggy backs on static call resolution
1364     if (bc.code() == Bytecodes::_if_acmpeq || bc.code() == Bytecodes::_if_acmpne) {
1365       SystemDictionary::ValueBootstrapMethods_klass()->initialize(CHECK_NULL);
1366       return SystemDictionary::ValueBootstrapMethods_klass()->find_method(vmSymbols::isSubstitutable_name(), vmSymbols::object_object_boolean_signature());
1367     }
1368   }
1369 
1370   // determine call info & receiver
1371   // note: a) receiver is NULL for static calls
1372   //       b) an exception is thrown if receiver is NULL for non-static calls
1373   CallInfo call_info;
1374   Bytecodes::Code invoke_code = Bytecodes::_illegal;
1375   Handle receiver = find_callee_info(thread, invoke_code,
1376                                      call_info, CHECK_(methodHandle()));
1377   methodHandle callee_method = call_info.selected_method();
1378 
1379   assert((!is_virtual && invoke_code == Bytecodes::_invokestatic ) ||
1380          (!is_virtual && invoke_code == Bytecodes::_invokespecial) ||
1381          (!is_virtual && invoke_code == Bytecodes::_invokehandle ) ||
1382          (!is_virtual && invoke_code == Bytecodes::_invokedynamic) ||
1383          ( is_virtual && invoke_code != Bytecodes::_invokestatic ), "inconsistent bytecode");
1384 
1385   assert(caller_nm->is_alive() && !caller_nm->is_unloading(), "It should be alive");
1386 
1387 #ifndef PRODUCT
1388   // tracing/debugging/statistics




1037   }
1038   return NULL;
1039 }
1040 
1041 // Finds receiver, CallInfo (i.e. receiver method), and calling bytecode
1042 // for a call current in progress, i.e., arguments has been pushed on stack
1043 // but callee has not been invoked yet.  Caller frame must be compiled.
1044 Handle SharedRuntime::find_callee_info_helper(JavaThread* thread,
1045                                               vframeStream& vfst,
1046                                               Bytecodes::Code& bc,
1047                                               CallInfo& callinfo, TRAPS) {
1048   Handle receiver;
1049   Handle nullHandle;  //create a handy null handle for exception returns
1050 
1051   assert(!vfst.at_end(), "Java frame must exist");
1052 
1053   // Find caller and bci from vframe
1054   methodHandle caller(THREAD, vfst.method());
1055   int          bci   = vfst.bci();
1056 
1057   // Substitutability test implementation piggy backs on static call resolution
1058   Bytecodes::Code code = caller->java_code_at(bci);
1059   if (code == Bytecodes::_if_acmpeq || code == Bytecodes::_if_acmpne) {
1060     bc = Bytecodes::_invokestatic;
1061     methodHandle attached_method = extract_attached_method(vfst);
1062     assert(attached_method.not_null(), "must have attached method");
1063     LinkResolver::resolve_invoke(callinfo, receiver, attached_method, bc, CHECK_NH);
1064 #ifdef ASSERT
1065     SystemDictionary::ValueBootstrapMethods_klass()->initialize(CHECK_NH);
1066     Method* is_subst = SystemDictionary::ValueBootstrapMethods_klass()->find_method(vmSymbols::isSubstitutable_name(), vmSymbols::object_object_boolean_signature());
1067     assert(callinfo.selected_method() == is_subst, "must be isSubstitutable method");
1068 #endif
1069     return receiver;
1070   }
1071 
1072   Bytecode_invoke bytecode(caller, bci);
1073   int bytecode_index = bytecode.index();
1074   bc = bytecode.invoke_code();
1075 
1076   methodHandle attached_method = extract_attached_method(vfst);
1077   if (attached_method.not_null()) {
1078     methodHandle callee = bytecode.static_target(CHECK_NH);
1079     vmIntrinsics::ID id = callee->intrinsic_id();
1080     // When VM replaces MH.invokeBasic/linkTo* call with a direct/virtual call,
1081     // it attaches statically resolved method to the call site.
1082     if (MethodHandles::is_signature_polymorphic(id) &&
1083         MethodHandles::is_signature_polymorphic_intrinsic(id)) {
1084       bc = MethodHandles::signature_polymorphic_intrinsic_bytecode(id);
1085 
1086       // Adjust invocation mode according to the attached method.
1087       switch (bc) {
1088         case Bytecodes::_invokevirtual:
1089           if (attached_method->method_holder()->is_interface()) {
1090             bc = Bytecodes::_invokeinterface;
1091           }


1354 // Resolves a call.  The compilers generate code for calls that go here
1355 // and are patched with the real destination of the call.
1356 methodHandle SharedRuntime::resolve_sub_helper(JavaThread *thread,
1357                                                bool is_virtual,
1358                                                bool is_optimized,
1359                                                bool* caller_is_c1, TRAPS) {
1360 
1361   ResourceMark rm(thread);
1362   RegisterMap cbl_map(thread, false);
1363   frame caller_frame = thread->last_frame().sender(&cbl_map);
1364 
1365   CodeBlob* caller_cb = caller_frame.cb();
1366   guarantee(caller_cb != NULL && caller_cb->is_compiled(), "must be called from compiled method");
1367   CompiledMethod* caller_nm = caller_cb->as_compiled_method_or_null();
1368   *caller_is_c1 = caller_nm->is_compiled_by_c1();
1369 
1370   // make sure caller is not getting deoptimized
1371   // and removed before we are done with it.
1372   // CLEANUP - with lazy deopt shouldn't need this lock
1373   nmethodLocker caller_lock(caller_nm);










1374 
1375   // determine call info & receiver
1376   // note: a) receiver is NULL for static calls
1377   //       b) an exception is thrown if receiver is NULL for non-static calls
1378   CallInfo call_info;
1379   Bytecodes::Code invoke_code = Bytecodes::_illegal;
1380   Handle receiver = find_callee_info(thread, invoke_code,
1381                                      call_info, CHECK_(methodHandle()));
1382   methodHandle callee_method = call_info.selected_method();
1383 
1384   assert((!is_virtual && invoke_code == Bytecodes::_invokestatic ) ||
1385          (!is_virtual && invoke_code == Bytecodes::_invokespecial) ||
1386          (!is_virtual && invoke_code == Bytecodes::_invokehandle ) ||
1387          (!is_virtual && invoke_code == Bytecodes::_invokedynamic) ||
1388          ( is_virtual && invoke_code != Bytecodes::_invokestatic ), "inconsistent bytecode");
1389 
1390   assert(caller_nm->is_alive() && !caller_nm->is_unloading(), "It should be alive");
1391 
1392 #ifndef PRODUCT
1393   // tracing/debugging/statistics


< prev index next >