comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Assumption.java @ 9259:324dcaedb1ed

Added a method isValid to the Assumption class. Added javadoc to the Assumption class.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 23 Apr 2013 15:44:07 +0200
parents 07f8d136a05e
children 494b818b527c
comparison
equal deleted inserted replaced
9258:07f8d136a05e 9259:324dcaedb1ed
22 */ 22 */
23 package com.oracle.truffle.api; 23 package com.oracle.truffle.api;
24 24
25 import com.oracle.truffle.api.nodes.*; 25 import com.oracle.truffle.api.nodes.*;
26 26
27 /**
28 * An assumption is a global boolean flag that starts with the value true (i.e., the assumption is
29 * valid) and can subsequently be invalidated (using {@link Assumption#invalidate()}). Once
30 * invalidated, an assumption can never get valid again. Assumptions can be created using the
31 * {@link TruffleRuntime#createAssumption()} or the {@link TruffleRuntime#createAssumption(String)}
32 * method. The Truffle compiler has special knowledge of this class in order to produce efficient
33 * machine code for checking an assumption in case the assumption object is a compile time constant.
34 * Therefore, assumptions should be stored in final fields in Truffle nodes.
35 */
27 public interface Assumption { 36 public interface Assumption {
28 37
38 /**
39 * Checks that this assumption is still valid. The method throws an exception, if this is no
40 * longer the case. This method is preferred over the {@link #isValid()} method when writing
41 * guest language interpreter code. The catch block should perform a node rewrite (see
42 * {@link Node#replace(Node)}) with a node that no longer relies on the assumption.
43 *
44 * @throws InvalidAssumptionException If the assumption is no longer valid.
45 */
29 void check() throws InvalidAssumptionException; 46 void check() throws InvalidAssumptionException;
30 47
48 /**
49 * Checks whether the assumption is still valid.
50 *
51 * @return a boolean value indicating the validity of the assumption
52 */
53 boolean isValid();
54
55 /**
56 * Invalidates this assumption. Performs no operation, if the assumption is already invalid.
57 */
31 void invalidate(); 58 void invalidate();
32 59
60 /**
61 * A name for the assumption that is used for debug output.
62 *
63 * @return the name of the assumption
64 */
33 String getName(); 65 String getName();
34 } 66 }