3042 assert(frequency == 0 || is_power_of_2(frequency + 1), "Frequency must be x^2 - 1 or 0"); |
3042 assert(frequency == 0 || is_power_of_2(frequency + 1), "Frequency must be x^2 - 1 or 0"); |
3043 int level = _compilation->env()->comp_level(); |
3043 int level = _compilation->env()->comp_level(); |
3044 assert(level > CompLevel_simple, "Shouldn't be here"); |
3044 assert(level > CompLevel_simple, "Shouldn't be here"); |
3045 |
3045 |
3046 int offset = -1; |
3046 int offset = -1; |
3047 LIR_Opr counter_holder = new_register(T_METADATA); |
3047 LIR_Opr counter_holder; |
3048 LIR_Opr meth; |
|
3049 if (level == CompLevel_limited_profile) { |
3048 if (level == CompLevel_limited_profile) { |
3050 offset = in_bytes(backedge ? Method::backedge_counter_offset() : |
3049 address counters_adr = method->ensure_method_counters(); |
3051 Method::invocation_counter_offset()); |
3050 counter_holder = new_pointer_register(); |
3052 __ metadata2reg(method->constant_encoding(), counter_holder); |
3051 __ move(LIR_OprFact::intptrConst(counters_adr), counter_holder); |
3053 meth = counter_holder; |
3052 offset = in_bytes(backedge ? MethodCounters::backedge_counter_offset() : |
|
3053 MethodCounters::invocation_counter_offset()); |
3054 } else if (level == CompLevel_full_profile) { |
3054 } else if (level == CompLevel_full_profile) { |
|
3055 counter_holder = new_register(T_METADATA); |
3055 offset = in_bytes(backedge ? MethodData::backedge_counter_offset() : |
3056 offset = in_bytes(backedge ? MethodData::backedge_counter_offset() : |
3056 MethodData::invocation_counter_offset()); |
3057 MethodData::invocation_counter_offset()); |
3057 ciMethodData* md = method->method_data_or_null(); |
3058 ciMethodData* md = method->method_data_or_null(); |
3058 assert(md != NULL, "Sanity"); |
3059 assert(md != NULL, "Sanity"); |
3059 __ metadata2reg(md->constant_encoding(), counter_holder); |
3060 __ metadata2reg(md->constant_encoding(), counter_holder); |
3060 meth = new_register(T_METADATA); |
|
3061 __ metadata2reg(method->constant_encoding(), meth); |
|
3062 } else { |
3061 } else { |
3063 ShouldNotReachHere(); |
3062 ShouldNotReachHere(); |
3064 } |
3063 } |
3065 LIR_Address* counter = new LIR_Address(counter_holder, offset, T_INT); |
3064 LIR_Address* counter = new LIR_Address(counter_holder, offset, T_INT); |
3066 LIR_Opr result = new_register(T_INT); |
3065 LIR_Opr result = new_register(T_INT); |
3067 __ load(counter, result); |
3066 __ load(counter, result); |
3068 __ add(result, LIR_OprFact::intConst(InvocationCounter::count_increment), result); |
3067 __ add(result, LIR_OprFact::intConst(InvocationCounter::count_increment), result); |
3069 __ store(result, counter); |
3068 __ store(result, counter); |
3070 if (notify) { |
3069 if (notify) { |
3071 LIR_Opr mask = load_immediate(frequency << InvocationCounter::count_shift, T_INT); |
3070 LIR_Opr mask = load_immediate(frequency << InvocationCounter::count_shift, T_INT); |
|
3071 LIR_Opr meth = new_register(T_METADATA); |
|
3072 __ metadata2reg(method->constant_encoding(), meth); |
3072 __ logical_and(result, mask, result); |
3073 __ logical_and(result, mask, result); |
3073 __ cmp(lir_cond_equal, result, LIR_OprFact::intConst(0)); |
3074 __ cmp(lir_cond_equal, result, LIR_OprFact::intConst(0)); |
3074 // The bci for info can point to cmp for if's we want the if bci |
3075 // The bci for info can point to cmp for if's we want the if bci |
3075 CodeStub* overflow = new CounterOverflowStub(info, bci, meth); |
3076 CodeStub* overflow = new CounterOverflowStub(info, bci, meth); |
3076 __ branch(lir_cond_equal, T_INT, overflow); |
3077 __ branch(lir_cond_equal, T_INT, overflow); |