Mercurial > hg > truffle
diff truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/CountingConditionProfile.java @ 22389:c1dfbaeef4af
Profile counts should not overflow, otherwise injectBranchProbability triggers assertion
author | Stefan Marr <stefan.marr@jku.at> |
---|---|
date | Thu, 19 Nov 2015 15:32:26 +0100 |
parents | dc83cc1f94f2 |
children | a63bda98cfdb |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/CountingConditionProfile.java Thu Nov 19 09:59:05 2015 +0100 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/CountingConditionProfile.java Thu Nov 19 15:32:26 2015 +0100 @@ -52,14 +52,18 @@ CompilerDirectives.transferToInterpreterAndInvalidate(); } if (CompilerDirectives.inInterpreter()) { - trueCount++; + if (trueCount < Integer.MAX_VALUE) { + trueCount++; + } } } else { if (falseCount == 0) { CompilerDirectives.transferToInterpreterAndInvalidate(); } if (CompilerDirectives.inInterpreter()) { - falseCount++; + if (falseCount < Integer.MAX_VALUE) { + falseCount++; + } } } return CompilerDirectives.injectBranchProbability((double) trueCount / (double) (trueCount + falseCount), value);