src/share/vm/c1/c1_Optimizer.cpp

Print this page




 492   void do_Goto           (Goto*            x);
 493   void do_If             (If*              x);
 494   void do_IfInstanceOf   (IfInstanceOf*    x);
 495   void do_TableSwitch    (TableSwitch*     x);
 496   void do_LookupSwitch   (LookupSwitch*    x);
 497   void do_Return         (Return*          x);
 498   void do_Throw          (Throw*           x);
 499   void do_Base           (Base*            x);
 500   void do_OsrEntry       (OsrEntry*        x);
 501   void do_ExceptionObject(ExceptionObject* x);
 502   void do_RoundFP        (RoundFP*         x);
 503   void do_UnsafeGetRaw   (UnsafeGetRaw*    x);
 504   void do_UnsafePutRaw   (UnsafePutRaw*    x);
 505   void do_UnsafeGetObject(UnsafeGetObject* x);
 506   void do_UnsafePutObject(UnsafePutObject* x);
 507   void do_UnsafePrefetchRead (UnsafePrefetchRead*  x);
 508   void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x);
 509   void do_ProfileCall    (ProfileCall*     x);
 510   void do_ProfileInvoke  (ProfileInvoke*   x);
 511   void do_RuntimeCall    (RuntimeCall*     x);

 512 };
 513 
 514 
 515 // Because of a static contained within (for the purpose of iteration
 516 // over instructions), it is only valid to have one of these active at
 517 // a time
 518 class NullCheckEliminator: public ValueVisitor {
 519  private:
 520   Optimizer*        _opt;
 521 
 522   ValueSet*         _visitable_instructions;        // Visit each instruction only once per basic block
 523   BlockList*        _work_list;                   // Basic blocks to visit
 524 
 525   bool visitable(Value x) {
 526     assert(_visitable_instructions != NULL, "check");
 527     return _visitable_instructions->contains(x);
 528   }
 529   void mark_visited(Value x) {
 530     assert(_visitable_instructions != NULL, "check");
 531     _visitable_instructions->remove(x);


 661 void NullCheckVisitor::do_Goto           (Goto*            x) {}
 662 void NullCheckVisitor::do_If             (If*              x) {}
 663 void NullCheckVisitor::do_IfInstanceOf   (IfInstanceOf*    x) {}
 664 void NullCheckVisitor::do_TableSwitch    (TableSwitch*     x) {}
 665 void NullCheckVisitor::do_LookupSwitch   (LookupSwitch*    x) {}
 666 void NullCheckVisitor::do_Return         (Return*          x) {}
 667 void NullCheckVisitor::do_Throw          (Throw*           x) { nce()->clear_last_explicit_null_check(); }
 668 void NullCheckVisitor::do_Base           (Base*            x) {}
 669 void NullCheckVisitor::do_OsrEntry       (OsrEntry*        x) {}
 670 void NullCheckVisitor::do_ExceptionObject(ExceptionObject* x) { nce()->handle_ExceptionObject(x); }
 671 void NullCheckVisitor::do_RoundFP        (RoundFP*         x) {}
 672 void NullCheckVisitor::do_UnsafeGetRaw   (UnsafeGetRaw*    x) {}
 673 void NullCheckVisitor::do_UnsafePutRaw   (UnsafePutRaw*    x) {}
 674 void NullCheckVisitor::do_UnsafeGetObject(UnsafeGetObject* x) {}
 675 void NullCheckVisitor::do_UnsafePutObject(UnsafePutObject* x) {}
 676 void NullCheckVisitor::do_UnsafePrefetchRead (UnsafePrefetchRead*  x) {}
 677 void NullCheckVisitor::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {}
 678 void NullCheckVisitor::do_ProfileCall    (ProfileCall*     x) { nce()->clear_last_explicit_null_check(); }
 679 void NullCheckVisitor::do_ProfileInvoke  (ProfileInvoke*   x) {}
 680 void NullCheckVisitor::do_RuntimeCall    (RuntimeCall*     x) {}

 681 
 682 
 683 void NullCheckEliminator::visit(Value* p) {
 684   assert(*p != NULL, "should not find NULL instructions");
 685   if (visitable(*p)) {
 686     mark_visited(*p);
 687     (*p)->visit(&_visitor);
 688   }
 689 }
 690 
 691 bool NullCheckEliminator::merge_state_for(BlockBegin* block, ValueSet* incoming_state) {
 692   ValueSet* state = state_for(block);
 693   if (state == NULL) {
 694     state = incoming_state->copy();
 695     set_state_for(block, state);
 696     return true;
 697   } else {
 698     bool changed = state->set_intersect(incoming_state);
 699     if (PrintNullCheckElimination && changed) {
 700       tty->print_cr("Block %d's null check state changed", block->block_id());




 492   void do_Goto           (Goto*            x);
 493   void do_If             (If*              x);
 494   void do_IfInstanceOf   (IfInstanceOf*    x);
 495   void do_TableSwitch    (TableSwitch*     x);
 496   void do_LookupSwitch   (LookupSwitch*    x);
 497   void do_Return         (Return*          x);
 498   void do_Throw          (Throw*           x);
 499   void do_Base           (Base*            x);
 500   void do_OsrEntry       (OsrEntry*        x);
 501   void do_ExceptionObject(ExceptionObject* x);
 502   void do_RoundFP        (RoundFP*         x);
 503   void do_UnsafeGetRaw   (UnsafeGetRaw*    x);
 504   void do_UnsafePutRaw   (UnsafePutRaw*    x);
 505   void do_UnsafeGetObject(UnsafeGetObject* x);
 506   void do_UnsafePutObject(UnsafePutObject* x);
 507   void do_UnsafePrefetchRead (UnsafePrefetchRead*  x);
 508   void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x);
 509   void do_ProfileCall    (ProfileCall*     x);
 510   void do_ProfileInvoke  (ProfileInvoke*   x);
 511   void do_RuntimeCall    (RuntimeCall*     x);
 512   void do_MemBar         (MemBar*          x);
 513 };
 514 
 515 
 516 // Because of a static contained within (for the purpose of iteration
 517 // over instructions), it is only valid to have one of these active at
 518 // a time
 519 class NullCheckEliminator: public ValueVisitor {
 520  private:
 521   Optimizer*        _opt;
 522 
 523   ValueSet*         _visitable_instructions;        // Visit each instruction only once per basic block
 524   BlockList*        _work_list;                   // Basic blocks to visit
 525 
 526   bool visitable(Value x) {
 527     assert(_visitable_instructions != NULL, "check");
 528     return _visitable_instructions->contains(x);
 529   }
 530   void mark_visited(Value x) {
 531     assert(_visitable_instructions != NULL, "check");
 532     _visitable_instructions->remove(x);


 662 void NullCheckVisitor::do_Goto           (Goto*            x) {}
 663 void NullCheckVisitor::do_If             (If*              x) {}
 664 void NullCheckVisitor::do_IfInstanceOf   (IfInstanceOf*    x) {}
 665 void NullCheckVisitor::do_TableSwitch    (TableSwitch*     x) {}
 666 void NullCheckVisitor::do_LookupSwitch   (LookupSwitch*    x) {}
 667 void NullCheckVisitor::do_Return         (Return*          x) {}
 668 void NullCheckVisitor::do_Throw          (Throw*           x) { nce()->clear_last_explicit_null_check(); }
 669 void NullCheckVisitor::do_Base           (Base*            x) {}
 670 void NullCheckVisitor::do_OsrEntry       (OsrEntry*        x) {}
 671 void NullCheckVisitor::do_ExceptionObject(ExceptionObject* x) { nce()->handle_ExceptionObject(x); }
 672 void NullCheckVisitor::do_RoundFP        (RoundFP*         x) {}
 673 void NullCheckVisitor::do_UnsafeGetRaw   (UnsafeGetRaw*    x) {}
 674 void NullCheckVisitor::do_UnsafePutRaw   (UnsafePutRaw*    x) {}
 675 void NullCheckVisitor::do_UnsafeGetObject(UnsafeGetObject* x) {}
 676 void NullCheckVisitor::do_UnsafePutObject(UnsafePutObject* x) {}
 677 void NullCheckVisitor::do_UnsafePrefetchRead (UnsafePrefetchRead*  x) {}
 678 void NullCheckVisitor::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {}
 679 void NullCheckVisitor::do_ProfileCall    (ProfileCall*     x) { nce()->clear_last_explicit_null_check(); }
 680 void NullCheckVisitor::do_ProfileInvoke  (ProfileInvoke*   x) {}
 681 void NullCheckVisitor::do_RuntimeCall    (RuntimeCall*     x) {}
 682 void NullCheckVisitor::do_MemBar         (MemBar*          x) {}
 683 
 684 
 685 void NullCheckEliminator::visit(Value* p) {
 686   assert(*p != NULL, "should not find NULL instructions");
 687   if (visitable(*p)) {
 688     mark_visited(*p);
 689     (*p)->visit(&_visitor);
 690   }
 691 }
 692 
 693 bool NullCheckEliminator::merge_state_for(BlockBegin* block, ValueSet* incoming_state) {
 694   ValueSet* state = state_for(block);
 695   if (state == NULL) {
 696     state = incoming_state->copy();
 697     set_state_for(block, state);
 698     return true;
 699   } else {
 700     bool changed = state->set_intersect(incoming_state);
 701     if (PrintNullCheckElimination && changed) {
 702       tty->print_cr("Block %d's null check state changed", block->block_id());