Mercurial > hg > graal-compiler
diff src/share/vm/c1/c1_Optimizer.cpp @ 1819:f02a8bbe6ed4
6986046: C1 valuestack cleanup
Summary: fixes an historical oddity in C1 with inlining where all of the expression stacks are kept in the topmost ValueStack instead of being in their respective ValueStacks.
Reviewed-by: never
Contributed-by: Christian Wimmer <cwimmer@uci.edu>
author | roland |
---|---|
date | Tue, 29 Dec 2009 19:08:54 +0100 |
parents | d5d065957597 |
children | 42a10fc37986 |
line wrap: on
line diff
--- a/src/share/vm/c1/c1_Optimizer.cpp Wed Sep 22 23:51:03 2010 -0700 +++ b/src/share/vm/c1/c1_Optimizer.cpp Tue Dec 29 19:08:54 2009 +0100 @@ -140,25 +140,27 @@ // with an IfOp followed by a Goto // cut if_ away and get node before Instruction* cur_end = if_->prev(block); - int bci = if_->bci(); // append constants of true- and false-block if necessary // clone constants because original block must not be destroyed assert((t_value != f_const && f_value != t_const) || t_const == f_const, "mismatch"); if (t_value == t_const) { t_value = new Constant(t_const->type()); - cur_end = cur_end->set_next(t_value, bci); + NOT_PRODUCT(t_value->set_printable_bci(if_->printable_bci())); + cur_end = cur_end->set_next(t_value); } if (f_value == f_const) { f_value = new Constant(f_const->type()); - cur_end = cur_end->set_next(f_value, bci); + NOT_PRODUCT(f_value->set_printable_bci(if_->printable_bci())); + cur_end = cur_end->set_next(f_value); } // it is very unlikely that the condition can be statically decided // (this was checked previously by the Canonicalizer), so always // append IfOp Value result = new IfOp(if_->x(), if_->cond(), if_->y(), t_value, f_value); - cur_end = cur_end->set_next(result, bci); + NOT_PRODUCT(result->set_printable_bci(if_->printable_bci())); + cur_end = cur_end->set_next(result); // append Goto to successor ValueStack* state_before = if_->is_safepoint() ? if_->state_before() : NULL; @@ -167,16 +169,15 @@ // prepare state for Goto ValueStack* goto_state = if_->state(); while (sux_state->scope() != goto_state->scope()) { - goto_state = goto_state->pop_scope(); + goto_state = goto_state->caller_state(); assert(goto_state != NULL, "states do not match up"); } - goto_state = goto_state->copy(); + goto_state = goto_state->copy(ValueStack::StateAfter, goto_state->bci()); goto_state->push(result->type(), result); - assert(goto_state->is_same_across_scopes(sux_state), "states must match now"); + assert(goto_state->is_same(sux_state), "states must match now"); goto_->set_state(goto_state); - // Steal the bci for the goto from the sux - cur_end = cur_end->set_next(goto_, sux->bci()); + cur_end = cur_end->set_next(goto_, goto_state->bci()); // Adjust control flow graph BlockBegin::disconnect_edge(block, t_block); @@ -251,10 +252,8 @@ // no phi functions must be present at beginning of sux ValueStack* sux_state = sux->state(); ValueStack* end_state = end->state(); - while (end_state->scope() != sux_state->scope()) { - // match up inlining level - end_state = end_state->pop_scope(); - } + + assert(end_state->scope() == sux_state->scope(), "scopes must match"); assert(end_state->stack_size() == sux_state->stack_size(), "stack not equal"); assert(end_state->locals_size() == sux_state->locals_size(), "locals not equal"); @@ -273,7 +272,7 @@ Instruction* prev = end->prev(block); Instruction* next = sux->next(); assert(prev->as_BlockEnd() == NULL, "must not be a BlockEnd"); - prev->set_next(next, next->bci()); + prev->set_next(next); sux->disconnect_from_graph(); block->set_end(sux->end()); // add exception handlers of deleted block, if any @@ -337,7 +336,8 @@ newif->set_state(if_->state()->copy()); assert(prev->next() == if_, "must be guaranteed by above search"); - prev->set_next(newif, if_->bci()); + NOT_PRODUCT(newif->set_printable_bci(if_->printable_bci())); + prev->set_next(newif); block->set_end(newif); _merge_count++; @@ -705,7 +705,7 @@ // visiting instructions which are references in other blocks or // visiting instructions more than once. mark_visitable(instr); - if (instr->is_root() || instr->can_trap() || (instr->as_NullCheck() != NULL)) { + if (instr->is_pinned() || instr->can_trap() || (instr->as_NullCheck() != NULL)) { mark_visited(instr); instr->input_values_do(this); instr->visit(&_visitor);