3245 int freq_log = Tier23InlineeNotifyFreqLog; |
3245 int freq_log = Tier23InlineeNotifyFreqLog; |
3246 double scale; |
3246 double scale; |
3247 if (_method->has_option_value("CompileThresholdScaling", scale)) { |
3247 if (_method->has_option_value("CompileThresholdScaling", scale)) { |
3248 freq_log = Arguments::scaled_freq_log(freq_log, scale); |
3248 freq_log = Arguments::scaled_freq_log(freq_log, scale); |
3249 } |
3249 } |
3250 increment_event_counter_impl(info, x->inlinee(), right_n_bits(freq_log), InvocationEntryBci, false, true); |
3250 increment_event_counter_impl(info, x->inlinee(), LIR_OprFact::intConst(InvocationCounter::count_increment), right_n_bits(freq_log), InvocationEntryBci, false, true); |
3251 } |
3251 } |
3252 } |
3252 } |
3253 |
3253 |
3254 void LIRGenerator::increment_event_counter(CodeEmitInfo* info, int bci, bool backedge) { |
3254 void LIRGenerator::increment_backedge_counter_conditionally(LIR_Condition cond, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info, int left_bci, int right_bci, int bci) { |
|
3255 if (compilation()->count_backedges()) { |
|
3256 __ cmp(cond, left, right); |
|
3257 LIR_Opr step = new_register(T_INT); |
|
3258 LIR_Opr plus_one = LIR_OprFact::intConst(InvocationCounter::count_increment); |
|
3259 LIR_Opr zero = LIR_OprFact::intConst(0); |
|
3260 __ cmove(cond, |
|
3261 (left_bci < bci) ? plus_one : zero, |
|
3262 (right_bci < bci) ? plus_one : zero, |
|
3263 step, left->type()); |
|
3264 increment_backedge_counter(info, step, bci); |
|
3265 } |
|
3266 } |
|
3267 |
|
3268 |
|
3269 void LIRGenerator::increment_event_counter(CodeEmitInfo* info, LIR_Opr step, int bci, bool backedge) { |
3255 int freq_log = 0; |
3270 int freq_log = 0; |
3256 int level = compilation()->env()->comp_level(); |
3271 int level = compilation()->env()->comp_level(); |
3257 if (level == CompLevel_limited_profile) { |
3272 if (level == CompLevel_limited_profile) { |
3258 freq_log = (backedge ? Tier2BackedgeNotifyFreqLog : Tier2InvokeNotifyFreqLog); |
3273 freq_log = (backedge ? Tier2BackedgeNotifyFreqLog : Tier2InvokeNotifyFreqLog); |
3259 } else if (level == CompLevel_full_profile) { |
3274 } else if (level == CompLevel_full_profile) { |
3264 // Increment the appropriate invocation/backedge counter and notify the runtime. |
3279 // Increment the appropriate invocation/backedge counter and notify the runtime. |
3265 double scale; |
3280 double scale; |
3266 if (_method->has_option_value("CompileThresholdScaling", scale)) { |
3281 if (_method->has_option_value("CompileThresholdScaling", scale)) { |
3267 freq_log = Arguments::scaled_freq_log(freq_log, scale); |
3282 freq_log = Arguments::scaled_freq_log(freq_log, scale); |
3268 } |
3283 } |
3269 increment_event_counter_impl(info, info->scope()->method(), right_n_bits(freq_log), bci, backedge, true); |
3284 increment_event_counter_impl(info, info->scope()->method(), step, right_n_bits(freq_log), bci, backedge, true); |
3270 } |
3285 } |
3271 |
3286 |
3272 void LIRGenerator::decrement_age(CodeEmitInfo* info) { |
3287 void LIRGenerator::decrement_age(CodeEmitInfo* info) { |
3273 ciMethod* method = info->scope()->method(); |
3288 ciMethod* method = info->scope()->method(); |
3274 MethodCounters* mc_adr = method->ensure_method_counters(); |
3289 MethodCounters* mc_adr = method->ensure_method_counters(); |
3289 } |
3304 } |
3290 } |
3305 } |
3291 |
3306 |
3292 |
3307 |
3293 void LIRGenerator::increment_event_counter_impl(CodeEmitInfo* info, |
3308 void LIRGenerator::increment_event_counter_impl(CodeEmitInfo* info, |
3294 ciMethod *method, int frequency, |
3309 ciMethod *method, LIR_Opr step, int frequency, |
3295 int bci, bool backedge, bool notify) { |
3310 int bci, bool backedge, bool notify) { |
3296 assert(frequency == 0 || is_power_of_2(frequency + 1), "Frequency must be x^2 - 1 or 0"); |
3311 assert(frequency == 0 || is_power_of_2(frequency + 1), "Frequency must be x^2 - 1 or 0"); |
3297 int level = _compilation->env()->comp_level(); |
3312 int level = _compilation->env()->comp_level(); |
3298 assert(level > CompLevel_simple, "Shouldn't be here"); |
3313 assert(level > CompLevel_simple, "Shouldn't be here"); |
3299 |
3314 |
3320 ShouldNotReachHere(); |
3335 ShouldNotReachHere(); |
3321 } |
3336 } |
3322 LIR_Address* counter = new LIR_Address(counter_holder, offset, T_INT); |
3337 LIR_Address* counter = new LIR_Address(counter_holder, offset, T_INT); |
3323 LIR_Opr result = new_register(T_INT); |
3338 LIR_Opr result = new_register(T_INT); |
3324 __ load(counter, result); |
3339 __ load(counter, result); |
3325 __ add(result, LIR_OprFact::intConst(InvocationCounter::count_increment), result); |
3340 __ add(result, step, result); |
3326 __ store(result, counter); |
3341 __ store(result, counter); |
3327 if (notify && (!backedge || UseOnStackReplacement)) { |
3342 if (notify && (!backedge || UseOnStackReplacement)) { |
3328 LIR_Opr meth = LIR_OprFact::metadataConst(method->constant_encoding()); |
3343 LIR_Opr meth = LIR_OprFact::metadataConst(method->constant_encoding()); |
3329 // The bci for info can point to cmp for if's we want the if bci |
3344 // The bci for info can point to cmp for if's we want the if bci |
3330 CodeStub* overflow = new CounterOverflowStub(info, bci, meth); |
3345 CodeStub* overflow = new CounterOverflowStub(info, bci, meth); |
3331 int freq = frequency << InvocationCounter::count_shift; |
3346 int freq = frequency << InvocationCounter::count_shift; |
3332 if (freq == 0) { |
3347 if (freq == 0) { |
3333 __ branch(lir_cond_always, T_ILLEGAL, overflow); |
3348 if (!step->is_constant()) { |
|
3349 __ cmp(lir_cond_notEqual, step, LIR_OprFact::intConst(0)); |
|
3350 __ branch(lir_cond_notEqual, T_ILLEGAL, overflow); |
|
3351 } else { |
|
3352 __ branch(lir_cond_always, T_ILLEGAL, overflow); |
|
3353 } |
3334 } else { |
3354 } else { |
3335 LIR_Opr mask = load_immediate(freq, T_INT); |
3355 LIR_Opr mask = load_immediate(freq, T_INT); |
|
3356 if (!step->is_constant()) { |
|
3357 // If step is 0, make sure the overflow check below always fails |
|
3358 __ cmp(lir_cond_notEqual, step, LIR_OprFact::intConst(0)); |
|
3359 __ cmove(lir_cond_notEqual, result, LIR_OprFact::intConst(InvocationCounter::count_increment), result, T_INT); |
|
3360 } |
3336 __ logical_and(result, mask, result); |
3361 __ logical_and(result, mask, result); |
3337 __ cmp(lir_cond_equal, result, LIR_OprFact::intConst(0)); |
3362 __ cmp(lir_cond_equal, result, LIR_OprFact::intConst(0)); |
3338 __ branch(lir_cond_equal, T_INT, overflow); |
3363 __ branch(lir_cond_equal, T_INT, overflow); |
3339 } |
3364 } |
3340 __ branch_destination(overflow->continuation()); |
3365 __ branch_destination(overflow->continuation()); |