src/share/vm/runtime/deoptimization.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/runtime

src/share/vm/runtime/deoptimization.hpp

Print this page
rev 8006 : 8073480: C2 should optimize explicit range checks
Summary: explicit range checks should be recognized by C2
Reviewed-by:


  46     Reason_null_assert,           // saw unexpected non-null or non-zero (@bci)
  47     Reason_range_check,           // saw unexpected array index (@bci)
  48     Reason_class_check,           // saw unexpected object class (@bci)
  49     Reason_array_check,           // saw unexpected array class (aastore @bci)
  50     Reason_intrinsic,             // saw unexpected operand to intrinsic (@bci)
  51     Reason_bimorphic,             // saw unexpected object class in bimorphic inlining (@bci)
  52 
  53     Reason_unloaded,              // unloaded class or constant pool entry
  54     Reason_uninitialized,         // bad class state (uninitialized)
  55     Reason_unreached,             // code is not reached, compiler
  56     Reason_unhandled,             // arbitrary compiler limitation
  57     Reason_constraint,            // arbitrary runtime constraint violated
  58     Reason_div0_check,            // a null_check due to division by zero
  59     Reason_age,                   // nmethod too old; tier threshold reached
  60     Reason_predicate,             // compiler generated predicate failed
  61     Reason_loop_limit_check,      // compiler generated loop limits check failed
  62     Reason_speculate_class_check, // saw unexpected object class from type speculation
  63     Reason_speculate_null_check,  // saw unexpected null from type speculation
  64     Reason_rtm_state_change,      // rtm state change detected
  65     Reason_unstable_if,           // a branch predicted always false was taken

  66 
  67     // Reason_tenured is counted separately, add normal counted Reasons above.
  68     // Related to MethodData::_trap_hist_limit where Reason_tenured isn't included
  69     Reason_tenured,               // age of the code has reached the limit
  70     Reason_LIMIT,
  71     // Note:  Keep this enum in sync. with _trap_reason_name.
  72     Reason_RECORDED_LIMIT = Reason_bimorphic  // some are not recorded per bc
  73     // Note:  Reason_RECORDED_LIMIT should be < 8 to fit into 3 bits of
  74     // DataLayout::trap_bits.  This dependency is enforced indirectly
  75     // via asserts, to avoid excessive direct header-to-header dependencies.
  76     // See Deoptimization::trap_state_reason and class DataLayout.
  77   };
  78 
  79   // What action must be taken by the runtime?
  80   enum DeoptAction {
  81     Action_none,                  // just interpret, do not invalidate nmethod
  82     Action_maybe_recompile,       // recompile the nmethod; need not invalidate
  83     Action_reinterpret,           // invalidate the nmethod, reset IC, maybe recompile
  84     Action_make_not_entrant,      // invalidate the nmethod, recompile (probably)
  85     Action_make_not_compilable,   // invalidate the nmethod and do not compile


 309   static bool trap_state_is_recompiled(int trap_state);
 310   static int  trap_state_set_recompiled(int trap_state, bool z);
 311   static const char* format_trap_state(char* buf, size_t buflen,
 312                                        int trap_state);
 313 
 314   static bool reason_is_recorded_per_bytecode(DeoptReason reason) {
 315     return reason > Reason_none && reason <= Reason_RECORDED_LIMIT;
 316   }
 317 
 318   static DeoptReason reason_recorded_per_bytecode_if_any(DeoptReason reason) {
 319     if (reason_is_recorded_per_bytecode(reason))
 320       return reason;
 321     else if (reason == Reason_div0_check) // null check due to divide-by-zero?
 322       return Reason_null_check;           // recorded per BCI as a null check
 323     else if (reason == Reason_speculate_class_check)
 324       return Reason_class_check;
 325     else if (reason == Reason_speculate_null_check)
 326       return Reason_null_check;
 327     else if (reason == Reason_unstable_if)
 328       return Reason_intrinsic;


 329     else
 330       return Reason_none;
 331   }
 332 
 333   static bool reason_is_speculate(int reason) {
 334     if (reason == Reason_speculate_class_check || reason == Reason_speculate_null_check) {
 335       return true;
 336     }
 337     return false;
 338   }
 339 
 340   static DeoptReason reason_null_check(bool speculative) {
 341     return speculative ? Deoptimization::Reason_speculate_null_check : Deoptimization::Reason_null_check;
 342   }
 343 
 344   static DeoptReason reason_class_check(bool speculative) {
 345     return speculative ? Deoptimization::Reason_speculate_class_check : Deoptimization::Reason_class_check;
 346   }
 347 
 348   static uint per_method_trap_limit(int reason) {




  46     Reason_null_assert,           // saw unexpected non-null or non-zero (@bci)
  47     Reason_range_check,           // saw unexpected array index (@bci)
  48     Reason_class_check,           // saw unexpected object class (@bci)
  49     Reason_array_check,           // saw unexpected array class (aastore @bci)
  50     Reason_intrinsic,             // saw unexpected operand to intrinsic (@bci)
  51     Reason_bimorphic,             // saw unexpected object class in bimorphic inlining (@bci)
  52 
  53     Reason_unloaded,              // unloaded class or constant pool entry
  54     Reason_uninitialized,         // bad class state (uninitialized)
  55     Reason_unreached,             // code is not reached, compiler
  56     Reason_unhandled,             // arbitrary compiler limitation
  57     Reason_constraint,            // arbitrary runtime constraint violated
  58     Reason_div0_check,            // a null_check due to division by zero
  59     Reason_age,                   // nmethod too old; tier threshold reached
  60     Reason_predicate,             // compiler generated predicate failed
  61     Reason_loop_limit_check,      // compiler generated loop limits check failed
  62     Reason_speculate_class_check, // saw unexpected object class from type speculation
  63     Reason_speculate_null_check,  // saw unexpected null from type speculation
  64     Reason_rtm_state_change,      // rtm state change detected
  65     Reason_unstable_if,           // a branch predicted always false was taken
  66     Reason_unstable_fused_if,     // fused two ifs that had each one untaken branch. One is now taken.
  67 
  68     // Reason_tenured is counted separately, add normal counted Reasons above.
  69     // Related to MethodData::_trap_hist_limit where Reason_tenured isn't included
  70     Reason_tenured,               // age of the code has reached the limit
  71     Reason_LIMIT,
  72     // Note:  Keep this enum in sync. with _trap_reason_name.
  73     Reason_RECORDED_LIMIT = Reason_bimorphic  // some are not recorded per bc
  74     // Note:  Reason_RECORDED_LIMIT should be < 8 to fit into 3 bits of
  75     // DataLayout::trap_bits.  This dependency is enforced indirectly
  76     // via asserts, to avoid excessive direct header-to-header dependencies.
  77     // See Deoptimization::trap_state_reason and class DataLayout.
  78   };
  79 
  80   // What action must be taken by the runtime?
  81   enum DeoptAction {
  82     Action_none,                  // just interpret, do not invalidate nmethod
  83     Action_maybe_recompile,       // recompile the nmethod; need not invalidate
  84     Action_reinterpret,           // invalidate the nmethod, reset IC, maybe recompile
  85     Action_make_not_entrant,      // invalidate the nmethod, recompile (probably)
  86     Action_make_not_compilable,   // invalidate the nmethod and do not compile


 310   static bool trap_state_is_recompiled(int trap_state);
 311   static int  trap_state_set_recompiled(int trap_state, bool z);
 312   static const char* format_trap_state(char* buf, size_t buflen,
 313                                        int trap_state);
 314 
 315   static bool reason_is_recorded_per_bytecode(DeoptReason reason) {
 316     return reason > Reason_none && reason <= Reason_RECORDED_LIMIT;
 317   }
 318 
 319   static DeoptReason reason_recorded_per_bytecode_if_any(DeoptReason reason) {
 320     if (reason_is_recorded_per_bytecode(reason))
 321       return reason;
 322     else if (reason == Reason_div0_check) // null check due to divide-by-zero?
 323       return Reason_null_check;           // recorded per BCI as a null check
 324     else if (reason == Reason_speculate_class_check)
 325       return Reason_class_check;
 326     else if (reason == Reason_speculate_null_check)
 327       return Reason_null_check;
 328     else if (reason == Reason_unstable_if)
 329       return Reason_intrinsic;
 330     else if (reason == Reason_unstable_fused_if)
 331       return Reason_range_check;
 332     else
 333       return Reason_none;
 334   }
 335 
 336   static bool reason_is_speculate(int reason) {
 337     if (reason == Reason_speculate_class_check || reason == Reason_speculate_null_check) {
 338       return true;
 339     }
 340     return false;
 341   }
 342 
 343   static DeoptReason reason_null_check(bool speculative) {
 344     return speculative ? Deoptimization::Reason_speculate_null_check : Deoptimization::Reason_null_check;
 345   }
 346 
 347   static DeoptReason reason_class_check(bool speculative) {
 348     return speculative ? Deoptimization::Reason_speculate_class_check : Deoptimization::Reason_class_check;
 349   }
 350 
 351   static uint per_method_trap_limit(int reason) {


src/share/vm/runtime/deoptimization.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File