src/share/vm/c1/c1_LIRGenerator.hpp

Print this page
rev 4136 : 7153771: array bound check elimination for c1
Summary: when possible optimize out array bound checks, inserting predicates when needed.
Reviewed-by:


 395   LIR_Opr new_register(ValueType* type)          { return new_register(as_BasicType(type)); }
 396 
 397   // returns a register suitable for doing pointer math
 398   LIR_Opr new_pointer_register() {
 399 #ifdef _LP64
 400     return new_register(T_LONG);
 401 #else
 402     return new_register(T_INT);
 403 #endif
 404   }
 405 
 406   static LIR_Condition lir_cond(If::Condition cond) {
 407     LIR_Condition l;
 408     switch (cond) {
 409     case If::eql: l = lir_cond_equal;        break;
 410     case If::neq: l = lir_cond_notEqual;     break;
 411     case If::lss: l = lir_cond_less;         break;
 412     case If::leq: l = lir_cond_lessEqual;    break;
 413     case If::geq: l = lir_cond_greaterEqual; break;
 414     case If::gtr: l = lir_cond_greater;      break;


 415     };
 416     return l;
 417   }
 418 
 419 #ifdef __SOFTFP__
 420   void do_soft_float_compare(If *x);
 421 #endif // __SOFTFP__
 422 
 423   void init();
 424 
 425   SwitchRangeArray* create_lookup_ranges(TableSwitch* x);
 426   SwitchRangeArray* create_lookup_ranges(LookupSwitch* x);
 427   void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux);
 428 
 429   void do_RuntimeCall(address routine, int expected_arguments, Intrinsic* x);
 430 #ifdef TRACE_HAVE_INTRINSICS
 431   void do_ThreadIDIntrinsic(Intrinsic* x);
 432   void do_ClassIDIntrinsic(Intrinsic* x);
 433 #endif
 434 


 517   virtual void do_IfInstanceOf   (IfInstanceOf*    x);
 518   virtual void do_TableSwitch    (TableSwitch*     x);
 519   virtual void do_LookupSwitch   (LookupSwitch*    x);
 520   virtual void do_Return         (Return*          x);
 521   virtual void do_Throw          (Throw*           x);
 522   virtual void do_Base           (Base*            x);
 523   virtual void do_OsrEntry       (OsrEntry*        x);
 524   virtual void do_ExceptionObject(ExceptionObject* x);
 525   virtual void do_RoundFP        (RoundFP*         x);
 526   virtual void do_UnsafeGetRaw   (UnsafeGetRaw*    x);
 527   virtual void do_UnsafePutRaw   (UnsafePutRaw*    x);
 528   virtual void do_UnsafeGetObject(UnsafeGetObject* x);
 529   virtual void do_UnsafePutObject(UnsafePutObject* x);
 530   virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x);
 531   virtual void do_UnsafePrefetchRead (UnsafePrefetchRead*  x);
 532   virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x);
 533   virtual void do_ProfileCall    (ProfileCall*     x);
 534   virtual void do_ProfileInvoke  (ProfileInvoke*   x);
 535   virtual void do_RuntimeCall    (RuntimeCall*     x);
 536   virtual void do_MemBar         (MemBar*          x);


 537 };
 538 
 539 
 540 class LIRItem: public CompilationResourceObj {
 541  private:
 542   Value         _value;
 543   LIRGenerator* _gen;
 544   LIR_Opr       _result;
 545   bool          _destroys_register;
 546   LIR_Opr       _new_result;
 547 
 548   LIRGenerator* gen() const { return _gen; }
 549 
 550  public:
 551   LIRItem(Value value, LIRGenerator* gen) {
 552     _destroys_register = false;
 553     _gen = gen;
 554     set_instruction(value);
 555   }
 556 




 395   LIR_Opr new_register(ValueType* type)          { return new_register(as_BasicType(type)); }
 396 
 397   // returns a register suitable for doing pointer math
 398   LIR_Opr new_pointer_register() {
 399 #ifdef _LP64
 400     return new_register(T_LONG);
 401 #else
 402     return new_register(T_INT);
 403 #endif
 404   }
 405 
 406   static LIR_Condition lir_cond(If::Condition cond) {
 407     LIR_Condition l;
 408     switch (cond) {
 409     case If::eql: l = lir_cond_equal;        break;
 410     case If::neq: l = lir_cond_notEqual;     break;
 411     case If::lss: l = lir_cond_less;         break;
 412     case If::leq: l = lir_cond_lessEqual;    break;
 413     case If::geq: l = lir_cond_greaterEqual; break;
 414     case If::gtr: l = lir_cond_greater;      break;
 415     case If::aeq: l = lir_cond_aboveEqual;   break;
 416     case If::beq: l = lir_cond_belowEqual;   break;
 417     };
 418     return l;
 419   }
 420 
 421 #ifdef __SOFTFP__
 422   void do_soft_float_compare(If *x);
 423 #endif // __SOFTFP__
 424 
 425   void init();
 426 
 427   SwitchRangeArray* create_lookup_ranges(TableSwitch* x);
 428   SwitchRangeArray* create_lookup_ranges(LookupSwitch* x);
 429   void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux);
 430 
 431   void do_RuntimeCall(address routine, int expected_arguments, Intrinsic* x);
 432 #ifdef TRACE_HAVE_INTRINSICS
 433   void do_ThreadIDIntrinsic(Intrinsic* x);
 434   void do_ClassIDIntrinsic(Intrinsic* x);
 435 #endif
 436 


 519   virtual void do_IfInstanceOf   (IfInstanceOf*    x);
 520   virtual void do_TableSwitch    (TableSwitch*     x);
 521   virtual void do_LookupSwitch   (LookupSwitch*    x);
 522   virtual void do_Return         (Return*          x);
 523   virtual void do_Throw          (Throw*           x);
 524   virtual void do_Base           (Base*            x);
 525   virtual void do_OsrEntry       (OsrEntry*        x);
 526   virtual void do_ExceptionObject(ExceptionObject* x);
 527   virtual void do_RoundFP        (RoundFP*         x);
 528   virtual void do_UnsafeGetRaw   (UnsafeGetRaw*    x);
 529   virtual void do_UnsafePutRaw   (UnsafePutRaw*    x);
 530   virtual void do_UnsafeGetObject(UnsafeGetObject* x);
 531   virtual void do_UnsafePutObject(UnsafePutObject* x);
 532   virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x);
 533   virtual void do_UnsafePrefetchRead (UnsafePrefetchRead*  x);
 534   virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x);
 535   virtual void do_ProfileCall    (ProfileCall*     x);
 536   virtual void do_ProfileInvoke  (ProfileInvoke*   x);
 537   virtual void do_RuntimeCall    (RuntimeCall*     x);
 538   virtual void do_MemBar         (MemBar*          x);
 539   virtual void do_RangeCheckPredicate(RangeCheckPredicate* x);
 540   virtual void do_Assert         (Assert*          x);
 541 };
 542 
 543 
 544 class LIRItem: public CompilationResourceObj {
 545  private:
 546   Value         _value;
 547   LIRGenerator* _gen;
 548   LIR_Opr       _result;
 549   bool          _destroys_register;
 550   LIR_Opr       _new_result;
 551 
 552   LIRGenerator* gen() const { return _gen; }
 553 
 554  public:
 555   LIRItem(Value value, LIRGenerator* gen) {
 556     _destroys_register = false;
 557     _gen = gen;
 558     set_instruction(value);
 559   }
 560