src/share/vm/opto/compile.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/compile.cpp

Print this page
rev 5771 : 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
Summary: type methods shouldn't always operate on speculative part
Reviewed-by:
rev 5774 : 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
Summary: support for speculative traps that keep track of the root of the compilation in which a trap occurs.
Reviewed-by:
rev 5775 : imported patch spectrap-chris


3255 
3256   set_java_calls(frc.get_java_call_count());
3257   set_inner_loops(frc.get_inner_loop_count());
3258 
3259   // No infinite loops, no reason to bail out.
3260   return false;
3261 }
3262 
3263 //-----------------------------too_many_traps----------------------------------
3264 // Report if there are too many traps at the current method and bci.
3265 // Return true if there was a trap, and/or PerMethodTrapLimit is exceeded.
3266 bool Compile::too_many_traps(ciMethod* method,
3267                              int bci,
3268                              Deoptimization::DeoptReason reason) {
3269   ciMethodData* md = method->method_data();
3270   if (md->is_empty()) {
3271     // Assume the trap has not occurred, or that it occurred only
3272     // because of a transient condition during start-up in the interpreter.
3273     return false;
3274   }
3275   if (md->has_trap_at(bci, reason) != 0) {

3276     // Assume PerBytecodeTrapLimit==0, for a more conservative heuristic.
3277     // Also, if there are multiple reasons, or if there is no per-BCI record,
3278     // assume the worst.
3279     if (log())
3280       log()->elem("observe trap='%s' count='%d'",
3281                   Deoptimization::trap_reason_name(reason),
3282                   md->trap_count(reason));
3283     return true;
3284   } else {
3285     // Ignore method/bci and see if there have been too many globally.
3286     return too_many_traps(reason, md);
3287   }
3288 }
3289 
3290 // Less-accurate variant which does not require a method and bci.
3291 bool Compile::too_many_traps(Deoptimization::DeoptReason reason,
3292                              ciMethodData* logmd) {
3293  if (trap_count(reason) >= (uint)PerMethodTrapLimit) {
3294     // Too many traps globally.
3295     // Note that we use cumulative trap_count, not just md->trap_count.
3296     if (log()) {
3297       int mcount = (logmd == NULL)? -1: (int)logmd->trap_count(reason);
3298       log()->elem("observe trap='%s' count='0' mcount='%d' ccount='%d'",
3299                   Deoptimization::trap_reason_name(reason),
3300                   mcount, trap_count(reason));
3301     }
3302     return true;
3303   } else {
3304     // The coast is clear.
3305     return false;
3306   }
3307 }
3308 
3309 //--------------------------too_many_recompiles--------------------------------
3310 // Report if there are too many recompiles at the current method and bci.
3311 // Consults PerBytecodeRecompilationCutoff and PerMethodRecompilationCutoff.
3312 // Is not eager to return true, since this will cause the compiler to use
3313 // Action_none for a trap point, to avoid too many recompilations.
3314 bool Compile::too_many_recompiles(ciMethod* method,
3315                                   int bci,
3316                                   Deoptimization::DeoptReason reason) {
3317   ciMethodData* md = method->method_data();
3318   if (md->is_empty()) {
3319     // Assume the trap has not occurred, or that it occurred only
3320     // because of a transient condition during start-up in the interpreter.
3321     return false;
3322   }
3323   // Pick a cutoff point well within PerBytecodeRecompilationCutoff.
3324   uint bc_cutoff = (uint) PerBytecodeRecompilationCutoff / 8;
3325   uint m_cutoff  = (uint) PerMethodRecompilationCutoff / 2 + 1;  // not zero
3326   Deoptimization::DeoptReason per_bc_reason
3327     = Deoptimization::reason_recorded_per_bytecode_if_any(reason);

3328   if ((per_bc_reason == Deoptimization::Reason_none
3329        || md->has_trap_at(bci, reason) != 0)
3330       // The trap frequency measure we care about is the recompile count:
3331       && md->trap_recompiled_at(bci)
3332       && md->overflow_recompile_count() >= bc_cutoff) {
3333     // Do not emit a trap here if it has already caused recompilations.
3334     // Also, if there are multiple reasons, or if there is no per-BCI record,
3335     // assume the worst.
3336     if (log())
3337       log()->elem("observe trap='%s recompiled' count='%d' recompiles2='%d'",
3338                   Deoptimization::trap_reason_name(reason),
3339                   md->trap_count(reason),
3340                   md->overflow_recompile_count());
3341     return true;
3342   } else if (trap_count(reason) != 0
3343              && decompile_count() >= m_cutoff) {
3344     // Too many recompiles globally, and we have seen this sort of trap.
3345     // Use cumulative decompile_count, not just md->decompile_count.
3346     if (log())
3347       log()->elem("observe trap='%s' count='%d' mcount='%d' decompiles='%d' mdecompiles='%d'",
3348                   Deoptimization::trap_reason_name(reason),
3349                   md->trap_count(reason), trap_count(reason),
3350                   md->decompile_count(), decompile_count());
3351     return true;




3255 
3256   set_java_calls(frc.get_java_call_count());
3257   set_inner_loops(frc.get_inner_loop_count());
3258 
3259   // No infinite loops, no reason to bail out.
3260   return false;
3261 }
3262 
3263 //-----------------------------too_many_traps----------------------------------
3264 // Report if there are too many traps at the current method and bci.
3265 // Return true if there was a trap, and/or PerMethodTrapLimit is exceeded.
3266 bool Compile::too_many_traps(ciMethod* method,
3267                              int bci,
3268                              Deoptimization::DeoptReason reason) {
3269   ciMethodData* md = method->method_data();
3270   if (md->is_empty()) {
3271     // Assume the trap has not occurred, or that it occurred only
3272     // because of a transient condition during start-up in the interpreter.
3273     return false;
3274   }
3275   ciMethod* m = Deoptimization::reason_is_speculate(reason) ? this->method() : NULL;
3276   if (md->has_trap_at(bci, m, reason) != 0) {
3277     // Assume PerBytecodeTrapLimit==0, for a more conservative heuristic.
3278     // Also, if there are multiple reasons, or if there is no per-BCI record,
3279     // assume the worst.
3280     if (log())
3281       log()->elem("observe trap='%s' count='%d'",
3282                   Deoptimization::trap_reason_name(reason),
3283                   md->trap_count(reason));
3284     return true;
3285   } else {
3286     // Ignore method/bci and see if there have been too many globally.
3287     return too_many_traps(reason, md);
3288   }
3289 }
3290 
3291 // Less-accurate variant which does not require a method and bci.
3292 bool Compile::too_many_traps(Deoptimization::DeoptReason reason,
3293                              ciMethodData* logmd) {
3294   if (trap_count(reason) >= Deoptimization::per_method_trap_limit(reason)) {
3295     // Too many traps globally.
3296     // Note that we use cumulative trap_count, not just md->trap_count.
3297     if (log()) {
3298       int mcount = (logmd == NULL)? -1: (int)logmd->trap_count(reason);
3299       log()->elem("observe trap='%s' count='0' mcount='%d' ccount='%d'",
3300                   Deoptimization::trap_reason_name(reason),
3301                   mcount, trap_count(reason));
3302     }
3303     return true;
3304   } else {
3305     // The coast is clear.
3306     return false;
3307   }
3308 }
3309 
3310 //--------------------------too_many_recompiles--------------------------------
3311 // Report if there are too many recompiles at the current method and bci.
3312 // Consults PerBytecodeRecompilationCutoff and PerMethodRecompilationCutoff.
3313 // Is not eager to return true, since this will cause the compiler to use
3314 // Action_none for a trap point, to avoid too many recompilations.
3315 bool Compile::too_many_recompiles(ciMethod* method,
3316                                   int bci,
3317                                   Deoptimization::DeoptReason reason) {
3318   ciMethodData* md = method->method_data();
3319   if (md->is_empty()) {
3320     // Assume the trap has not occurred, or that it occurred only
3321     // because of a transient condition during start-up in the interpreter.
3322     return false;
3323   }
3324   // Pick a cutoff point well within PerBytecodeRecompilationCutoff.
3325   uint bc_cutoff = (uint) PerBytecodeRecompilationCutoff / 8;
3326   uint m_cutoff  = (uint) PerMethodRecompilationCutoff / 2 + 1;  // not zero
3327   Deoptimization::DeoptReason per_bc_reason
3328     = Deoptimization::reason_recorded_per_bytecode_if_any(reason);
3329   ciMethod* m = Deoptimization::reason_is_speculate(reason) ? this->method() : NULL;
3330   if ((per_bc_reason == Deoptimization::Reason_none
3331        || md->has_trap_at(bci, m, reason) != 0)
3332       // The trap frequency measure we care about is the recompile count:
3333       && md->trap_recompiled_at(bci, m)
3334       && md->overflow_recompile_count() >= bc_cutoff) {
3335     // Do not emit a trap here if it has already caused recompilations.
3336     // Also, if there are multiple reasons, or if there is no per-BCI record,
3337     // assume the worst.
3338     if (log())
3339       log()->elem("observe trap='%s recompiled' count='%d' recompiles2='%d'",
3340                   Deoptimization::trap_reason_name(reason),
3341                   md->trap_count(reason),
3342                   md->overflow_recompile_count());
3343     return true;
3344   } else if (trap_count(reason) != 0
3345              && decompile_count() >= m_cutoff) {
3346     // Too many recompiles globally, and we have seen this sort of trap.
3347     // Use cumulative decompile_count, not just md->decompile_count.
3348     if (log())
3349       log()->elem("observe trap='%s' count='%d' mcount='%d' decompiles='%d' mdecompiles='%d'",
3350                   Deoptimization::trap_reason_name(reason),
3351                   md->trap_count(reason), trap_count(reason),
3352                   md->decompile_count(), decompile_count());
3353     return true;


src/share/vm/opto/compile.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File