8218031: Zero broken after JDK-8217922 (Compiler dead code removal)

Reviewed-by: thartmann, sgehwolf, shade
This commit is contained in:
Ao Qi 2019-01-30 18:34:31 +01:00 committed by Aleksey Shipilev
parent 4c17358fae
commit a0de7b80c9
2 changed files with 23 additions and 5 deletions

View File

@ -79,6 +79,10 @@ void InvocationCounter::print_short() {
int InvocationCounter::_init [InvocationCounter::number_of_states];
InvocationCounter::Action InvocationCounter::_action[InvocationCounter::number_of_states];
#ifdef CC_INTERP
int InvocationCounter::InterpreterInvocationLimit;
int InvocationCounter::InterpreterBackwardBranchLimit;
#endif
const char* InvocationCounter::state_as_string(State state) {
switch (state) {
@ -132,6 +136,22 @@ void InvocationCounter::reinitialize() {
guarantee((int)number_of_states <= (int)state_limit, "adjust number_of_state_bits");
def(wait_for_nothing, 0, do_nothing);
def(wait_for_compile, 0, do_decay);
#ifdef CC_INTERP
InterpreterInvocationLimit = CompileThreshold << number_of_noncount_bits;
// When methodData is collected, the backward branch limit is compared against a
// methodData counter, rather than an InvocationCounter. In the former case, we
// don't need the shift by number_of_noncount_bits, but we do need to adjust
// the factor by which we scale the threshold.
if (ProfileInterpreter) {
InterpreterBackwardBranchLimit = (int)((int64_t)CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage) / 100);
} else {
InterpreterBackwardBranchLimit = (int)(((int64_t)CompileThreshold * OnStackReplacePercentage / 100) << number_of_noncount_bits);
}
assert(0 <= InterpreterBackwardBranchLimit, "OSR threshold should be non-negative");
#endif
}
void invocationCounter_init() {

View File

@ -92,6 +92,9 @@ class InvocationCounter {
int count() const { return _counter >> number_of_noncount_bits; }
#ifdef CC_INTERP
static int InterpreterInvocationLimit; // CompileThreshold scaled for interpreter use
static int InterpreterBackwardBranchLimit; // A separate threshold for on stack replacement
// Test counter using scaled limits like the asm interpreter would do rather than doing
// the shifts to normalize the counter.
// Checks sum of invocation_counter and backedge_counter as the template interpreter does.
@ -103,11 +106,6 @@ class InvocationCounter {
return (_counter & count_mask) + (back_edge_count->_counter & count_mask) >=
(unsigned int) InterpreterBackwardBranchLimit;
}
// Do this just like asm interpreter does for max speed.
bool reached_ProfileLimit(InvocationCounter *back_edge_count) const {
return (_counter & count_mask) + (back_edge_count->_counter & count_mask) >=
(unsigned int) InterpreterProfileLimit;
}
#endif // CC_INTERP
void increment() { _counter += count_increment; }