comparison src/share/vm/c1/c1_Optimizer.cpp @ 4757:7bca37d28f32

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
author roland
date Tue, 13 Dec 2011 10:54:47 +0100
parents 15559220ce79
children e5ac210043cd
comparison
equal deleted inserted replaced
4756:abcceac2f7cd 4757:7bca37d28f32
120 // check if both gotos merge into the same block 120 // check if both gotos merge into the same block
121 BlockBegin* sux = t_goto->default_sux(); 121 BlockBegin* sux = t_goto->default_sux();
122 if (sux != f_goto->default_sux()) return; 122 if (sux != f_goto->default_sux()) return;
123 123
124 // check if at least one word was pushed on sux_state 124 // check if at least one word was pushed on sux_state
125 // inlining depths must match
126 ValueStack* if_state = if_->state();
125 ValueStack* sux_state = sux->state(); 127 ValueStack* sux_state = sux->state();
126 if (sux_state->stack_size() <= if_->state()->stack_size()) return; 128 while (sux_state->scope() != if_state->scope()) {
129 if_state = if_state->caller_state();
130 assert(if_state != NULL, "states do not match up");
131 }
132
133 if (sux_state->stack_size() <= if_state->stack_size()) return;
127 134
128 // check if phi function is present at end of successor stack and that 135 // check if phi function is present at end of successor stack and that
129 // only this phi was pushed on the stack 136 // only this phi was pushed on the stack
130 Value sux_phi = sux_state->stack_at(if_->state()->stack_size()); 137 Value sux_phi = sux_state->stack_at(if_state->stack_size());
131 if (sux_phi == NULL || sux_phi->as_Phi() == NULL || sux_phi->as_Phi()->block() != sux) return; 138 if (sux_phi == NULL || sux_phi->as_Phi() == NULL || sux_phi->as_Phi()->block() != sux) return;
132 if (sux_phi->type()->size() != sux_state->stack_size() - if_->state()->stack_size()) return; 139 if (sux_phi->type()->size() != sux_state->stack_size() - if_state->stack_size()) return;
133 140
134 // get the values that were pushed in the true- and false-branch 141 // get the values that were pushed in the true- and false-branch
135 Value t_value = t_goto->state()->stack_at(if_->state()->stack_size()); 142 Value t_value = t_goto->state()->stack_at(if_state->stack_size());
136 Value f_value = f_goto->state()->stack_at(if_->state()->stack_size()); 143 Value f_value = f_goto->state()->stack_at(if_state->stack_size());
137 144
138 // backend does not support floats 145 // backend does not support floats
139 assert(t_value->type()->base() == f_value->type()->base(), "incompatible types"); 146 assert(t_value->type()->base() == f_value->type()->base(), "incompatible types");
140 if (t_value->type()->is_float_kind()) return; 147 if (t_value->type()->is_float_kind()) return;
141 148
178 // append Goto to successor 185 // append Goto to successor
179 ValueStack* state_before = if_->is_safepoint() ? if_->state_before() : NULL; 186 ValueStack* state_before = if_->is_safepoint() ? if_->state_before() : NULL;
180 Goto* goto_ = new Goto(sux, state_before, if_->is_safepoint() || t_goto->is_safepoint() || f_goto->is_safepoint()); 187 Goto* goto_ = new Goto(sux, state_before, if_->is_safepoint() || t_goto->is_safepoint() || f_goto->is_safepoint());
181 188
182 // prepare state for Goto 189 // prepare state for Goto
183 ValueStack* goto_state = if_->state(); 190 ValueStack* goto_state = if_state;
184 while (sux_state->scope() != goto_state->scope()) {
185 goto_state = goto_state->caller_state();
186 assert(goto_state != NULL, "states do not match up");
187 }
188 goto_state = goto_state->copy(ValueStack::StateAfter, goto_state->bci()); 191 goto_state = goto_state->copy(ValueStack::StateAfter, goto_state->bci());
189 goto_state->push(result->type(), result); 192 goto_state->push(result->type(), result);
190 assert(goto_state->is_same(sux_state), "states must match now"); 193 assert(goto_state->is_same(sux_state), "states must match now");
191 goto_->set_state(goto_state); 194 goto_->set_state(goto_state);
192 195