3231 ciKlass* exact = profile_type(md, md->byte_offset_of_slot(data, ret->type_offset()), 0, 3232 ret->type(), x->ret(), mdp, 3233 !x->needs_null_check(), 3234 signature_at_call->return_type()->as_klass(), 3235 x->callee()->signature()->return_type()->as_klass()); 3236 if (exact != NULL) { 3237 md->set_return_type(bci, exact); 3238 } 3239 } 3240 } 3241 3242 void LIRGenerator::do_ProfileInvoke(ProfileInvoke* x) { 3243 // We can safely ignore accessors here, since c2 will inline them anyway, 3244 // accessors are also always mature. 3245 if (!x->inlinee()->is_accessor()) { 3246 CodeEmitInfo* info = state_for(x, x->state(), true); 3247 // Notify the runtime very infrequently only to take care of counter overflows 3248 int freq_log = Tier23InlineeNotifyFreqLog; 3249 double scale; 3250 if (_method->has_option_value("CompileThresholdScaling", scale)) { 3251 freq_log = Arguments::scaled_freq_log(freq_log, scale); 3252 } 3253 increment_event_counter_impl(info, x->inlinee(), right_n_bits(freq_log), InvocationEntryBci, false, true); 3254 } 3255 } 3256 3257 void LIRGenerator::increment_event_counter(CodeEmitInfo* info, int bci, bool backedge) { 3258 int freq_log = 0; 3259 int level = compilation()->env()->comp_level(); 3260 if (level == CompLevel_limited_profile) { 3261 freq_log = (backedge ? Tier2BackedgeNotifyFreqLog : Tier2InvokeNotifyFreqLog); 3262 } else if (level == CompLevel_full_profile) { 3263 freq_log = (backedge ? Tier3BackedgeNotifyFreqLog : Tier3InvokeNotifyFreqLog); 3264 } else { 3265 ShouldNotReachHere(); 3266 } 3267 // Increment the appropriate invocation/backedge counter and notify the runtime. 3268 double scale; 3269 if (_method->has_option_value("CompileThresholdScaling", scale)) { 3270 freq_log = Arguments::scaled_freq_log(freq_log, scale); 3271 } 3272 increment_event_counter_impl(info, info->scope()->method(), right_n_bits(freq_log), bci, backedge, true); 3273 } 3274 3275 void LIRGenerator::decrement_age(CodeEmitInfo* info) { 3276 ciMethod* method = info->scope()->method(); 3277 MethodCounters* mc_adr = method->ensure_method_counters(); 3278 if (mc_adr != NULL) { 3279 LIR_Opr mc = new_pointer_register(); 3280 __ move(LIR_OprFact::intptrConst(mc_adr), mc); 3281 int offset = in_bytes(MethodCounters::nmethod_age_offset()); 3282 LIR_Address* counter = new LIR_Address(mc, offset, T_INT); 3283 LIR_Opr result = new_register(T_INT); 3284 __ load(counter, result); 3285 __ sub(result, LIR_OprFact::intConst(1), result); 3286 __ store(result, counter); 3287 // DeoptimizeStub will reexecute from the current state in code info. 3288 CodeStub* deopt = new DeoptimizeStub(info, Deoptimization::Reason_tenured, 3289 Deoptimization::Action_make_not_entrant); 3290 __ cmp(lir_cond_lessEqual, result, LIR_OprFact::intConst(0)); | 3231 ciKlass* exact = profile_type(md, md->byte_offset_of_slot(data, ret->type_offset()), 0, 3232 ret->type(), x->ret(), mdp, 3233 !x->needs_null_check(), 3234 signature_at_call->return_type()->as_klass(), 3235 x->callee()->signature()->return_type()->as_klass()); 3236 if (exact != NULL) { 3237 md->set_return_type(bci, exact); 3238 } 3239 } 3240 } 3241 3242 void LIRGenerator::do_ProfileInvoke(ProfileInvoke* x) { 3243 // We can safely ignore accessors here, since c2 will inline them anyway, 3244 // accessors are also always mature. 3245 if (!x->inlinee()->is_accessor()) { 3246 CodeEmitInfo* info = state_for(x, x->state(), true); 3247 // Notify the runtime very infrequently only to take care of counter overflows 3248 int freq_log = Tier23InlineeNotifyFreqLog; 3249 double scale; 3250 if (_method->has_option_value("CompileThresholdScaling", scale)) { 3251 freq_log = CompilerConfig::scaled_freq_log(freq_log, scale); 3252 } 3253 increment_event_counter_impl(info, x->inlinee(), right_n_bits(freq_log), InvocationEntryBci, false, true); 3254 } 3255 } 3256 3257 void LIRGenerator::increment_event_counter(CodeEmitInfo* info, int bci, bool backedge) { 3258 int freq_log = 0; 3259 int level = compilation()->env()->comp_level(); 3260 if (level == CompLevel_limited_profile) { 3261 freq_log = (backedge ? Tier2BackedgeNotifyFreqLog : Tier2InvokeNotifyFreqLog); 3262 } else if (level == CompLevel_full_profile) { 3263 freq_log = (backedge ? Tier3BackedgeNotifyFreqLog : Tier3InvokeNotifyFreqLog); 3264 } else { 3265 ShouldNotReachHere(); 3266 } 3267 // Increment the appropriate invocation/backedge counter and notify the runtime. 3268 double scale; 3269 if (_method->has_option_value("CompileThresholdScaling", scale)) { 3270 freq_log = CompilerConfig::scaled_freq_log(freq_log, scale); 3271 } 3272 increment_event_counter_impl(info, info->scope()->method(), right_n_bits(freq_log), bci, backedge, true); 3273 } 3274 3275 void LIRGenerator::decrement_age(CodeEmitInfo* info) { 3276 ciMethod* method = info->scope()->method(); 3277 MethodCounters* mc_adr = method->ensure_method_counters(); 3278 if (mc_adr != NULL) { 3279 LIR_Opr mc = new_pointer_register(); 3280 __ move(LIR_OprFact::intptrConst(mc_adr), mc); 3281 int offset = in_bytes(MethodCounters::nmethod_age_offset()); 3282 LIR_Address* counter = new LIR_Address(mc, offset, T_INT); 3283 LIR_Opr result = new_register(T_INT); 3284 __ load(counter, result); 3285 __ sub(result, LIR_OprFact::intConst(1), result); 3286 __ store(result, counter); 3287 // DeoptimizeStub will reexecute from the current state in code info. 3288 CodeStub* deopt = new DeoptimizeStub(info, Deoptimization::Reason_tenured, 3289 Deoptimization::Action_make_not_entrant); 3290 __ cmp(lir_cond_lessEqual, result, LIR_OprFact::intConst(0)); |