810 set_state(new_state);
811
812 } else if (existing_state->is_same(new_state)) {
813 TRACE_PHI(tty->print_cr("exisiting state found"));
814
815 assert(existing_state->scope() == new_state->scope(), "not matching");
816 assert(existing_state->locals_size() == new_state->locals_size(), "not matching");
817 assert(existing_state->stack_size() == new_state->stack_size(), "not matching");
818
819 if (is_set(BlockBegin::was_visited_flag)) {
820 TRACE_PHI(tty->print_cr("loop header block, phis must be present"));
821
822 if (!is_set(BlockBegin::parser_loop_header_flag)) {
823 // this actually happens for complicated jsr/ret structures
824 return false; // BAILOUT in caller
825 }
826
827 for_each_local_value(existing_state, index, existing_value) {
828 Value new_value = new_state->local_at(index);
829 if (new_value == NULL || new_value->type()->tag() != existing_value->type()->tag()) {
830 // The old code invalidated the phi function here
831 // Because dead locals are replaced with NULL, this is a very rare case now, so simply bail out
832 return false; // BAILOUT in caller
833 }
834 }
835
836 #ifdef ASSERT
837 // check that all necessary phi functions are present
838 for_each_stack_value(existing_state, index, existing_value) {
839 assert(existing_value->as_Phi() != NULL && existing_value->as_Phi()->block() == this, "phi function required");
840 }
841 for_each_local_value(existing_state, index, existing_value) {
842 assert(existing_value == new_state->local_at(index) || (existing_value->as_Phi() != NULL && existing_value->as_Phi()->as_Phi()->block() == this), "phi function required");
843 }
844 #endif
845
846 } else {
847 TRACE_PHI(tty->print_cr("creating phi functions on demand"));
848
849 // create necessary phi functions for stack
850 for_each_stack_value(existing_state, index, existing_value) {
851 Value new_value = new_state->stack_at(index);
852 Phi* existing_phi = existing_value->as_Phi();
|
810 set_state(new_state);
811
812 } else if (existing_state->is_same(new_state)) {
813 TRACE_PHI(tty->print_cr("exisiting state found"));
814
815 assert(existing_state->scope() == new_state->scope(), "not matching");
816 assert(existing_state->locals_size() == new_state->locals_size(), "not matching");
817 assert(existing_state->stack_size() == new_state->stack_size(), "not matching");
818
819 if (is_set(BlockBegin::was_visited_flag)) {
820 TRACE_PHI(tty->print_cr("loop header block, phis must be present"));
821
822 if (!is_set(BlockBegin::parser_loop_header_flag)) {
823 // this actually happens for complicated jsr/ret structures
824 return false; // BAILOUT in caller
825 }
826
827 for_each_local_value(existing_state, index, existing_value) {
828 Value new_value = new_state->local_at(index);
829 if (new_value == NULL || new_value->type()->tag() != existing_value->type()->tag()) {
830 Phi* existing_phi = existing_value->as_Phi();
831 if (existing_phi == NULL) {
832 return false; // BAILOUT in caller
833 }
834 // Invalidate the phi function here. This case is very rare except for
835 // JVMTI capability "can_access_local_variables".
836 // In really rare cases we will bail out in LIRGenerator::move_to_phi.
837 existing_phi->make_illegal();
838 existing_state->invalidate_local(index);
839 TRACE_PHI(tty->print_cr("invalidating local %d because of type mismatch", index));
840 }
841 }
842
843 #ifdef ASSERT
844 // check that all necessary phi functions are present
845 for_each_stack_value(existing_state, index, existing_value) {
846 assert(existing_value->as_Phi() != NULL && existing_value->as_Phi()->block() == this, "phi function required");
847 }
848 for_each_local_value(existing_state, index, existing_value) {
849 assert(existing_value == new_state->local_at(index) || (existing_value->as_Phi() != NULL && existing_value->as_Phi()->as_Phi()->block() == this), "phi function required");
850 }
851 #endif
852
853 } else {
854 TRACE_PHI(tty->print_cr("creating phi functions on demand"));
855
856 // create necessary phi functions for stack
857 for_each_stack_value(existing_state, index, existing_value) {
858 Value new_value = new_state->stack_at(index);
859 Phi* existing_phi = existing_value->as_Phi();
|