Tue, 13 Dec 2011 10:54:47 +0100
7114106: C1: assert(goto_state->is_same(sux_state)) failed: states must match now
Summary: fix C1's CEE to take inlining into account when the stacks in states are compared.
Reviewed-by: iveresov, never
src/share/vm/c1/c1_Optimizer.cpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/c1/c1_Optimizer.cpp Mon Dec 12 12:44:08 2011 -0800 1.2 +++ b/src/share/vm/c1/c1_Optimizer.cpp Tue Dec 13 10:54:47 2011 +0100 1.3 @@ -122,18 +122,25 @@ 1.4 if (sux != f_goto->default_sux()) return; 1.5 1.6 // check if at least one word was pushed on sux_state 1.7 + // inlining depths must match 1.8 + ValueStack* if_state = if_->state(); 1.9 ValueStack* sux_state = sux->state(); 1.10 - if (sux_state->stack_size() <= if_->state()->stack_size()) return; 1.11 + while (sux_state->scope() != if_state->scope()) { 1.12 + if_state = if_state->caller_state(); 1.13 + assert(if_state != NULL, "states do not match up"); 1.14 + } 1.15 + 1.16 + if (sux_state->stack_size() <= if_state->stack_size()) return; 1.17 1.18 // check if phi function is present at end of successor stack and that 1.19 // only this phi was pushed on the stack 1.20 - Value sux_phi = sux_state->stack_at(if_->state()->stack_size()); 1.21 + Value sux_phi = sux_state->stack_at(if_state->stack_size()); 1.22 if (sux_phi == NULL || sux_phi->as_Phi() == NULL || sux_phi->as_Phi()->block() != sux) return; 1.23 - if (sux_phi->type()->size() != sux_state->stack_size() - if_->state()->stack_size()) return; 1.24 + if (sux_phi->type()->size() != sux_state->stack_size() - if_state->stack_size()) return; 1.25 1.26 // get the values that were pushed in the true- and false-branch 1.27 - Value t_value = t_goto->state()->stack_at(if_->state()->stack_size()); 1.28 - Value f_value = f_goto->state()->stack_at(if_->state()->stack_size()); 1.29 + Value t_value = t_goto->state()->stack_at(if_state->stack_size()); 1.30 + Value f_value = f_goto->state()->stack_at(if_state->stack_size()); 1.31 1.32 // backend does not support floats 1.33 assert(t_value->type()->base() == f_value->type()->base(), "incompatible types"); 1.34 @@ -180,11 +187,7 @@ 1.35 Goto* goto_ = new Goto(sux, state_before, if_->is_safepoint() || t_goto->is_safepoint() || f_goto->is_safepoint()); 1.36 1.37 // prepare state for Goto 1.38 - ValueStack* goto_state = if_->state(); 1.39 - while (sux_state->scope() != goto_state->scope()) { 1.40 - goto_state = goto_state->caller_state(); 1.41 - assert(goto_state != NULL, "states do not match up"); 1.42 - } 1.43 + ValueStack* goto_state = if_state; 1.44 goto_state = goto_state->copy(ValueStack::StateAfter, goto_state->bci()); 1.45 goto_state->push(result->type(), result); 1.46 assert(goto_state->is_same(sux_state), "states must match now");