JVMState* DirectCallGenerator::generate(JVMState* jvms, Parse* parent_parser) { GraphKit kit(jvms); bool is_static = method()->is_static(); address target = is_static ? SharedRuntime::get_resolve_static_call_stub() : SharedRuntime::get_resolve_opt_virtual_call_stub(); if (kit.C->log() != NULL) { kit.C->log()->elem("direct_call bci='%d'", jvms->bci()); } CallStaticJavaNode *call = new (kit.C) CallStaticJavaNode(kit.C, tf(), target, method(), kit.bci()); _call_node = call; // Save the call node in case we need it later if (!is_static) { // Make an explicit receiver null_check as part of this call. // Since we share a map with the caller, his JVMS gets adjusted. kit.null_check_receiver_before_call(method()); if (kit.stopped()) { // And dump it back to the caller, decorated with any exceptions: return kit.transfer_exceptions_into_jvms(); } // Mark the call node as virtual, sort of: call->set_optimized_virtual(true); if (method()->is_method_handle_intrinsic() || method()->is_compiled_lambda_form()) { call->set_method_handle_invoke(true); } } kit.set_arguments_for_java_call(call); kit.set_edges_for_java_call(call, false, _separate_io_proj); Node* ret = kit.set_results_for_java_call(call, _separate_io_proj); kit.push_node(method()->return_type()->basic_type(), ret); return kit.transfer_exceptions_into_jvms(); }
JVMState* DynamicCallGenerator::generate(JVMState* jvms) { GraphKit kit(jvms); Compile* C = kit.C; PhaseGVN& gvn = kit.gvn(); if (C->log() != NULL) { C->log()->elem("dynamic_call bci='%d'", jvms->bci()); } // Get the constant pool cache from the caller class. ciMethod* caller_method = jvms->method(); ciBytecodeStream str(caller_method); str.force_bci(jvms->bci()); // Set the stream to the invokedynamic bci. assert(str.cur_bc() == Bytecodes::_invokedynamic, "wrong place to issue a dynamic call!"); ciCPCache* cpcache = str.get_cpcache(); // Get the offset of the CallSite from the constant pool cache // pointer. int index = str.get_method_index(); size_t call_site_offset = cpcache->get_f1_offset(index); // Load the CallSite object from the constant pool cache. const TypeOopPtr* cpcache_type = TypeOopPtr::make_from_constant(cpcache); // returns TypeAryPtr of type T_OBJECT const TypeOopPtr* call_site_type = TypeOopPtr::make_from_klass(C->env()->CallSite_klass()); Node* cpcache_adr = kit.makecon(cpcache_type); Node* call_site_adr = kit.basic_plus_adr(cpcache_adr, call_site_offset); // The oops in the constant pool cache are not compressed; load then as raw pointers. Node* call_site = kit.make_load(kit.control(), call_site_adr, call_site_type, T_ADDRESS, Compile::AliasIdxRaw); // Load the target MethodHandle from the CallSite object. const TypeOopPtr* target_type = TypeOopPtr::make_from_klass(C->env()->MethodHandle_klass()); Node* target_mh_adr = kit.basic_plus_adr(call_site, java_lang_invoke_CallSite::target_offset_in_bytes()); Node* target_mh = kit.make_load(kit.control(), target_mh_adr, target_type, T_OBJECT); address resolve_stub = SharedRuntime::get_resolve_opt_virtual_call_stub(); CallStaticJavaNode* call = new (C, tf()->domain()->cnt()) CallStaticJavaNode(tf(), resolve_stub, method(), kit.bci()); // invokedynamic is treated as an optimized invokevirtual. call->set_optimized_virtual(true); // Take extra care (in the presence of argument motion) not to trash the SP: call->set_method_handle_invoke(true); // Pass the target MethodHandle as first argument and shift the // other arguments. call->init_req(0 + TypeFunc::Parms, target_mh); uint nargs = call->method()->arg_size(); for (uint i = 1; i < nargs; i++) { Node* arg = kit.argument(i - 1); call->init_req(i + TypeFunc::Parms, arg); } kit.set_edges_for_java_call(call); Node* ret = kit.set_results_for_java_call(call); kit.push_node(method()->return_type()->basic_type(), ret); return kit.transfer_exceptions_into_jvms(); }
JVMState* DirectCallGenerator::generate(JVMState* jvms) { GraphKit kit(jvms); kit.C->print_inlining_update(this); bool is_static = method()->is_static(); address target = is_static ? SharedRuntime::get_resolve_static_call_stub() : SharedRuntime::get_resolve_opt_virtual_call_stub(); if (kit.C->log() != NULL) { kit.C->log()->elem("direct_call bci='%d'", jvms->bci()); } CallStaticJavaNode *call = new CallStaticJavaNode(kit.C, tf(), target, method(), kit.bci()); if (is_inlined_mh_linker(jvms, method())) { // To be able to issue a direct call and skip a call to MH.linkTo*/invokeBasic adapter, // additional information about the method being invoked should be attached // to the call site to make resolution logic work // (see SharedRuntime::resolve_static_call_C). call->set_override_symbolic_info(true); } _call_node = call; // Save the call node in case we need it later if (!is_static) { // Make an explicit receiver null_check as part of this call. // Since we share a map with the caller, his JVMS gets adjusted. kit.null_check_receiver_before_call(method()); if (kit.stopped()) { // And dump it back to the caller, decorated with any exceptions: return kit.transfer_exceptions_into_jvms(); } // Mark the call node as virtual, sort of: call->set_optimized_virtual(true); if (method()->is_method_handle_intrinsic() || method()->is_compiled_lambda_form()) { call->set_method_handle_invoke(true); } } kit.set_arguments_for_java_call(call); kit.set_edges_for_java_call(call, false, _separate_io_proj); Node* ret = kit.set_results_for_java_call(call, _separate_io_proj); kit.push_node(method()->return_type()->basic_type(), ret); return kit.transfer_exceptions_into_jvms(); }