Mercurial > hg > truffle
changeset 16868:db090a8d3705
clarify documentation about assumption and profile storage in final fields
author | Michael Haupt <michael.haupt@oracle.com> |
---|---|
date | Wed, 20 Aug 2014 15:16:11 +0200 |
parents | 7af9301efe6b |
children | 6754b5b64978 |
files | graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Assumption.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/ConditionProfile.java |
diffstat | 3 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Assumption.java Tue Aug 19 19:25:44 2014 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Assumption.java Wed Aug 20 15:16:11 2014 +0200 @@ -34,6 +34,9 @@ * method. The Truffle compiler has special knowledge of this class in order to produce efficient * machine code for checking an assumption in case the assumption object is a compile time constant. * Therefore, assumptions should be stored in final fields in Truffle nodes. + * + * All instances of classes implementing {@code Assumption} must be held in {@code final} fields for + * compiler optimizations to take effect. */ public interface Assumption { @@ -42,14 +45,14 @@ * longer the case. This method is preferred over the {@link #isValid()} method when writing * guest language interpreter code. The catch block should perform a node rewrite (see * {@link Node#replace(Node)}) with a node that no longer relies on the assumption. - * + * * @throws InvalidAssumptionException If the assumption is no longer valid. */ void check() throws InvalidAssumptionException; /** * Checks whether the assumption is still valid. - * + * * @return a boolean value indicating the validity of the assumption */ boolean isValid(); @@ -61,7 +64,7 @@ /** * A name for the assumption that is used for debug output. - * + * * @return the name of the assumption */ String getName();
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java Tue Aug 19 19:25:44 2014 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java Wed Aug 20 15:16:11 2014 +0200 @@ -32,6 +32,9 @@ * invoked first the optimized code is invalidated and the branch where {@link #enter()} is invoked * is enabled for compilation. Otherwise if the {@link #enter()} method was never invoked the branch * will not get compiled. + * + * All {@code BranchProfile} instances must be held in {@code final} fields for compiler + * optimizations to take effect. */ public final class BranchProfile {
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/ConditionProfile.java Tue Aug 19 19:25:44 2014 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/ConditionProfile.java Wed Aug 20 15:16:11 2014 +0200 @@ -34,7 +34,7 @@ * * <pre> * private final ConditionProfile zero = ConditionProfile.createBinaryProfile(); - * + * * int value = ...; * if (zero.profile(value == 0)) { * return 0; @@ -44,6 +44,9 @@ * * </pre> * + * All instances of {@code ConditionProfile} (and subclasses) must be held in {@code final} fields + * for compiler optimizations to take effect. + * * @see #createCountingProfile() * @see #createBinaryProfile() */