callGenerator.cpp revision 4022
0N/A/*
3932N/A * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "ci/bcEscapeAnalyzer.hpp"
2677N/A#include "ci/ciCallSite.hpp"
1879N/A#include "ci/ciCPCache.hpp"
3932N/A#include "ci/ciMemberName.hpp"
1879N/A#include "ci/ciMethodHandle.hpp"
1879N/A#include "classfile/javaClasses.hpp"
1879N/A#include "compiler/compileLog.hpp"
1879N/A#include "opto/addnode.hpp"
1879N/A#include "opto/callGenerator.hpp"
1879N/A#include "opto/callnode.hpp"
1879N/A#include "opto/cfgnode.hpp"
1879N/A#include "opto/connode.hpp"
1879N/A#include "opto/parse.hpp"
1879N/A#include "opto/rootnode.hpp"
1879N/A#include "opto/runtime.hpp"
1879N/A#include "opto/subnode.hpp"
0N/A
0N/A
0N/A// Utility function.
0N/Aconst TypeFunc* CallGenerator::tf() const {
0N/A return TypeFunc::make(method());
0N/A}
0N/A
0N/A//-----------------------------ParseGenerator---------------------------------
0N/A// Internal class which handles all direct bytecode traversal.
0N/Aclass ParseGenerator : public InlineCallGenerator {
0N/Aprivate:
0N/A bool _is_osr;
0N/A float _expected_uses;
0N/A
0N/Apublic:
0N/A ParseGenerator(ciMethod* method, float expected_uses, bool is_osr = false)
0N/A : InlineCallGenerator(method)
0N/A {
0N/A _is_osr = is_osr;
0N/A _expected_uses = expected_uses;
2734N/A assert(InlineTree::check_can_parse(method) == NULL, "parse must be possible");
0N/A }
0N/A
0N/A virtual bool is_parse() const { return true; }
0N/A virtual JVMState* generate(JVMState* jvms);
0N/A int is_osr() { return _is_osr; }
0N/A
0N/A};
0N/A
0N/AJVMState* ParseGenerator::generate(JVMState* jvms) {
0N/A Compile* C = Compile::current();
0N/A
0N/A if (is_osr()) {
0N/A // The JVMS for a OSR has a single argument (see its TypeFunc).
0N/A assert(jvms->depth() == 1, "no inline OSR");
0N/A }
0N/A
0N/A if (C->failing()) {
0N/A return NULL; // bailing out of the compile; do not try to parse
0N/A }
0N/A
0N/A Parse parser(jvms, method(), _expected_uses);
0N/A // Grab signature for matching/allocation
0N/A#ifdef ASSERT
0N/A if (parser.tf() != (parser.depth() == 1 ? C->tf() : tf())) {
0N/A MutexLockerEx ml(Compile_lock, Mutex::_no_safepoint_check_flag);
0N/A assert(C->env()->system_dictionary_modification_counter_changed(),
0N/A "Must invalidate if TypeFuncs differ");
0N/A }
0N/A#endif
0N/A
0N/A GraphKit& exits = parser.exits();
0N/A
0N/A if (C->failing()) {
0N/A while (exits.pop_exception_state() != NULL) ;
0N/A return NULL;
0N/A }
0N/A
0N/A assert(exits.jvms()->same_calls_as(jvms), "sanity");
0N/A
0N/A // Simply return the exit state of the parser,
0N/A // augmented by any exceptional states.
0N/A return exits.transfer_exceptions_into_jvms();
0N/A}
0N/A
0N/A//---------------------------DirectCallGenerator------------------------------
0N/A// Internal class which handles all out-of-line calls w/o receiver type checks.
0N/Aclass DirectCallGenerator : public CallGenerator {
1080N/A private:
1080N/A CallStaticJavaNode* _call_node;
1080N/A // Force separate memory and I/O projections for the exceptional
1080N/A // paths to facilitate late inlinig.
1080N/A bool _separate_io_proj;
1080N/A
1080N/A public:
1080N/A DirectCallGenerator(ciMethod* method, bool separate_io_proj)
1080N/A : CallGenerator(method),
1080N/A _separate_io_proj(separate_io_proj)
0N/A {
0N/A }
0N/A virtual JVMState* generate(JVMState* jvms);
1080N/A
1080N/A CallStaticJavaNode* call_node() const { return _call_node; }
0N/A};
0N/A
0N/AJVMState* DirectCallGenerator::generate(JVMState* jvms) {
0N/A GraphKit kit(jvms);
0N/A bool is_static = method()->is_static();
0N/A address target = is_static ? SharedRuntime::get_resolve_static_call_stub()
0N/A : SharedRuntime::get_resolve_opt_virtual_call_stub();
0N/A
0N/A if (kit.C->log() != NULL) {
0N/A kit.C->log()->elem("direct_call bci='%d'", jvms->bci());
0N/A }
0N/A
4022N/A CallStaticJavaNode *call = new (kit.C) CallStaticJavaNode(tf(), target, method(), kit.bci());
3711N/A _call_node = call; // Save the call node in case we need it later
0N/A if (!is_static) {
0N/A // Make an explicit receiver null_check as part of this call.
0N/A // Since we share a map with the caller, his JVMS gets adjusted.
0N/A kit.null_check_receiver(method());
0N/A if (kit.stopped()) {
0N/A // And dump it back to the caller, decorated with any exceptions:
0N/A return kit.transfer_exceptions_into_jvms();
0N/A }
0N/A // Mark the call node as virtual, sort of:
0N/A call->set_optimized_virtual(true);
3932N/A if (method()->is_method_handle_intrinsic() ||
3932N/A method()->is_compiled_lambda_form()) {
1137N/A call->set_method_handle_invoke(true);
1265N/A }
0N/A }
0N/A kit.set_arguments_for_java_call(call);
1080N/A kit.set_edges_for_java_call(call, false, _separate_io_proj);
1080N/A Node* ret = kit.set_results_for_java_call(call, _separate_io_proj);
0N/A kit.push_node(method()->return_type()->basic_type(), ret);
0N/A return kit.transfer_exceptions_into_jvms();
0N/A}
0N/A
1137N/A//--------------------------VirtualCallGenerator------------------------------
1137N/A// Internal class which handles all out-of-line calls checking receiver type.
0N/Aclass VirtualCallGenerator : public CallGenerator {
0N/Aprivate:
0N/A int _vtable_index;
0N/Apublic:
0N/A VirtualCallGenerator(ciMethod* method, int vtable_index)
0N/A : CallGenerator(method), _vtable_index(vtable_index)
0N/A {
0N/A assert(vtable_index == methodOopDesc::invalid_vtable_index ||
0N/A vtable_index >= 0, "either invalid or usable");
0N/A }
0N/A virtual bool is_virtual() const { return true; }
0N/A virtual JVMState* generate(JVMState* jvms);
0N/A};
0N/A
0N/AJVMState* VirtualCallGenerator::generate(JVMState* jvms) {
0N/A GraphKit kit(jvms);
0N/A Node* receiver = kit.argument(0);
0N/A
0N/A if (kit.C->log() != NULL) {
0N/A kit.C->log()->elem("virtual_call bci='%d'", jvms->bci());
0N/A }
0N/A
0N/A // If the receiver is a constant null, do not torture the system
0N/A // by attempting to call through it. The compile will proceed
0N/A // correctly, but may bail out in final_graph_reshaping, because
0N/A // the call instruction will have a seemingly deficient out-count.
0N/A // (The bailout says something misleading about an "infinite loop".)
0N/A if (kit.gvn().type(receiver)->higher_equal(TypePtr::NULL_PTR)) {
0N/A kit.inc_sp(method()->arg_size()); // restore arguments
0N/A kit.uncommon_trap(Deoptimization::Reason_null_check,
0N/A Deoptimization::Action_none,
0N/A NULL, "null receiver");
0N/A return kit.transfer_exceptions_into_jvms();
0N/A }
0N/A
0N/A // Ideally we would unconditionally do a null check here and let it
0N/A // be converted to an implicit check based on profile information.
0N/A // However currently the conversion to implicit null checks in
0N/A // Block::implicit_null_check() only looks for loads and stores, not calls.
0N/A ciMethod *caller = kit.method();
0N/A ciMethodData *caller_md = (caller == NULL) ? NULL : caller->method_data();
0N/A if (!UseInlineCaches || !ImplicitNullChecks ||
0N/A ((ImplicitNullCheckThreshold > 0) && caller_md &&
0N/A (caller_md->trap_count(Deoptimization::Reason_null_check)
0N/A >= (uint)ImplicitNullCheckThreshold))) {
0N/A // Make an explicit receiver null_check as part of this call.
0N/A // Since we share a map with the caller, his JVMS gets adjusted.
0N/A receiver = kit.null_check_receiver(method());
0N/A if (kit.stopped()) {
0N/A // And dump it back to the caller, decorated with any exceptions:
0N/A return kit.transfer_exceptions_into_jvms();
0N/A }
0N/A }
0N/A
0N/A assert(!method()->is_static(), "virtual call must not be to static");
0N/A assert(!method()->is_final(), "virtual call should not be to final");
0N/A assert(!method()->is_private(), "virtual call should not be to private");
0N/A assert(_vtable_index == methodOopDesc::invalid_vtable_index || !UseInlineCaches,
0N/A "no vtable calls if +UseInlineCaches ");
0N/A address target = SharedRuntime::get_resolve_virtual_call_stub();
0N/A // Normal inline cache used for call
4022N/A CallDynamicJavaNode *call = new (kit.C) CallDynamicJavaNode(tf(), target, method(), _vtable_index, kit.bci());
0N/A kit.set_arguments_for_java_call(call);
0N/A kit.set_edges_for_java_call(call);
0N/A Node* ret = kit.set_results_for_java_call(call);
0N/A kit.push_node(method()->return_type()->basic_type(), ret);
0N/A
0N/A // Represent the effect of an implicit receiver null_check
0N/A // as part of this call. Since we share a map with the caller,
0N/A // his JVMS gets adjusted.
0N/A kit.cast_not_null(receiver);
0N/A return kit.transfer_exceptions_into_jvms();
0N/A}
0N/A
0N/ACallGenerator* CallGenerator::for_inline(ciMethod* m, float expected_uses) {
2734N/A if (InlineTree::check_can_parse(m) != NULL) return NULL;
0N/A return new ParseGenerator(m, expected_uses);
0N/A}
0N/A
0N/A// As a special case, the JVMS passed to this CallGenerator is
0N/A// for the method execution already in progress, not just the JVMS
0N/A// of the caller. Thus, this CallGenerator cannot be mixed with others!
0N/ACallGenerator* CallGenerator::for_osr(ciMethod* m, int osr_bci) {
2734N/A if (InlineTree::check_can_parse(m) != NULL) return NULL;
0N/A float past_uses = m->interpreter_invocation_count();
0N/A float expected_uses = past_uses;
0N/A return new ParseGenerator(m, expected_uses, true);
0N/A}
0N/A
1080N/ACallGenerator* CallGenerator::for_direct_call(ciMethod* m, bool separate_io_proj) {
0N/A assert(!m->is_abstract(), "for_direct_call mismatch");
1080N/A return new DirectCallGenerator(m, separate_io_proj);
0N/A}
0N/A
0N/ACallGenerator* CallGenerator::for_virtual_call(ciMethod* m, int vtable_index) {
0N/A assert(!m->is_static(), "for_virtual_call mismatch");
3932N/A assert(!m->is_method_handle_intrinsic(), "should be a direct call");
0N/A return new VirtualCallGenerator(m, vtable_index);
0N/A}
0N/A
1080N/A// Allow inlining decisions to be delayed
1080N/Aclass LateInlineCallGenerator : public DirectCallGenerator {
1080N/A CallGenerator* _inline_cg;
1080N/A
1080N/A public:
1080N/A LateInlineCallGenerator(ciMethod* method, CallGenerator* inline_cg) :
1080N/A DirectCallGenerator(method, true), _inline_cg(inline_cg) {}
1080N/A
1080N/A virtual bool is_late_inline() const { return true; }
1080N/A
1080N/A // Convert the CallStaticJava into an inline
1080N/A virtual void do_late_inline();
1080N/A
3966N/A virtual JVMState* generate(JVMState* jvms) {
1080N/A // Record that this call site should be revisited once the main
1080N/A // parse is finished.
1080N/A Compile::current()->add_late_inline(this);
1080N/A
1080N/A // Emit the CallStaticJava and request separate projections so
1080N/A // that the late inlining logic can distinguish between fall
1080N/A // through and exceptional uses of the memory and io projections
1080N/A // as is done for allocations and macro expansion.
1080N/A return DirectCallGenerator::generate(jvms);
1080N/A }
1080N/A
1080N/A};
1080N/A
1080N/A
1080N/Avoid LateInlineCallGenerator::do_late_inline() {
1080N/A // Can't inline it
1080N/A if (call_node() == NULL || call_node()->outcnt() == 0 ||
1080N/A call_node()->in(0) == NULL || call_node()->in(0)->is_top())
1080N/A return;
1080N/A
1080N/A CallStaticJavaNode* call = call_node();
1080N/A
1080N/A // Make a clone of the JVMState that appropriate to use for driving a parse
1080N/A Compile* C = Compile::current();
1080N/A JVMState* jvms = call->jvms()->clone_shallow(C);
1080N/A uint size = call->req();
4022N/A SafePointNode* map = new (C) SafePointNode(size, jvms);
1080N/A for (uint i1 = 0; i1 < size; i1++) {
1080N/A map->init_req(i1, call->in(i1));
1080N/A }
1080N/A
1080N/A // Make sure the state is a MergeMem for parsing.
1080N/A if (!map->in(TypeFunc::Memory)->is_MergeMem()) {
1080N/A map->set_req(TypeFunc::Memory, MergeMemNode::make(C, map->in(TypeFunc::Memory)));
1080N/A }
1080N/A
1080N/A // Make enough space for the expression stack and transfer the incoming arguments
1080N/A int nargs = method()->arg_size();
1080N/A jvms->set_map(map);
1080N/A map->ensure_stack(jvms, jvms->method()->max_stack());
1080N/A if (nargs > 0) {
1080N/A for (int i1 = 0; i1 < nargs; i1++) {
1080N/A map->set_req(i1 + jvms->argoff(), call->in(TypeFunc::Parms + i1));
1080N/A }
1080N/A }
1080N/A
1080N/A CompileLog* log = C->log();
1080N/A if (log != NULL) {
1080N/A log->head("late_inline method='%d'", log->identify(method()));
1080N/A JVMState* p = jvms;
1080N/A while (p != NULL) {
1080N/A log->elem("jvms bci='%d' method='%d'", p->bci(), log->identify(p->method()));
1080N/A p = p->caller();
1080N/A }
1080N/A log->tail("late_inline");
1080N/A }
1080N/A
1080N/A // Setup default node notes to be picked up by the inlining
1080N/A Node_Notes* old_nn = C->default_node_notes();
1080N/A if (old_nn != NULL) {
1080N/A Node_Notes* entry_nn = old_nn->clone(C);
1080N/A entry_nn->set_jvms(jvms);
1080N/A C->set_default_node_notes(entry_nn);
1080N/A }
1080N/A
1080N/A // Now perform the inling using the synthesized JVMState
1080N/A JVMState* new_jvms = _inline_cg->generate(jvms);
1080N/A if (new_jvms == NULL) return; // no change
1080N/A if (C->failing()) return;
1080N/A
1080N/A // Capture any exceptional control flow
1080N/A GraphKit kit(new_jvms);
1080N/A
1080N/A // Find the result object
1080N/A Node* result = C->top();
1080N/A int result_size = method()->return_type()->size();
1080N/A if (result_size != 0 && !kit.stopped()) {
1080N/A result = (result_size == 1) ? kit.pop() : kit.pop_pair();
1080N/A }
1080N/A
1080N/A kit.replace_call(call, result);
1080N/A}
1080N/A
1080N/A
1080N/ACallGenerator* CallGenerator::for_late_inline(ciMethod* method, CallGenerator* inline_cg) {
1080N/A return new LateInlineCallGenerator(method, inline_cg);
1080N/A}
1080N/A
0N/A
0N/A//---------------------------WarmCallGenerator--------------------------------
0N/A// Internal class which handles initial deferral of inlining decisions.
0N/Aclass WarmCallGenerator : public CallGenerator {
0N/A WarmCallInfo* _call_info;
0N/A CallGenerator* _if_cold;
0N/A CallGenerator* _if_hot;
0N/A bool _is_virtual; // caches virtuality of if_cold
0N/A bool _is_inline; // caches inline-ness of if_hot
0N/A
0N/Apublic:
0N/A WarmCallGenerator(WarmCallInfo* ci,
0N/A CallGenerator* if_cold,
0N/A CallGenerator* if_hot)
0N/A : CallGenerator(if_cold->method())
0N/A {
0N/A assert(method() == if_hot->method(), "consistent choices");
0N/A _call_info = ci;
0N/A _if_cold = if_cold;
0N/A _if_hot = if_hot;
0N/A _is_virtual = if_cold->is_virtual();
0N/A _is_inline = if_hot->is_inline();
0N/A }
0N/A
0N/A virtual bool is_inline() const { return _is_inline; }
0N/A virtual bool is_virtual() const { return _is_virtual; }
0N/A virtual bool is_deferred() const { return true; }
0N/A
0N/A virtual JVMState* generate(JVMState* jvms);
0N/A};
0N/A
0N/A
0N/ACallGenerator* CallGenerator::for_warm_call(WarmCallInfo* ci,
0N/A CallGenerator* if_cold,
0N/A CallGenerator* if_hot) {
0N/A return new WarmCallGenerator(ci, if_cold, if_hot);
0N/A}
0N/A
0N/AJVMState* WarmCallGenerator::generate(JVMState* jvms) {
0N/A Compile* C = Compile::current();
0N/A if (C->log() != NULL) {
0N/A C->log()->elem("warm_call bci='%d'", jvms->bci());
0N/A }
0N/A jvms = _if_cold->generate(jvms);
0N/A if (jvms != NULL) {
0N/A Node* m = jvms->map()->control();
0N/A if (m->is_CatchProj()) m = m->in(0); else m = C->top();
0N/A if (m->is_Catch()) m = m->in(0); else m = C->top();
0N/A if (m->is_Proj()) m = m->in(0); else m = C->top();
0N/A if (m->is_CallJava()) {
0N/A _call_info->set_call(m->as_Call());
0N/A _call_info->set_hot_cg(_if_hot);
0N/A#ifndef PRODUCT
0N/A if (PrintOpto || PrintOptoInlining) {
0N/A tty->print_cr("Queueing for warm inlining at bci %d:", jvms->bci());
0N/A tty->print("WCI: ");
0N/A _call_info->print();
0N/A }
0N/A#endif
0N/A _call_info->set_heat(_call_info->compute_heat());
0N/A C->set_warm_calls(_call_info->insert_into(C->warm_calls()));
0N/A }
0N/A }
0N/A return jvms;
0N/A}
0N/A
0N/Avoid WarmCallInfo::make_hot() {
1080N/A Unimplemented();
0N/A}
0N/A
0N/Avoid WarmCallInfo::make_cold() {
0N/A // No action: Just dequeue.
0N/A}
0N/A
0N/A
0N/A//------------------------PredictedCallGenerator------------------------------
0N/A// Internal class which handles all out-of-line calls checking receiver type.
0N/Aclass PredictedCallGenerator : public CallGenerator {
0N/A ciKlass* _predicted_receiver;
0N/A CallGenerator* _if_missed;
0N/A CallGenerator* _if_hit;
0N/A float _hit_prob;
0N/A
0N/Apublic:
0N/A PredictedCallGenerator(ciKlass* predicted_receiver,
0N/A CallGenerator* if_missed,
0N/A CallGenerator* if_hit, float hit_prob)
0N/A : CallGenerator(if_missed->method())
0N/A {
0N/A // The call profile data may predict the hit_prob as extreme as 0 or 1.
0N/A // Remove the extremes values from the range.
0N/A if (hit_prob > PROB_MAX) hit_prob = PROB_MAX;
0N/A if (hit_prob < PROB_MIN) hit_prob = PROB_MIN;
0N/A
0N/A _predicted_receiver = predicted_receiver;
0N/A _if_missed = if_missed;
0N/A _if_hit = if_hit;
0N/A _hit_prob = hit_prob;
0N/A }
0N/A
0N/A virtual bool is_virtual() const { return true; }
0N/A virtual bool is_inline() const { return _if_hit->is_inline(); }
0N/A virtual bool is_deferred() const { return _if_hit->is_deferred(); }
0N/A
0N/A virtual JVMState* generate(JVMState* jvms);
0N/A};
0N/A
0N/A
0N/ACallGenerator* CallGenerator::for_predicted_call(ciKlass* predicted_receiver,
0N/A CallGenerator* if_missed,
0N/A CallGenerator* if_hit,
0N/A float hit_prob) {
0N/A return new PredictedCallGenerator(predicted_receiver, if_missed, if_hit, hit_prob);
0N/A}
0N/A
0N/A
0N/AJVMState* PredictedCallGenerator::generate(JVMState* jvms) {
0N/A GraphKit kit(jvms);
0N/A PhaseGVN& gvn = kit.gvn();
0N/A // We need an explicit receiver null_check before checking its type.
0N/A // We share a map with the caller, so his JVMS gets adjusted.
0N/A Node* receiver = kit.argument(0);
0N/A
0N/A CompileLog* log = kit.C->log();
0N/A if (log != NULL) {
0N/A log->elem("predicted_call bci='%d' klass='%d'",
0N/A jvms->bci(), log->identify(_predicted_receiver));
0N/A }
0N/A
0N/A receiver = kit.null_check_receiver(method());
0N/A if (kit.stopped()) {
0N/A return kit.transfer_exceptions_into_jvms();
0N/A }
0N/A
0N/A Node* exact_receiver = receiver; // will get updated in place...
0N/A Node* slow_ctl = kit.type_check_receiver(receiver,
0N/A _predicted_receiver, _hit_prob,
0N/A &exact_receiver);
0N/A
0N/A SafePointNode* slow_map = NULL;
0N/A JVMState* slow_jvms;
0N/A { PreserveJVMState pjvms(&kit);
0N/A kit.set_control(slow_ctl);
0N/A if (!kit.stopped()) {
0N/A slow_jvms = _if_missed->generate(kit.sync_jvms());
2960N/A if (kit.failing())
2960N/A return NULL; // might happen because of NodeCountInliningCutoff
2960N/A assert(slow_jvms != NULL, "must be");
0N/A kit.add_exception_states_from(slow_jvms);
0N/A kit.set_map(slow_jvms->map());
0N/A if (!kit.stopped())
0N/A slow_map = kit.stop();
0N/A }
0N/A }
0N/A
293N/A if (kit.stopped()) {
293N/A // Instance exactly does not matches the desired type.
293N/A kit.set_jvms(slow_jvms);
293N/A return kit.transfer_exceptions_into_jvms();
293N/A }
293N/A
0N/A // fall through if the instance exactly matches the desired type
0N/A kit.replace_in_map(receiver, exact_receiver);
0N/A
0N/A // Make the hot call:
0N/A JVMState* new_jvms = _if_hit->generate(kit.sync_jvms());
0N/A if (new_jvms == NULL) {
0N/A // Inline failed, so make a direct call.
0N/A assert(_if_hit->is_inline(), "must have been a failed inline");
0N/A CallGenerator* cg = CallGenerator::for_direct_call(_if_hit->method());
0N/A new_jvms = cg->generate(kit.sync_jvms());
0N/A }
0N/A kit.add_exception_states_from(new_jvms);
0N/A kit.set_jvms(new_jvms);
0N/A
0N/A // Need to merge slow and fast?
0N/A if (slow_map == NULL) {
0N/A // The fast path is the only path remaining.
0N/A return kit.transfer_exceptions_into_jvms();
0N/A }
0N/A
0N/A if (kit.stopped()) {
0N/A // Inlined method threw an exception, so it's just the slow path after all.
0N/A kit.set_jvms(slow_jvms);
0N/A return kit.transfer_exceptions_into_jvms();
0N/A }
0N/A
0N/A // Finish the diamond.
0N/A kit.C->set_has_split_ifs(true); // Has chance for split-if optimization
4022N/A RegionNode* region = new (kit.C) RegionNode(3);
0N/A region->init_req(1, kit.control());
0N/A region->init_req(2, slow_map->control());
0N/A kit.set_control(gvn.transform(region));
0N/A Node* iophi = PhiNode::make(region, kit.i_o(), Type::ABIO);
0N/A iophi->set_req(2, slow_map->i_o());
0N/A kit.set_i_o(gvn.transform(iophi));
0N/A kit.merge_memory(slow_map->merged_memory(), region, 2);
0N/A uint tos = kit.jvms()->stkoff() + kit.sp();
0N/A uint limit = slow_map->req();
0N/A for (uint i = TypeFunc::Parms; i < limit; i++) {
0N/A // Skip unused stack slots; fast forward to monoff();
0N/A if (i == tos) {
0N/A i = kit.jvms()->monoff();
0N/A if( i >= limit ) break;
0N/A }
0N/A Node* m = kit.map()->in(i);
0N/A Node* n = slow_map->in(i);
0N/A if (m != n) {
0N/A const Type* t = gvn.type(m)->meet(gvn.type(n));
0N/A Node* phi = PhiNode::make(region, m, t);
0N/A phi->set_req(2, n);
0N/A kit.map()->set_req(i, gvn.transform(phi));
0N/A }
0N/A }
0N/A return kit.transfer_exceptions_into_jvms();
0N/A}
0N/A
0N/A
3932N/ACallGenerator* CallGenerator::for_method_handle_call(JVMState* jvms, ciMethod* caller, ciMethod* callee) {
3932N/A assert(callee->is_method_handle_intrinsic() ||
3932N/A callee->is_compiled_lambda_form(), "for_method_handle_call mismatch");
3932N/A CallGenerator* cg = CallGenerator::for_method_handle_inline(jvms, caller, callee);
2960N/A if (cg != NULL)
2960N/A return cg;
2960N/A return CallGenerator::for_direct_call(callee);
2960N/A}
2960N/A
3932N/ACallGenerator* CallGenerator::for_method_handle_inline(JVMState* jvms, ciMethod* caller, ciMethod* callee) {
3932N/A GraphKit kit(jvms);
3932N/A PhaseGVN& gvn = kit.gvn();
3932N/A Compile* C = kit.C;
3932N/A vmIntrinsics::ID iid = callee->intrinsic_id();
3932N/A switch (iid) {
3932N/A case vmIntrinsics::_invokeBasic:
3932N/A {
3932N/A // get MethodHandle receiver
3932N/A Node* receiver = kit.argument(0);
3932N/A if (receiver->Opcode() == Op_ConP) {
3932N/A const TypeOopPtr* oop_ptr = receiver->bottom_type()->is_oopptr();
3932N/A ciMethod* target = oop_ptr->const_oop()->as_method_handle()->get_vmtarget();
3932N/A guarantee(!target->is_method_handle_intrinsic(), "should not happen"); // XXX remove
3932N/A const int vtable_index = methodOopDesc::invalid_vtable_index;
3932N/A CallGenerator* cg = C->call_generator(target, vtable_index, false, jvms, true, PROB_ALWAYS);
3932N/A if (cg != NULL && cg->is_inline())
3932N/A return cg;
3932N/A } else {
3932N/A if (PrintInlining) CompileTask::print_inlining(callee, jvms->depth() - 1, jvms->bci(), "receiver not constant");
2739N/A }
2739N/A }
3932N/A break;
2739N/A
3932N/A case vmIntrinsics::_linkToVirtual:
3932N/A case vmIntrinsics::_linkToStatic:
3932N/A case vmIntrinsics::_linkToSpecial:
3932N/A case vmIntrinsics::_linkToInterface:
3932N/A {
Error!

 

There was an error!

null

java.lang.NullPointerException