src/share/vm/c1/c1_Canonicalizer.cpp

Print this page




 710         }
 711       }
 712     } else if (l->as_InstanceOf() != NULL) {
 713       // NOTE: Code permanently disabled for now since it leaves the old InstanceOf
 714       //       instruction in the graph (it is pinned). Need to fix this at some point.
 715       //       It should also be left in the graph when generating a profiled method version or Goto
 716       //       has to know that it was an InstanceOf.
 717       return;
 718       // pattern: If ((obj instanceof klass) cond rc) => simplify to: IfInstanceOf or: Goto
 719       InstanceOf* inst = l->as_InstanceOf();
 720       BlockBegin* is_inst_sux = x->sux_for(is_true(1, x->cond(), rc)); // successor for instanceof == 1
 721       BlockBegin* no_inst_sux = x->sux_for(is_true(0, x->cond(), rc)); // successor for instanceof == 0
 722       if (is_inst_sux == no_inst_sux && inst->is_loaded()) {
 723         // both successors identical and klass is loaded => simplify to: Goto
 724         set_canonical(new Goto(is_inst_sux, x->state_before(), x->is_safepoint()));
 725       } else {
 726         // successors differ => simplify to: IfInstanceOf
 727         set_canonical(new IfInstanceOf(inst->klass(), inst->obj(), true, inst->state_before()->bci(), is_inst_sux, no_inst_sux));
 728       }
 729     }
 730   } else if (rt == objectNull && (l->as_NewInstance() || l->as_NewArray())) {


 731     if (x->cond() == Instruction::eql) {
 732       BlockBegin* sux = x->fsux();
 733       set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux)));
 734     } else {
 735       assert(x->cond() == Instruction::neq, "only other valid case");
 736       BlockBegin* sux = x->tsux();
 737       set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux)));
 738     }
 739   }
 740 }
 741 
 742 
 743 void Canonicalizer::do_TableSwitch(TableSwitch* x) {
 744   if (x->tag()->type()->is_constant()) {
 745     int v = x->tag()->type()->as_IntConstant()->value();
 746     BlockBegin* sux = x->default_sux();
 747     if (v >= x->lo_key() && v <= x->hi_key()) {
 748       sux = x->sux_at(v - x->lo_key());
 749     }
 750     set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux)));




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