Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
22388:9f64eb5ad9c1 | 22389:c1dfbaeef4af |
---|---|
50 if (value) { | 50 if (value) { |
51 if (trueCount == 0) { | 51 if (trueCount == 0) { |
52 CompilerDirectives.transferToInterpreterAndInvalidate(); | 52 CompilerDirectives.transferToInterpreterAndInvalidate(); |
53 } | 53 } |
54 if (CompilerDirectives.inInterpreter()) { | 54 if (CompilerDirectives.inInterpreter()) { |
55 trueCount++; | 55 if (trueCount < Integer.MAX_VALUE) { |
56 trueCount++; | |
57 } | |
56 } | 58 } |
57 } else { | 59 } else { |
58 if (falseCount == 0) { | 60 if (falseCount == 0) { |
59 CompilerDirectives.transferToInterpreterAndInvalidate(); | 61 CompilerDirectives.transferToInterpreterAndInvalidate(); |
60 } | 62 } |
61 if (CompilerDirectives.inInterpreter()) { | 63 if (CompilerDirectives.inInterpreter()) { |
62 falseCount++; | 64 if (falseCount < Integer.MAX_VALUE) { |
65 falseCount++; | |
66 } | |
63 } | 67 } |
64 } | 68 } |
65 return CompilerDirectives.injectBranchProbability((double) trueCount / (double) (trueCount + falseCount), value); | 69 return CompilerDirectives.injectBranchProbability((double) trueCount / (double) (trueCount + falseCount), value); |
66 } | 70 } |
67 | 71 |