comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BinaryConditionProfile.java @ 16860:fa5e62620593

Truffle: made constructors of condition profiles package protected to delegate them later to TruffleRuntime.
author Christian Humer <christian.humer@gmail.com>
date Tue, 19 Aug 2014 14:56:19 +0200
parents fc6f12ee71e5
children b026b6d86ab6
comparison
equal deleted inserted replaced
16855:226552569e34 16860:fa5e62620593
29 29
30 /** 30 /**
31 * Utility class to speculate on conditions to be never true or to be never false. Condition 31 * Utility class to speculate on conditions to be never true or to be never false. Condition
32 * profiles are intended to be used as part of if conditions. 32 * profiles are intended to be used as part of if conditions.
33 * 33 *
34 * Example usage: 34 * @see ConditionProfile#createBinaryProfile()
35 *
36 * <pre>
37 * private final ConditionProfile zero = new BooleanConditionProfile();
38 *
39 * int value = ...;
40 * if (zero.profile(value == 0)) {
41 * return 0;
42 * } else {
43 * return value;
44 * }
45 *
46 * </pre>
47 *
48 * @see ConditionProfile
49 * @see CountingConditionProfile
50 */ 35 */
51 public class BinaryConditionProfile extends ConditionProfile { 36 public final class BinaryConditionProfile extends ConditionProfile {
52 37
53 @CompilationFinal private boolean wasTrue; 38 @CompilationFinal private boolean wasTrue;
54 @CompilationFinal private boolean wasFalse; 39 @CompilationFinal private boolean wasFalse;
40
41 BinaryConditionProfile() {
42 /* package protected constructor */
43 }
55 44
56 @Override 45 @Override
57 public boolean profile(boolean value) { 46 public boolean profile(boolean value) {
58 if (value) { 47 if (value) {
59 if (!wasTrue) { 48 if (!wasTrue) {