@Override public String toString() { return toString(LoopConditionProfile.class, falseCount == 0, false, // String.format("trueProbability=%s (trueCount=%s, falseCount=%s)", calculateProbability(trueCount, falseCount), trueCount, falseCount)); }
@Override public boolean profile(boolean condition) { // locals required to guarantee no overflow in multi-threaded environments long trueCountLocal = trueCount; int falseCountLocal = falseCount; if (trueCountLocal == 0) { // Deopt for never entering the loop. if (condition) { CompilerDirectives.transferToInterpreterAndInvalidate(); } } // No deopt for not entering the loop. if (CompilerDirectives.inInterpreter()) { if (condition) { if (trueCountLocal < Long.MAX_VALUE) { trueCount = trueCountLocal + 1; } } else { if (falseCountLocal < Integer.MAX_VALUE) { falseCount = falseCountLocal + 1; } } // no branch probability calculation in the interpreter return condition; } else { return CompilerDirectives.injectBranchProbability(calculateProbability(trueCountLocal, falseCountLocal), condition); } }
@Override public boolean profile(boolean condition) { // locals required to guarantee no overflow in multi-threaded environments long trueCountLocal = trueCount; int falseCountLocal = falseCount; if (trueCountLocal == 0) { // Deopt for never entering the loop. if (condition) { CompilerDirectives.transferToInterpreterAndInvalidate(); } } // No deopt for not entering the loop. if (CompilerDirectives.inInterpreter()) { if (condition) { if (trueCountLocal < Long.MAX_VALUE) { trueCount = trueCountLocal + 1; } } else { if (falseCountLocal < Integer.MAX_VALUE) { falseCount = falseCountLocal + 1; } } // no branch probability calculation in the interpreter return condition; } else { return CompilerDirectives.injectBranchProbability(calculateProbability(trueCountLocal, falseCountLocal), condition); } }
/** * Returns a {@link LoopConditionProfile} that speculates on loop conditions to be never * <code>true</code>. It also captures loop probabilities for the compiler. Loop condition * profiles are intended to be used for loop conditions. * * @see LoopConditionProfile * @since 0.10 */ public static LoopConditionProfile createCountingProfile() { if (Profile.isProfilingEnabled()) { return Enabled.create(); } else { return Disabled.INSTANCE; } }
/** * Returns a {@link LoopConditionProfile} that speculates on loop conditions to be never * <code>true</code>. It also captures loop probabilities for the compiler. Loop condition * profiles are intended to be used for loop conditions. * * @see LoopConditionProfile * @since 0.10 */ public static LoopConditionProfile createCountingProfile() { if (Profile.isProfilingEnabled()) { return Enabled.create(); } else { return Disabled.INSTANCE; } }
static LoopConditionProfile create() { return new Enabled(); }
static LoopConditionProfile create() { return new Enabled(); }
@Override public boolean inject(boolean condition) { if (CompilerDirectives.inCompiledCode()) { return CompilerDirectives.injectBranchProbability(calculateProbability(trueCount, falseCount), condition); } else { return condition; } }
@Override public boolean inject(boolean condition) { if (CompilerDirectives.inCompiledCode()) { return CompilerDirectives.injectBranchProbability(calculateProbability(trueCount, falseCount), condition); } else { return condition; } }
@Override public String toString() { return toString(LoopConditionProfile.class, falseCount == 0, false, // String.format("trueProbability=%s (trueCount=%s, falseCount=%s)", calculateProbability(trueCount, falseCount), trueCount, falseCount)); }