src/share/vm/interpreter/invocationCounter.cpp

changeset 2138
d5d065957597
parent 1907
c18cbe5936b8
child 2314
f95d63e2154a
equal deleted inserted replaced
2137:f353275af40e 2138:d5d065957597
1 /* 1 /*
2 * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2010, 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.
38 // been executed 38 // been executed
39 set_state(wait_for_compile); 39 set_state(wait_for_compile);
40 } 40 }
41 41
42 void InvocationCounter::set_carry() { 42 void InvocationCounter::set_carry() {
43 _counter |= carry_mask; 43 set_carry_flag();
44
45 // The carry bit now indicates that this counter had achieved a very 44 // The carry bit now indicates that this counter had achieved a very
46 // large value. Now reduce the value, so that the method can be 45 // large value. Now reduce the value, so that the method can be
47 // executed many more times before re-entering the VM. 46 // executed many more times before re-entering the VM.
48 int old_count = count(); 47 int old_count = count();
49 int new_count = MIN2(old_count, (int) (CompileThreshold / 2)); 48 int new_count = MIN2(old_count, (int) (CompileThreshold / 2));
50 // prevent from going to zero, to distinguish from never-executed methods 49 // prevent from going to zero, to distinguish from never-executed methods
51 if (new_count == 0) new_count = 1; 50 if (new_count == 0) new_count = 1;
52 if (old_count != new_count) set(state(), new_count); 51 if (old_count != new_count) set(state(), new_count);
53 } 52 }
54
55 53
56 void InvocationCounter::set_state(State state) { 54 void InvocationCounter::set_state(State state) {
57 assert(0 <= state && state < number_of_states, "illegal state"); 55 assert(0 <= state && state < number_of_states, "illegal state");
58 int init = _init[state]; 56 int init = _init[state];
59 // prevent from going to zero, to distinguish from never-executed methods 57 // prevent from going to zero, to distinguish from never-executed methods
79 int InvocationCounter::_init [InvocationCounter::number_of_states]; 77 int InvocationCounter::_init [InvocationCounter::number_of_states];
80 InvocationCounter::Action InvocationCounter::_action[InvocationCounter::number_of_states]; 78 InvocationCounter::Action InvocationCounter::_action[InvocationCounter::number_of_states];
81 int InvocationCounter::InterpreterInvocationLimit; 79 int InvocationCounter::InterpreterInvocationLimit;
82 int InvocationCounter::InterpreterBackwardBranchLimit; 80 int InvocationCounter::InterpreterBackwardBranchLimit;
83 int InvocationCounter::InterpreterProfileLimit; 81 int InvocationCounter::InterpreterProfileLimit;
84
85 // Tier1 limits
86 int InvocationCounter::Tier1InvocationLimit;
87 int InvocationCounter::Tier1BackEdgeLimit;
88
89 82
90 83
91 const char* InvocationCounter::state_as_string(State state) { 84 const char* InvocationCounter::state_as_string(State state) {
92 switch (state) { 85 switch (state) {
93 case wait_for_nothing : return "wait_for_nothing"; 86 case wait_for_nothing : return "wait_for_nothing";
144 def(wait_for_compile, 0, dummy_invocation_counter_overflow); 137 def(wait_for_compile, 0, dummy_invocation_counter_overflow);
145 } 138 }
146 139
147 InterpreterInvocationLimit = CompileThreshold << number_of_noncount_bits; 140 InterpreterInvocationLimit = CompileThreshold << number_of_noncount_bits;
148 InterpreterProfileLimit = ((CompileThreshold * InterpreterProfilePercentage) / 100)<< number_of_noncount_bits; 141 InterpreterProfileLimit = ((CompileThreshold * InterpreterProfilePercentage) / 100)<< number_of_noncount_bits;
149 Tier1InvocationLimit = Tier2CompileThreshold << number_of_noncount_bits;
150 Tier1BackEdgeLimit = Tier2BackEdgeThreshold << number_of_noncount_bits;
151 142
152 // When methodData is collected, the backward branch limit is compared against a 143 // When methodData is collected, the backward branch limit is compared against a
153 // methodData counter, rather than an InvocationCounter. In the former case, we 144 // methodData counter, rather than an InvocationCounter. In the former case, we
154 // don't need the shift by number_of_noncount_bits, but we do need to adjust 145 // don't need the shift by number_of_noncount_bits, but we do need to adjust
155 // the factor by which we scale the threshold. 146 // the factor by which we scale the threshold.

mercurial