Mercurial > hg > truffle
comparison src/share/vm/opto/compile.cpp @ 17728:b8413a9cbb84
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 | 085b304a1cc5 |
children | 606acabe7b5c |
comparison
equal
deleted
inserted
replaced
17727:cfd4aac53239 | 17728:b8413a9cbb84 |
---|---|
3231 if (md->is_empty()) { | 3231 if (md->is_empty()) { |
3232 // Assume the trap has not occurred, or that it occurred only | 3232 // Assume the trap has not occurred, or that it occurred only |
3233 // because of a transient condition during start-up in the interpreter. | 3233 // because of a transient condition during start-up in the interpreter. |
3234 return false; | 3234 return false; |
3235 } | 3235 } |
3236 if (md->has_trap_at(bci, reason) != 0) { | 3236 ciMethod* m = Deoptimization::reason_is_speculate(reason) ? this->method() : NULL; |
3237 if (md->has_trap_at(bci, m, reason) != 0) { | |
3237 // Assume PerBytecodeTrapLimit==0, for a more conservative heuristic. | 3238 // Assume PerBytecodeTrapLimit==0, for a more conservative heuristic. |
3238 // Also, if there are multiple reasons, or if there is no per-BCI record, | 3239 // Also, if there are multiple reasons, or if there is no per-BCI record, |
3239 // assume the worst. | 3240 // assume the worst. |
3240 if (log()) | 3241 if (log()) |
3241 log()->elem("observe trap='%s' count='%d'", | 3242 log()->elem("observe trap='%s' count='%d'", |
3249 } | 3250 } |
3250 | 3251 |
3251 // Less-accurate variant which does not require a method and bci. | 3252 // Less-accurate variant which does not require a method and bci. |
3252 bool Compile::too_many_traps(Deoptimization::DeoptReason reason, | 3253 bool Compile::too_many_traps(Deoptimization::DeoptReason reason, |
3253 ciMethodData* logmd) { | 3254 ciMethodData* logmd) { |
3254 if (trap_count(reason) >= (uint)PerMethodTrapLimit) { | 3255 if (trap_count(reason) >= Deoptimization::per_method_trap_limit(reason)) { |
3255 // Too many traps globally. | 3256 // Too many traps globally. |
3256 // Note that we use cumulative trap_count, not just md->trap_count. | 3257 // Note that we use cumulative trap_count, not just md->trap_count. |
3257 if (log()) { | 3258 if (log()) { |
3258 int mcount = (logmd == NULL)? -1: (int)logmd->trap_count(reason); | 3259 int mcount = (logmd == NULL)? -1: (int)logmd->trap_count(reason); |
3259 log()->elem("observe trap='%s' count='0' mcount='%d' ccount='%d'", | 3260 log()->elem("observe trap='%s' count='0' mcount='%d' ccount='%d'", |
3284 // Pick a cutoff point well within PerBytecodeRecompilationCutoff. | 3285 // Pick a cutoff point well within PerBytecodeRecompilationCutoff. |
3285 uint bc_cutoff = (uint) PerBytecodeRecompilationCutoff / 8; | 3286 uint bc_cutoff = (uint) PerBytecodeRecompilationCutoff / 8; |
3286 uint m_cutoff = (uint) PerMethodRecompilationCutoff / 2 + 1; // not zero | 3287 uint m_cutoff = (uint) PerMethodRecompilationCutoff / 2 + 1; // not zero |
3287 Deoptimization::DeoptReason per_bc_reason | 3288 Deoptimization::DeoptReason per_bc_reason |
3288 = Deoptimization::reason_recorded_per_bytecode_if_any(reason); | 3289 = Deoptimization::reason_recorded_per_bytecode_if_any(reason); |
3290 ciMethod* m = Deoptimization::reason_is_speculate(reason) ? this->method() : NULL; | |
3289 if ((per_bc_reason == Deoptimization::Reason_none | 3291 if ((per_bc_reason == Deoptimization::Reason_none |
3290 || md->has_trap_at(bci, reason) != 0) | 3292 || md->has_trap_at(bci, m, reason) != 0) |
3291 // The trap frequency measure we care about is the recompile count: | 3293 // The trap frequency measure we care about is the recompile count: |
3292 && md->trap_recompiled_at(bci) | 3294 && md->trap_recompiled_at(bci, m) |
3293 && md->overflow_recompile_count() >= bc_cutoff) { | 3295 && md->overflow_recompile_count() >= bc_cutoff) { |
3294 // Do not emit a trap here if it has already caused recompilations. | 3296 // Do not emit a trap here if it has already caused recompilations. |
3295 // Also, if there are multiple reasons, or if there is no per-BCI record, | 3297 // Also, if there are multiple reasons, or if there is no per-BCI record, |
3296 // assume the worst. | 3298 // assume the worst. |
3297 if (log()) | 3299 if (log()) |