comparison src/share/vm/opto/compile.cpp @ 14500:fdad2932c73f

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: kvn, twisti
author roland
date Tue, 25 Feb 2014 18:16:24 +0100
parents cd5d10655495
children 4ca6dc0799b6
comparison
equal deleted inserted replaced
14498:04e7587c97dc 14500:fdad2932c73f
3247 if (md->is_empty()) { 3247 if (md->is_empty()) {
3248 // Assume the trap has not occurred, or that it occurred only 3248 // Assume the trap has not occurred, or that it occurred only
3249 // because of a transient condition during start-up in the interpreter. 3249 // because of a transient condition during start-up in the interpreter.
3250 return false; 3250 return false;
3251 } 3251 }
3252 if (md->has_trap_at(bci, reason) != 0) { 3252 ciMethod* m = Deoptimization::reason_is_speculate(reason) ? this->method() : NULL;
3253 if (md->has_trap_at(bci, m, reason) != 0) {
3253 // Assume PerBytecodeTrapLimit==0, for a more conservative heuristic. 3254 // Assume PerBytecodeTrapLimit==0, for a more conservative heuristic.
3254 // Also, if there are multiple reasons, or if there is no per-BCI record, 3255 // Also, if there are multiple reasons, or if there is no per-BCI record,
3255 // assume the worst. 3256 // assume the worst.
3256 if (log()) 3257 if (log())
3257 log()->elem("observe trap='%s' count='%d'", 3258 log()->elem("observe trap='%s' count='%d'",
3265 } 3266 }
3266 3267
3267 // Less-accurate variant which does not require a method and bci. 3268 // Less-accurate variant which does not require a method and bci.
3268 bool Compile::too_many_traps(Deoptimization::DeoptReason reason, 3269 bool Compile::too_many_traps(Deoptimization::DeoptReason reason,
3269 ciMethodData* logmd) { 3270 ciMethodData* logmd) {
3270 if (trap_count(reason) >= (uint)PerMethodTrapLimit) { 3271 if (trap_count(reason) >= Deoptimization::per_method_trap_limit(reason)) {
3271 // Too many traps globally. 3272 // Too many traps globally.
3272 // Note that we use cumulative trap_count, not just md->trap_count. 3273 // Note that we use cumulative trap_count, not just md->trap_count.
3273 if (log()) { 3274 if (log()) {
3274 int mcount = (logmd == NULL)? -1: (int)logmd->trap_count(reason); 3275 int mcount = (logmd == NULL)? -1: (int)logmd->trap_count(reason);
3275 log()->elem("observe trap='%s' count='0' mcount='%d' ccount='%d'", 3276 log()->elem("observe trap='%s' count='0' mcount='%d' ccount='%d'",
3300 // Pick a cutoff point well within PerBytecodeRecompilationCutoff. 3301 // Pick a cutoff point well within PerBytecodeRecompilationCutoff.
3301 uint bc_cutoff = (uint) PerBytecodeRecompilationCutoff / 8; 3302 uint bc_cutoff = (uint) PerBytecodeRecompilationCutoff / 8;
3302 uint m_cutoff = (uint) PerMethodRecompilationCutoff / 2 + 1; // not zero 3303 uint m_cutoff = (uint) PerMethodRecompilationCutoff / 2 + 1; // not zero
3303 Deoptimization::DeoptReason per_bc_reason 3304 Deoptimization::DeoptReason per_bc_reason
3304 = Deoptimization::reason_recorded_per_bytecode_if_any(reason); 3305 = Deoptimization::reason_recorded_per_bytecode_if_any(reason);
3306 ciMethod* m = Deoptimization::reason_is_speculate(reason) ? this->method() : NULL;
3305 if ((per_bc_reason == Deoptimization::Reason_none 3307 if ((per_bc_reason == Deoptimization::Reason_none
3306 || md->has_trap_at(bci, reason) != 0) 3308 || md->has_trap_at(bci, m, reason) != 0)
3307 // The trap frequency measure we care about is the recompile count: 3309 // The trap frequency measure we care about is the recompile count:
3308 && md->trap_recompiled_at(bci) 3310 && md->trap_recompiled_at(bci, m)
3309 && md->overflow_recompile_count() >= bc_cutoff) { 3311 && md->overflow_recompile_count() >= bc_cutoff) {
3310 // Do not emit a trap here if it has already caused recompilations. 3312 // Do not emit a trap here if it has already caused recompilations.
3311 // Also, if there are multiple reasons, or if there is no per-BCI record, 3313 // Also, if there are multiple reasons, or if there is no per-BCI record,
3312 // assume the worst. 3314 // assume the worst.
3313 if (log()) 3315 if (log())