|
Java example source code file (doCall.cpp)
The doCall.cpp Java example source code
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "ci/ciCallSite.hpp"
#include "ci/ciMethodHandle.hpp"
#include "classfile/vmSymbols.hpp"
#include "compiler/compileBroker.hpp"
#include "compiler/compileLog.hpp"
#include "interpreter/linkResolver.hpp"
#include "opto/addnode.hpp"
#include "opto/callGenerator.hpp"
#include "opto/cfgnode.hpp"
#include "opto/mulnode.hpp"
#include "opto/parse.hpp"
#include "opto/rootnode.hpp"
#include "opto/runtime.hpp"
#include "opto/subnode.hpp"
#include "prims/nativeLookup.hpp"
#include "runtime/sharedRuntime.hpp"
void trace_type_profile(Compile* C, ciMethod *method, int depth, int bci, ciMethod *prof_method, ciKlass *prof_klass, int site_count, int receiver_count) {
if (TraceTypeProfile || C->print_inlining()) {
outputStream* out = tty;
if (!C->print_inlining()) {
if (NOT_PRODUCT(!PrintOpto &&) !PrintCompilation) {
method->print_short_name();
tty->cr();
}
CompileTask::print_inlining(prof_method, depth, bci);
} else {
out = C->print_inlining_stream();
}
CompileTask::print_inline_indent(depth, out);
out->print(" \\-> TypeProfile (%d/%d counts) = ", receiver_count, site_count);
stringStream ss;
prof_klass->name()->print_symbol_on(&ss);
out->print(ss.as_string());
out->cr();
}
}
CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool call_does_dispatch,
JVMState* jvms, bool allow_inline,
float prof_factor, ciKlass* speculative_receiver_type,
bool allow_intrinsics, bool delayed_forbidden) {
ciMethod* caller = jvms->method();
int bci = jvms->bci();
Bytecodes::Code bytecode = caller->java_code_at_bci(bci);
guarantee(callee != NULL, "failed method resolution");
// Dtrace currently doesn't work unless all calls are vanilla
if (env()->dtrace_method_probes()) {
allow_inline = false;
}
// Note: When we get profiling during stage-1 compiles, we want to pull
// from more specific profile data which pertains to this inlining.
// Right now, ignore the information in jvms->caller(), and do method[bci].
ciCallProfile profile = caller->call_profile_at_bci(bci);
// See how many times this site has been invoked.
int site_count = profile.count();
int receiver_count = -1;
if (call_does_dispatch && UseTypeProfile && profile.has_receiver(0)) {
// Receivers in the profile structure are ordered by call counts
// so that the most called (major) receiver is profile.receiver(0).
receiver_count = profile.receiver_count(0);
}
CompileLog* log = this->log();
if (log != NULL) {
int rid = (receiver_count >= 0)? log->identify(profile.receiver(0)): -1;
int r2id = (rid != -1 && profile.has_receiver(1))? log->identify(profile.receiver(1)):-1;
log->begin_elem("call method='%d' count='%d' prof_factor='%g'",
log->identify(callee), site_count, prof_factor);
if (call_does_dispatch) log->print(" virtual='1'");
if (allow_inline) log->print(" inline='1'");
if (receiver_count >= 0) {
log->print(" receiver='%d' receiver_count='%d'", rid, receiver_count);
if (profile.has_receiver(1)) {
log->print(" receiver2='%d' receiver2_count='%d'", r2id, profile.receiver_count(1));
}
}
log->end_elem();
}
// Special case the handling of certain common, profitable library
// methods. If these methods are replaced with specialized code,
// then we return it as the inlined version of the call.
// We do this before the strict f.p. check below because the
// intrinsics handle strict f.p. correctly.
CallGenerator* cg_intrinsic = NULL;
if (allow_inline && allow_intrinsics) {
CallGenerator* cg = find_intrinsic(callee, call_does_dispatch);
if (cg != NULL) {
if (cg->is_predicted()) {
// Code without intrinsic but, hopefully, inlined.
CallGenerator* inline_cg = this->call_generator(callee,
vtable_index, call_does_dispatch, jvms, allow_inline, prof_factor, speculative_receiver_type, false);
if (inline_cg != NULL) {
cg = CallGenerator::for_predicted_intrinsic(cg, inline_cg);
}
}
// If intrinsic does the virtual dispatch, we try to use the type profile
// first, and hopefully inline it as the regular virtual call below.
// We will retry the intrinsic if nothing had claimed it afterwards.
if (cg->does_virtual_dispatch()) {
cg_intrinsic = cg;
cg = NULL;
} else {
return cg;
}
}
}
// Do method handle calls.
// NOTE: This must happen before normal inlining logic below since
// MethodHandle.invoke* are native methods which obviously don't
// have bytecodes and so normal inlining fails.
if (callee->is_method_handle_intrinsic()) {
CallGenerator* cg = CallGenerator::for_method_handle_call(jvms, caller, callee, delayed_forbidden);
assert(cg == NULL || !delayed_forbidden || !cg->is_late_inline() || cg->is_mh_late_inline(), "unexpected CallGenerator");
return cg;
}
// Do not inline strict fp into non-strict code, or the reverse
if (caller->is_strict() ^ callee->is_strict()) {
allow_inline = false;
}
// Attempt to inline...
if (allow_inline) {
// The profile data is only partly attributable to this caller,
// scale back the call site information.
float past_uses = jvms->method()->scale_count(site_count, prof_factor);
// This is the number of times we expect the call code to be used.
float expected_uses = past_uses;
// Try inlining a bytecoded method:
if (!call_does_dispatch) {
InlineTree* ilt;
if (UseOldInlining) {
ilt = InlineTree::find_subtree_from_root(this->ilt(), jvms->caller(), jvms->method());
} else {
// Make a disembodied, stateless ILT.
// TO DO: When UseOldInlining is removed, copy the ILT code elsewhere.
float site_invoke_ratio = prof_factor;
// Note: ilt is for the root of this parse, not the present call site.
ilt = new InlineTree(this, jvms->method(), jvms->caller(), site_invoke_ratio, MaxInlineLevel);
}
WarmCallInfo scratch_ci;
if (!UseOldInlining)
scratch_ci.init(jvms, callee, profile, prof_factor);
bool should_delay = false;
WarmCallInfo* ci = ilt->ok_to_inline(callee, jvms, profile, &scratch_ci, should_delay);
assert(ci != &scratch_ci, "do not let this pointer escape");
bool allow_inline = (ci != NULL && !ci->is_cold());
bool require_inline = (allow_inline && ci->is_hot());
if (allow_inline) {
CallGenerator* cg = CallGenerator::for_inline(callee, expected_uses);
if (require_inline && cg != NULL) {
// Delay the inlining of this method to give us the
// opportunity to perform some high level optimizations
// first.
if (should_delay_string_inlining(callee, jvms)) {
assert(!delayed_forbidden, "strange");
return CallGenerator::for_string_late_inline(callee, cg);
} else if (should_delay_boxing_inlining(callee, jvms)) {
assert(!delayed_forbidden, "strange");
return CallGenerator::for_boxing_late_inline(callee, cg);
} else if ((should_delay || AlwaysIncrementalInline) && !delayed_forbidden) {
return CallGenerator::for_late_inline(callee, cg);
}
}
if (cg == NULL || should_delay) {
// Fall through.
} else if (require_inline || !InlineWarmCalls) {
return cg;
} else {
CallGenerator* cold_cg = call_generator(callee, vtable_index, call_does_dispatch, jvms, false, prof_factor);
return CallGenerator::for_warm_call(ci, cold_cg, cg);
}
}
}
// Try using the type profile.
if (call_does_dispatch && site_count > 0 && receiver_count > 0) {
// The major receiver's count >= TypeProfileMajorReceiverPercent of site_count.
bool have_major_receiver = (100.*profile.receiver_prob(0) >= (float)TypeProfileMajorReceiverPercent);
ciMethod* receiver_method = NULL;
int morphism = profile.morphism();
if (speculative_receiver_type != NULL) {
// We have a speculative type, we should be able to resolve
// the call. We do that before looking at the profiling at
// this invoke because it may lead to bimorphic inlining which
// a speculative type should help us avoid.
receiver_method = callee->resolve_invoke(jvms->method()->holder(),
speculative_receiver_type);
if (receiver_method == NULL) {
speculative_receiver_type = NULL;
} else {
morphism = 1;
}
}
if (receiver_method == NULL &&
(have_major_receiver || morphism == 1 ||
(morphism == 2 && UseBimorphicInlining))) {
// receiver_method = profile.method();
// Profiles do not suggest methods now. Look it up in the major receiver.
receiver_method = callee->resolve_invoke(jvms->method()->holder(),
profile.receiver(0));
}
if (receiver_method != NULL) {
// The single majority receiver sufficiently outweighs the minority.
CallGenerator* hit_cg = this->call_generator(receiver_method,
vtable_index, !call_does_dispatch, jvms, allow_inline, prof_factor);
if (hit_cg != NULL) {
// Look up second receiver.
CallGenerator* next_hit_cg = NULL;
ciMethod* next_receiver_method = NULL;
if (morphism == 2 && UseBimorphicInlining) {
next_receiver_method = callee->resolve_invoke(jvms->method()->holder(),
profile.receiver(1));
if (next_receiver_method != NULL) {
next_hit_cg = this->call_generator(next_receiver_method,
vtable_index, !call_does_dispatch, jvms,
allow_inline, prof_factor);
if (next_hit_cg != NULL && !next_hit_cg->is_inline() &&
have_major_receiver && UseOnlyInlinedBimorphic) {
// Skip if we can't inline second receiver's method
next_hit_cg = NULL;
}
}
}
CallGenerator* miss_cg;
Deoptimization::DeoptReason reason = morphism == 2 ?
Deoptimization::Reason_bimorphic :
Deoptimization::Reason_class_check;
if ((morphism == 1 || (morphism == 2 && next_hit_cg != NULL)) &&
!too_many_traps(jvms->method(), jvms->bci(), reason)
) {
// Generate uncommon trap for class check failure path
// in case of monomorphic or bimorphic virtual call site.
miss_cg = CallGenerator::for_uncommon_trap(callee, reason,
Deoptimization::Action_maybe_recompile);
} else {
// Generate virtual call for class check failure path
// in case of polymorphic virtual call site.
miss_cg = CallGenerator::for_virtual_call(callee, vtable_index);
}
if (miss_cg != NULL) {
if (next_hit_cg != NULL) {
assert(speculative_receiver_type == NULL, "shouldn't end up here if we used speculation");
trace_type_profile(C, jvms->method(), jvms->depth() - 1, jvms->bci(), next_receiver_method, profile.receiver(1), site_count, profile.receiver_count(1));
// We don't need to record dependency on a receiver here and below.
// Whenever we inline, the dependency is added by Parse::Parse().
miss_cg = CallGenerator::for_predicted_call(profile.receiver(1), miss_cg, next_hit_cg, PROB_MAX);
}
if (miss_cg != NULL) {
trace_type_profile(C, jvms->method(), jvms->depth() - 1, jvms->bci(), receiver_method, profile.receiver(0), site_count, receiver_count);
ciKlass* k = speculative_receiver_type != NULL ? speculative_receiver_type : profile.receiver(0);
float hit_prob = speculative_receiver_type != NULL ? 1.0 : profile.receiver_prob(0);
CallGenerator* cg = CallGenerator::for_predicted_call(k, miss_cg, hit_cg, hit_prob);
if (cg != NULL) return cg;
}
}
}
}
}
}
// Nothing claimed the intrinsic, we go with straight-forward inlining
// for already discovered intrinsic.
if (allow_inline && allow_intrinsics && cg_intrinsic != NULL) {
assert(cg_intrinsic->does_virtual_dispatch(), "sanity");
return cg_intrinsic;
}
// There was no special inlining tactic, or it bailed out.
// Use a more generic tactic, like a simple call.
if (call_does_dispatch) {
return CallGenerator::for_virtual_call(callee, vtable_index);
} else {
// Class Hierarchy Analysis or Type Profile reveals a unique target,
// or it is a static or special call.
return CallGenerator::for_direct_call(callee, should_delay_inlining(callee, jvms));
}
}
// Return true for methods that shouldn't be inlined early so that
// they are easier to analyze and optimize as intrinsics.
bool Compile::should_delay_string_inlining(ciMethod* call_method, JVMState* jvms) {
if (has_stringbuilder()) {
if ((call_method->holder() == C->env()->StringBuilder_klass() ||
call_method->holder() == C->env()->StringBuffer_klass()) &&
(jvms->method()->holder() == C->env()->StringBuilder_klass() ||
jvms->method()->holder() == C->env()->StringBuffer_klass())) {
// Delay SB calls only when called from non-SB code
return false;
}
switch (call_method->intrinsic_id()) {
case vmIntrinsics::_StringBuilder_void:
case vmIntrinsics::_StringBuilder_int:
case vmIntrinsics::_StringBuilder_String:
case vmIntrinsics::_StringBuilder_append_char:
case vmIntrinsics::_StringBuilder_append_int:
case vmIntrinsics::_StringBuilder_append_String:
case vmIntrinsics::_StringBuilder_toString:
case vmIntrinsics::_StringBuffer_void:
case vmIntrinsics::_StringBuffer_int:
case vmIntrinsics::_StringBuffer_String:
case vmIntrinsics::_StringBuffer_append_char:
case vmIntrinsics::_StringBuffer_append_int:
case vmIntrinsics::_StringBuffer_append_String:
case vmIntrinsics::_StringBuffer_toString:
case vmIntrinsics::_Integer_toString:
return true;
case vmIntrinsics::_String_String:
{
Node* receiver = jvms->map()->in(jvms->argoff() + 1);
if (receiver->is_Proj() && receiver->in(0)->is_CallStaticJava()) {
CallStaticJavaNode* csj = receiver->in(0)->as_CallStaticJava();
ciMethod* m = csj->method();
if (m != NULL &&
(m->intrinsic_id() == vmIntrinsics::_StringBuffer_toString ||
m->intrinsic_id() == vmIntrinsics::_StringBuilder_toString))
// Delay String.<init>(new SB())
return true;
}
return false;
}
default:
return false;
}
}
return false;
}
bool Compile::should_delay_boxing_inlining(ciMethod* call_method, JVMState* jvms) {
if (eliminate_boxing() && call_method->is_boxing_method()) {
set_has_boxed_value(true);
return true;
}
return false;
}
// uncommon-trap call-sites where callee is unloaded, uninitialized or will not link
bool Parse::can_not_compile_call_site(ciMethod *dest_method, ciInstanceKlass* klass) {
// Additional inputs to consider...
// bc = bc()
// caller = method()
// iter().get_method_holder_index()
assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" );
// Interface classes can be loaded & linked and never get around to
// being initialized. Uncommon-trap for not-initialized static or
// v-calls. Let interface calls happen.
ciInstanceKlass* holder_klass = dest_method->holder();
if (!holder_klass->is_being_initialized() &&
!holder_klass->is_initialized() &&
!holder_klass->is_interface()) {
uncommon_trap(Deoptimization::Reason_uninitialized,
Deoptimization::Action_reinterpret,
holder_klass);
return true;
}
assert(dest_method->is_loaded(), "dest_method: typeflow responsibility");
return false;
}
//------------------------------do_call----------------------------------------
// Handle your basic call. Inline if we can & want to, else just setup call.
void Parse::do_call() {
// It's likely we are going to add debug info soon.
// Also, if we inline a guy who eventually needs debug info for this JVMS,
// our contribution to it is cleaned up right here.
kill_dead_locals();
// Set frequently used booleans
const bool is_virtual = bc() == Bytecodes::_invokevirtual;
const bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface;
const bool has_receiver = Bytecodes::has_receiver(bc());
// Find target being called
bool will_link;
ciSignature* declared_signature = NULL;
ciMethod* orig_callee = iter().get_method(will_link, &declared_signature); // callee in the bytecode
ciInstanceKlass* holder_klass = orig_callee->holder();
ciKlass* holder = iter().get_declared_method_holder();
ciInstanceKlass* klass = ciEnv::get_instance_klass_for_declared_method_holder(holder);
assert(declared_signature != NULL, "cannot be null");
// uncommon-trap when callee is unloaded, uninitialized or will not link
// bailout when too many arguments for register representation
if (!will_link || can_not_compile_call_site(orig_callee, klass)) {
#ifndef PRODUCT
if (PrintOpto && (Verbose || WizardMode)) {
method()->print_name(); tty->print_cr(" can not compile call at bci %d to:", bci());
orig_callee->print_name(); tty->cr();
}
#endif
return;
}
assert(holder_klass->is_loaded(), "");
//assert((bc_callee->is_static() || is_invokedynamic) == !has_receiver , "must match bc"); // XXX invokehandle (cur_bc_raw)
// Note: this takes into account invokeinterface of methods declared in java/lang/Object,
// which should be invokevirtuals but according to the VM spec may be invokeinterfaces
assert(holder_klass->is_interface() || holder_klass->super() == NULL || (bc() != Bytecodes::_invokeinterface), "must match bc");
// Note: In the absence of miranda methods, an abstract class K can perform
// an invokevirtual directly on an interface method I.m if K implements I.
// orig_callee is the resolved callee which's signature includes the
// appendix argument.
const int nargs = orig_callee->arg_size();
const bool is_signature_polymorphic = MethodHandles::is_signature_polymorphic(orig_callee->intrinsic_id());
// Push appendix argument (MethodType, CallSite, etc.), if one.
if (iter().has_appendix()) {
ciObject* appendix_arg = iter().get_appendix();
const TypeOopPtr* appendix_arg_type = TypeOopPtr::make_from_constant(appendix_arg);
Node* appendix_arg_node = _gvn.makecon(appendix_arg_type);
push(appendix_arg_node);
}
// ---------------------
// Does Class Hierarchy Analysis reveal only a single target of a v-call?
// Then we may inline or make a static call, but become dependent on there being only 1 target.
// Does the call-site type profile reveal only one receiver?
// Then we may introduce a run-time check and inline on the path where it succeeds.
// The other path may uncommon_trap, check for another receiver, or do a v-call.
// Try to get the most accurate receiver type
ciMethod* callee = orig_callee;
int vtable_index = Method::invalid_vtable_index;
bool call_does_dispatch = false;
// Speculative type of the receiver if any
ciKlass* speculative_receiver_type = NULL;
if (is_virtual_or_interface) {
Node* receiver_node = stack(sp() - nargs);
const TypeOopPtr* receiver_type = _gvn.type(receiver_node)->isa_oopptr();
// call_does_dispatch and vtable_index are out-parameters. They might be changed.
callee = C->optimize_virtual_call(method(), bci(), klass, orig_callee, receiver_type,
is_virtual,
call_does_dispatch, vtable_index); // out-parameters
speculative_receiver_type = receiver_type != NULL ? receiver_type->speculative_type() : NULL;
}
// Note: It's OK to try to inline a virtual call.
// The call generator will not attempt to inline a polymorphic call
// unless it knows how to optimize the receiver dispatch.
bool try_inline = (C->do_inlining() || InlineAccessors);
// ---------------------
dec_sp(nargs); // Temporarily pop args for JVM state of call
JVMState* jvms = sync_jvms();
// ---------------------
// Decide call tactic.
// This call checks with CHA, the interpreter profile, intrinsics table, etc.
// It decides whether inlining is desirable or not.
CallGenerator* cg = C->call_generator(callee, vtable_index, call_does_dispatch, jvms, try_inline, prof_factor(), speculative_receiver_type);
// NOTE: Don't use orig_callee and callee after this point! Use cg->method() instead.
orig_callee = callee = NULL;
// ---------------------
// Round double arguments before call
round_double_arguments(cg->method());
// Feed profiling data for arguments to the type system so it can
// propagate it as speculative types
record_profiled_arguments_for_speculation(cg->method(), bc());
#ifndef PRODUCT
// bump global counters for calls
count_compiled_calls(/*at_method_entry*/ false, cg->is_inline());
// Record first part of parsing work for this call
parse_histogram()->record_change();
#endif // not PRODUCT
assert(jvms == this->jvms(), "still operating on the right JVMS");
assert(jvms_in_sync(), "jvms must carry full info into CG");
// save across call, for a subsequent cast_not_null.
Node* receiver = has_receiver ? argument(0) : NULL;
// The extra CheckCastPP for speculative types mess with PhaseStringOpts
if (receiver != NULL && !call_does_dispatch && !cg->is_string_late_inline()) {
// Feed profiling data for a single receiver to the type system so
// it can propagate it as a speculative type
receiver = record_profiled_receiver_for_speculation(receiver);
}
// Bump method data counters (We profile *before* the call is made
// because exceptions don't return to the call site.)
profile_call(receiver);
JVMState* new_jvms = cg->generate(jvms, this);
if (new_jvms == NULL) {
// When inlining attempt fails (e.g., too many arguments),
// it may contaminate the current compile state, making it
// impossible to pull back and try again. Once we call
// cg->generate(), we are committed. If it fails, the whole
// compilation task is compromised.
if (failing()) return;
// This can happen if a library intrinsic is available, but refuses
// the call site, perhaps because it did not match a pattern the
// intrinsic was expecting to optimize. Should always be possible to
// get a normal java call that may inline in that case
cg = C->call_generator(cg->method(), vtable_index, call_does_dispatch, jvms, try_inline, prof_factor(), speculative_receiver_type, /* allow_intrinsics= */ false);
if ((new_jvms = cg->generate(jvms, this)) == NULL) {
guarantee(failing(), "call failed to generate: calls should work");
return;
}
}
if (cg->is_inline()) {
// Accumulate has_loops estimate
C->set_has_loops(C->has_loops() || cg->method()->has_loops());
C->env()->notice_inlined_method(cg->method());
}
// Reset parser state from [new_]jvms, which now carries results of the call.
// Return value (if any) is already pushed on the stack by the cg.
add_exception_states_from(new_jvms);
if (new_jvms->map()->control() == top()) {
stop_and_kill_map();
} else {
assert(new_jvms->same_calls_as(jvms), "method/bci left unchanged");
set_jvms(new_jvms);
}
if (!stopped()) {
// This was some sort of virtual call, which did a null check for us.
// Now we can assert receiver-not-null, on the normal return path.
if (receiver != NULL && cg->is_virtual()) {
Node* cast = cast_not_null(receiver);
// %%% assert(receiver == cast, "should already have cast the receiver");
}
// Round double result after a call from strict to non-strict code
round_double_result(cg->method());
ciType* rtype = cg->method()->return_type();
ciType* ctype = declared_signature->return_type();
if (Bytecodes::has_optional_appendix(iter().cur_bc_raw()) || is_signature_polymorphic) {
// Be careful here with return types.
if (ctype != rtype) {
BasicType rt = rtype->basic_type();
BasicType ct = ctype->basic_type();
if (ct == T_VOID) {
// It's OK for a method to return a value that is discarded.
// The discarding does not require any special action from the caller.
// The Java code knows this, at VerifyType.isNullConversion.
pop_node(rt); // whatever it was, pop it
} else if (rt == T_INT || is_subword_type(rt)) {
// Nothing. These cases are handled in lambda form bytecode.
assert(ct == T_INT || is_subword_type(ct), err_msg_res("must match: rt=%s, ct=%s", type2name(rt), type2name(ct)));
} else if (rt == T_OBJECT || rt == T_ARRAY) {
assert(ct == T_OBJECT || ct == T_ARRAY, err_msg_res("rt=%s, ct=%s", type2name(rt), type2name(ct)));
if (ctype->is_loaded()) {
const TypeOopPtr* arg_type = TypeOopPtr::make_from_klass(rtype->as_klass());
const Type* sig_type = TypeOopPtr::make_from_klass(ctype->as_klass());
if (arg_type != NULL && !arg_type->higher_equal(sig_type)) {
Node* retnode = pop();
Node* cast_obj = _gvn.transform(new (C) CheckCastPPNode(control(), retnode, sig_type));
push(cast_obj);
}
}
} else {
assert(rt == ct, err_msg_res("unexpected mismatch: rt=%s, ct=%s", type2name(rt), type2name(ct)));
// push a zero; it's better than getting an oop/int mismatch
pop_node(rt);
Node* retnode = zerocon(ct);
push_node(ct, retnode);
}
// Now that the value is well-behaved, continue with the call-site type.
rtype = ctype;
}
} else {
// Symbolic resolution enforces the types to be the same.
// NOTE: We must relax the assert for unloaded types because two
// different ciType instances of the same unloaded class type
// can appear to be "loaded" by different loaders (depending on
// the accessing class).
assert(!rtype->is_loaded() || !ctype->is_loaded() || rtype == ctype,
err_msg_res("mismatched return types: rtype=%s, ctype=%s", rtype->name(), ctype->name()));
}
// If the return type of the method is not loaded, assert that the
// value we got is a null. Otherwise, we need to recompile.
if (!rtype->is_loaded()) {
#ifndef PRODUCT
if (PrintOpto && (Verbose || WizardMode)) {
method()->print_name(); tty->print_cr(" asserting nullness of result at bci: %d", bci());
cg->method()->print_name(); tty->cr();
}
#endif
if (C->log() != NULL) {
C->log()->elem("assert_null reason='return' klass='%d'",
C->log()->identify(rtype));
}
// If there is going to be a trap, put it at the next bytecode:
set_bci(iter().next_bci());
null_assert(peek());
set_bci(iter().cur_bci()); // put it back
}
BasicType ct = ctype->basic_type();
if (ct == T_OBJECT || ct == T_ARRAY) {
ciKlass* better_type = method()->return_profiled_type(bci());
if (UseTypeSpeculation && better_type != NULL) {
// If profiling reports a single type for the return value,
// feed it to the type system so it can propagate it as a
// speculative type
record_profile_for_speculation(stack(sp()-1), better_type);
}
}
}
// Restart record of parsing work after possible inlining of call
#ifndef PRODUCT
parse_histogram()->set_initial_state(bc());
#endif
}
//---------------------------catch_call_exceptions-----------------------------
// Put a Catch and CatchProj nodes behind a just-created call.
// Send their caught exceptions to the proper handler.
// This may be used after a call to the rethrow VM stub,
// when it is needed to process unloaded exception classes.
void Parse::catch_call_exceptions(ciExceptionHandlerStream& handlers) {
// Exceptions are delivered through this channel:
Node* i_o = this->i_o();
// Add a CatchNode.
GrowableArray<int>* bcis = new (C->node_arena()) GrowableArray
Other Java examples (source code examples)Here is a short list of links related to this Java doCall.cpp source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.