comparison src/share/vm/c1/c1_LIRGenerator.cpp @ 10105:aeaca88565e6

8010862: The Method counter fields used for profiling can be allocated lazily. Summary: Allocate the method's profiling related metadata until they are needed. Reviewed-by: coleenp, roland
author jiangli
date Tue, 09 Apr 2013 17:17:41 -0400
parents d595e8ddadd9
children 8df6ddda8090
comparison
equal deleted inserted replaced
9055:dcdeb150988c 10105:aeaca88565e6
1 /* 1 /*
2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
3061 assert(frequency == 0 || is_power_of_2(frequency + 1), "Frequency must be x^2 - 1 or 0"); 3061 assert(frequency == 0 || is_power_of_2(frequency + 1), "Frequency must be x^2 - 1 or 0");
3062 int level = _compilation->env()->comp_level(); 3062 int level = _compilation->env()->comp_level();
3063 assert(level > CompLevel_simple, "Shouldn't be here"); 3063 assert(level > CompLevel_simple, "Shouldn't be here");
3064 3064
3065 int offset = -1; 3065 int offset = -1;
3066 LIR_Opr counter_holder = new_register(T_METADATA); 3066 LIR_Opr counter_holder;
3067 LIR_Opr meth;
3068 if (level == CompLevel_limited_profile) { 3067 if (level == CompLevel_limited_profile) {
3069 offset = in_bytes(backedge ? Method::backedge_counter_offset() : 3068 address counters_adr = method->ensure_method_counters();
3070 Method::invocation_counter_offset()); 3069 counter_holder = new_pointer_register();
3071 __ metadata2reg(method->constant_encoding(), counter_holder); 3070 __ move(LIR_OprFact::intptrConst(counters_adr), counter_holder);
3072 meth = counter_holder; 3071 offset = in_bytes(backedge ? MethodCounters::backedge_counter_offset() :
3072 MethodCounters::invocation_counter_offset());
3073 } else if (level == CompLevel_full_profile) { 3073 } else if (level == CompLevel_full_profile) {
3074 counter_holder = new_register(T_METADATA);
3074 offset = in_bytes(backedge ? MethodData::backedge_counter_offset() : 3075 offset = in_bytes(backedge ? MethodData::backedge_counter_offset() :
3075 MethodData::invocation_counter_offset()); 3076 MethodData::invocation_counter_offset());
3076 ciMethodData* md = method->method_data_or_null(); 3077 ciMethodData* md = method->method_data_or_null();
3077 assert(md != NULL, "Sanity"); 3078 assert(md != NULL, "Sanity");
3078 __ metadata2reg(md->constant_encoding(), counter_holder); 3079 __ metadata2reg(md->constant_encoding(), counter_holder);
3079 meth = new_register(T_METADATA);
3080 __ metadata2reg(method->constant_encoding(), meth);
3081 } else { 3080 } else {
3082 ShouldNotReachHere(); 3081 ShouldNotReachHere();
3083 } 3082 }
3084 LIR_Address* counter = new LIR_Address(counter_holder, offset, T_INT); 3083 LIR_Address* counter = new LIR_Address(counter_holder, offset, T_INT);
3085 LIR_Opr result = new_register(T_INT); 3084 LIR_Opr result = new_register(T_INT);
3086 __ load(counter, result); 3085 __ load(counter, result);
3087 __ add(result, LIR_OprFact::intConst(InvocationCounter::count_increment), result); 3086 __ add(result, LIR_OprFact::intConst(InvocationCounter::count_increment), result);
3088 __ store(result, counter); 3087 __ store(result, counter);
3089 if (notify) { 3088 if (notify) {
3090 LIR_Opr mask = load_immediate(frequency << InvocationCounter::count_shift, T_INT); 3089 LIR_Opr mask = load_immediate(frequency << InvocationCounter::count_shift, T_INT);
3090 LIR_Opr meth = new_register(T_METADATA);
3091 __ metadata2reg(method->constant_encoding(), meth);
3091 __ logical_and(result, mask, result); 3092 __ logical_and(result, mask, result);
3092 __ cmp(lir_cond_equal, result, LIR_OprFact::intConst(0)); 3093 __ cmp(lir_cond_equal, result, LIR_OprFact::intConst(0));
3093 // The bci for info can point to cmp for if's we want the if bci 3094 // The bci for info can point to cmp for if's we want the if bci
3094 CodeStub* overflow = new CounterOverflowStub(info, bci, meth); 3095 CodeStub* overflow = new CounterOverflowStub(info, bci, meth);
3095 __ branch(lir_cond_equal, T_INT, overflow); 3096 __ branch(lir_cond_equal, T_INT, overflow);