713 } else if (l->as_InstanceOf() != NULL) {
714 // NOTE: Code permanently disabled for now since it leaves the old InstanceOf
715 // instruction in the graph (it is pinned). Need to fix this at some point.
716 // It should also be left in the graph when generating a profiled method version or Goto
717 // has to know that it was an InstanceOf.
718 return;
719 // pattern: If ((obj instanceof klass) cond rc) => simplify to: IfInstanceOf or: Goto
720 InstanceOf* inst = l->as_InstanceOf();
721 BlockBegin* is_inst_sux = x->sux_for(is_true(1, x->cond(), rc)); // successor for instanceof == 1
722 BlockBegin* no_inst_sux = x->sux_for(is_true(0, x->cond(), rc)); // successor for instanceof == 0
723 if (is_inst_sux == no_inst_sux && inst->is_loaded()) {
724 // both successors identical and klass is loaded => simplify to: Goto
725 set_canonical(new Goto(is_inst_sux, x->state_before(), x->is_safepoint()));
726 } else {
727 // successors differ => simplify to: IfInstanceOf
728 set_canonical(new IfInstanceOf(inst->klass(), inst->obj(), true, inst->state_before()->bci(), is_inst_sux, no_inst_sux));
729 }
730 }
731 } else if (rt == objectNull &&
732 (l->as_NewInstance() || l->as_NewArray() ||
733 (UseNewCode && l->as_Local() && l->as_Local()->is_receiver()))) {
734 if (x->cond() == Instruction::eql) {
735 BlockBegin* sux = x->fsux();
736 set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux)));
737 } else {
738 assert(x->cond() == Instruction::neq, "only other valid case");
739 BlockBegin* sux = x->tsux();
740 set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux)));
741 }
742 }
743 }
744
745
746 void Canonicalizer::do_TableSwitch(TableSwitch* x) {
747 if (x->tag()->type()->is_constant()) {
748 int v = x->tag()->type()->as_IntConstant()->value();
749 BlockBegin* sux = x->default_sux();
750 if (v >= x->lo_key() && v <= x->hi_key()) {
751 sux = x->sux_at(v - x->lo_key());
752 }
753 set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux)));
|
713 } else if (l->as_InstanceOf() != NULL) {
714 // NOTE: Code permanently disabled for now since it leaves the old InstanceOf
715 // instruction in the graph (it is pinned). Need to fix this at some point.
716 // It should also be left in the graph when generating a profiled method version or Goto
717 // has to know that it was an InstanceOf.
718 return;
719 // pattern: If ((obj instanceof klass) cond rc) => simplify to: IfInstanceOf or: Goto
720 InstanceOf* inst = l->as_InstanceOf();
721 BlockBegin* is_inst_sux = x->sux_for(is_true(1, x->cond(), rc)); // successor for instanceof == 1
722 BlockBegin* no_inst_sux = x->sux_for(is_true(0, x->cond(), rc)); // successor for instanceof == 0
723 if (is_inst_sux == no_inst_sux && inst->is_loaded()) {
724 // both successors identical and klass is loaded => simplify to: Goto
725 set_canonical(new Goto(is_inst_sux, x->state_before(), x->is_safepoint()));
726 } else {
727 // successors differ => simplify to: IfInstanceOf
728 set_canonical(new IfInstanceOf(inst->klass(), inst->obj(), true, inst->state_before()->bci(), is_inst_sux, no_inst_sux));
729 }
730 }
731 } else if (rt == objectNull &&
732 (l->as_NewInstance() || l->as_NewArray() ||
733 (l->as_Local() && l->as_Local()->is_receiver()))) {
734 if (x->cond() == Instruction::eql) {
735 BlockBegin* sux = x->fsux();
736 set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux)));
737 } else {
738 assert(x->cond() == Instruction::neq, "only other valid case");
739 BlockBegin* sux = x->tsux();
740 set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux)));
741 }
742 }
743 }
744
745
746 void Canonicalizer::do_TableSwitch(TableSwitch* x) {
747 if (x->tag()->type()->is_constant()) {
748 int v = x->tag()->type()->as_IntConstant()->value();
749 BlockBegin* sux = x->default_sux();
750 if (v >= x->lo_key() && v <= x->hi_key()) {
751 sux = x->sux_at(v - x->lo_key());
752 }
753 set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux)));
|