< prev index next >

src/share/vm/c1/c1_LIRGenerator.cpp

Print this page
rev 9031 : 8138892: C1: Improve counter overflow checking
Reviewed-by:


3401     counter_holder = new_pointer_register();
3402     __ move(LIR_OprFact::intptrConst(counters_adr), counter_holder);
3403     offset = in_bytes(backedge ? MethodCounters::backedge_counter_offset() :
3404                                  MethodCounters::invocation_counter_offset());
3405   } else if (level == CompLevel_full_profile) {
3406     counter_holder = new_register(T_METADATA);
3407     offset = in_bytes(backedge ? MethodData::backedge_counter_offset() :
3408                                  MethodData::invocation_counter_offset());
3409     ciMethodData* md = method->method_data_or_null();
3410     assert(md != NULL, "Sanity");
3411     __ metadata2reg(md->constant_encoding(), counter_holder);
3412   } else {
3413     ShouldNotReachHere();
3414   }
3415   LIR_Address* counter = new LIR_Address(counter_holder, offset, T_INT);
3416   LIR_Opr result = new_register(T_INT);
3417   __ load(counter, result);
3418   __ add(result, LIR_OprFact::intConst(InvocationCounter::count_increment), result);
3419   __ store(result, counter);
3420   if (notify) {
3421     LIR_Opr mask = load_immediate(frequency << InvocationCounter::count_shift, T_INT);
3422     LIR_Opr meth = new_register(T_METADATA);
3423     __ metadata2reg(method->constant_encoding(), meth);
3424     __ logical_and(result, mask, result);
3425     __ cmp(lir_cond_equal, result, LIR_OprFact::intConst(0));
3426     // The bci for info can point to cmp for if's we want the if bci
3427     CodeStub* overflow = new CounterOverflowStub(info, bci, meth);







3428     __ branch(lir_cond_equal, T_INT, overflow);

3429     __ branch_destination(overflow->continuation());
3430   }
3431 }
3432 
3433 void LIRGenerator::do_RuntimeCall(RuntimeCall* x) {
3434   LIR_OprList* args = new LIR_OprList(x->number_of_arguments());
3435   BasicTypeList* signature = new BasicTypeList(x->number_of_arguments());
3436 
3437   if (x->pass_thread()) {
3438     signature->append(LP64_ONLY(T_LONG) NOT_LP64(T_INT));    // thread
3439     args->append(getThreadPointer());
3440   }
3441 
3442   for (int i = 0; i < x->number_of_arguments(); i++) {
3443     Value a = x->argument_at(i);
3444     LIRItem* item = new LIRItem(a, this);
3445     item->load_item();
3446     args->append(item->result());
3447     signature->append(as_BasicType(a->type()));
3448   }




3401     counter_holder = new_pointer_register();
3402     __ move(LIR_OprFact::intptrConst(counters_adr), counter_holder);
3403     offset = in_bytes(backedge ? MethodCounters::backedge_counter_offset() :
3404                                  MethodCounters::invocation_counter_offset());
3405   } else if (level == CompLevel_full_profile) {
3406     counter_holder = new_register(T_METADATA);
3407     offset = in_bytes(backedge ? MethodData::backedge_counter_offset() :
3408                                  MethodData::invocation_counter_offset());
3409     ciMethodData* md = method->method_data_or_null();
3410     assert(md != NULL, "Sanity");
3411     __ metadata2reg(md->constant_encoding(), counter_holder);
3412   } else {
3413     ShouldNotReachHere();
3414   }
3415   LIR_Address* counter = new LIR_Address(counter_holder, offset, T_INT);
3416   LIR_Opr result = new_register(T_INT);
3417   __ load(counter, result);
3418   __ add(result, LIR_OprFact::intConst(InvocationCounter::count_increment), result);
3419   __ store(result, counter);
3420   if (notify) {
3421     LIR_Opr meth = LIR_OprFact::metadataConst(method->constant_encoding());




3422     // The bci for info can point to cmp for if's we want the if bci
3423     CodeStub* overflow = new CounterOverflowStub(info, bci, meth);
3424     int freq = frequency << InvocationCounter::count_shift;
3425     if (freq == 0) {
3426       __ branch(lir_cond_always, T_ILLEGAL, overflow);
3427     } else {
3428       LIR_Opr mask = load_immediate(freq, T_INT);
3429       __ logical_and(result, mask, result);
3430       __ cmp(lir_cond_equal, result, LIR_OprFact::intConst(0));
3431       __ branch(lir_cond_equal, T_INT, overflow);
3432     }
3433     __ branch_destination(overflow->continuation());
3434   }
3435 }
3436 
3437 void LIRGenerator::do_RuntimeCall(RuntimeCall* x) {
3438   LIR_OprList* args = new LIR_OprList(x->number_of_arguments());
3439   BasicTypeList* signature = new BasicTypeList(x->number_of_arguments());
3440 
3441   if (x->pass_thread()) {
3442     signature->append(LP64_ONLY(T_LONG) NOT_LP64(T_INT));    // thread
3443     args->append(getThreadPointer());
3444   }
3445 
3446   for (int i = 0; i < x->number_of_arguments(); i++) {
3447     Value a = x->argument_at(i);
3448     LIRItem* item = new LIRItem(a, this);
3449     item->load_item();
3450     args->append(item->result());
3451     signature->append(as_BasicType(a->type()));
3452   }


< prev index next >