annotate truffle/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Cached.java @ 22503:828c67903db2

Moving profiles into their own project to ensure the core API doesn't reference these utility classes.
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Thu, 17 Dec 2015 10:01:38 +0100
parents a63bda98cfdb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
1 /*
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
4 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
7 * published by the Free Software Foundation. Oracle designates this
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
8 * particular file as subject to the "Classpath" exception as provided
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
10 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
11 * This code is distributed in the hope that it will be useful, but WITHOUT
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
14 * version 2 for more details (a copy is included in the LICENSE file that
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
15 * accompanied this code).
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
16 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License version
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
18 * 2 along with this work; if not, write to the Free Software Foundation,
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
20 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
22 * or visit www.oracle.com if you need additional information or have any
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
23 * questions.
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
24 */
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
25 package com.oracle.truffle.api.dsl;
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
26
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22127
diff changeset
27 import com.oracle.truffle.api.CompilerAsserts;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22127
diff changeset
28 import com.oracle.truffle.api.nodes.Node;
22501
a63bda98cfdb Extract profiles into separate package. Add isProfilingEnabled in TruffleRuntime to disable profiling in the default runtime; Add low overhead profiles for primitives; Add LoopConditionProfile; Profile footprint/threadsafety improvements; Make toString implementations more consistent; Greatly enhanced javadoc documentation for profiles; Deprecate old profiles
Christian Humer <christian.humer@oracle.com>
parents: 22157
diff changeset
29
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22127
diff changeset
30 import java.lang.annotation.ElementType;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22127
diff changeset
31 import java.lang.annotation.Retention;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22127
diff changeset
32 import java.lang.annotation.RetentionPolicy;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22127
diff changeset
33 import java.lang.annotation.Target;
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
34
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
35 /**
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
36 * <p>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
37 * A parameter annotated with {@link Cached} in a {@link Specialization} refers to a <b>cached</b>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
38 * value of a specialization instance. A cached parameter value is initialized once using the
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
39 * initializer expression at specialization instantiation. For each call of the specialization
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
40 * method the cached value is provided by using the annotated parameter from the method body. Cache
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
41 * initializers are potentially executed before guard expressions declared in
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
42 * {@link Specialization#guards()}.
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
43 * </p>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
44 * <p>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
45 * A typical specialization may define multiple dynamic and multiple cached parameters. Dynamic
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
46 * parameter values are typically provided by executing child nodes of the operation. Cached
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
47 * parameters are initialized and stored once per specialization instantiation. Cached parameters
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
48 * are always constant at compile time. You may verify this by invoking
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
49 * {@link CompilerAsserts#compilationConstant(Object)} on any cached parameter. For consistency
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
50 * between specialization declarations cached parameters must be declared last in a specialization
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
51 * method.
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
52 * </p>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
53 * <p>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
54 * The initializer expression of a cached parameter is defined using a subset of Java. This subset
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
55 * includes field/parameter accesses, function calls, type exact infix comparisons (==, !=, <, <=,
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
56 * >, >=) and integer literals. The return type of the initializer expression must be assignable to
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
57 * the parameter type. If the annotated parameter type is derived from {@link Node} then the
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
58 * {@link Node} instance is allowed to use the {@link Node#replace(Node)} method to replace itself.
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
59 * Bound elements without receivers are resolved using the following order:
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
60 * <ol>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
61 * <li>Dynamic and cached parameters of the enclosing specialization.</li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
62 * <li>Fields defined using {@link NodeField} for the enclosing node.</li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
63 * <li>Public constructors of the type of the annotated parameter using the <code>new</code> keyword
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
64 * as method name.</li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
65 * <li>Public and static methods or fields of the type of the annotated parameter.</li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
66 * <li>Non-private, static or virtual methods or fields of enclosing node.</li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
67 * <li>Non-private, static or virtual methods or fields of super types of the enclosing node.</li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
68 * <li>Public and static methods or fields imported using {@link ImportStatic}.</li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
69 * </ol>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
70 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
71 * The following examples explain the intended use of the {@link Cached} annotation. All of the
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
72 * examples have to be enclosed in the following node declaration:
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
73 * </p>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
74 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
75 * <pre>
22127
5a0cccf023c4 Wrap annotation into @code or @link sections
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
76 * {@link NodeChild @NodeChild}("operand")
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
77 * abstract TestNode extends Node {
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
78 * abstract void execute(Object operandValue);
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
79 * // ... example here ...
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
80 * }
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
81 * </pre>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
82 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
83 * <ol>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
84 * <li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
85 * This example defines one dynamic and one cached parameter. The operand parameter is representing
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
86 * the dynamic value of the operand while the cachedOperand is initialized once at first execution
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
87 * of the specialization (specialization instantiation time).
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
88 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
89 * <pre>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
90 * &#064;Specialization
22127
5a0cccf023c4 Wrap annotation into @code or @link sections
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
91 * void doCached(int operand, {@code @Cached}(&quot;operand&quot;) int cachedOperand) {
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
92 * CompilerAsserts.compilationConstant(cachedOperand);
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
93 * ...
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
94 * }
22503
828c67903db2 Moving profiles into their own project to ensure the core API doesn't reference these utility classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22501
diff changeset
95 *
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
96 * Example executions:
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
97 * execute(1) => doCached(1, 1) // new instantiation, localOperand is bound to 1
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
98 * execute(0) => doCached(0, 1)
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
99 * execute(2) => doCached(2, 1)
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
100 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
101 * </pre>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
102 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
103 * </li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
104 * <li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
105 * We extend the previous example by a guard for the cachedOperand value to be equal to the dynamic
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
106 * operand value. This specifies that the specialization is instantiated for each individual operand
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
107 * value that is provided. There are a lot of individual <code>int</code> values and for each
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
108 * individual <code>int</code> value a new specialization would get instantiated. The
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
109 * {@link Specialization#limit()} property defines a limit for the number of specializations that
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
110 * can get instantiated. If the specialization instantiation limit is reached then no further
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
111 * specializations are instantiated. Like for other specializations if there are no more
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
112 * specializations defined an {@link UnsupportedSpecializationException} is thrown. The default
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
113 * specialization instantiation limit is <code>3</code>.
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
114 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
115 * <pre>
19771
b249bdba508b Truffle-DSL: @Cached javadoc fixes.
Christian Humer <christian.humer@gmail.com>
parents: 19300
diff changeset
116 * &#064;Specialization(guards = &quot;operand == cachedOperand&quot;)
22127
5a0cccf023c4 Wrap annotation into @code or @link sections
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
117 * void doCached(int operand, {@code @Cached}(&quot;operand&quot;) int cachedOperand) {
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
118 * CompilerAsserts.compilationConstant(cachedOperand);
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
119 * ...
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
120 * }
22503
828c67903db2 Moving profiles into their own project to ensure the core API doesn't reference these utility classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22501
diff changeset
121 *
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
122 * Example executions:
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
123 * execute(0) => doCached(0, 0) // new instantiation, cachedOperand is bound to 0
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
124 * execute(1) => doCached(1, 1) // new instantiation, cachedOperand is bound to 1
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
125 * execute(1) => doCached(1, 1)
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
126 * execute(2) => doCached(2, 2) // new instantiation, cachedOperand is bound to 2
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
127 * execute(3) => throws UnsupportedSpecializationException // instantiation limit overflows
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
128 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
129 * </pre>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
130 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
131 * </li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
132 * <li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
133 * To handle the limit overflow we extend our example by an additional specialization named
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
134 * <code>doNormal</code>. This specialization has the same type restrictions but does not have local
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
135 * state nor the operand identity guard. It is also declared after <code>doCached</code> therefore
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
136 * it is only instantiated if the limit of the <code>doCached</code> specialization has been
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
137 * reached. In other words <code>doNormal</code> is more generic than <code>doCached</code> . The
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
138 * <code>doNormal</code> specialization uses <code>contains=&quot;doCached&quot;</code> to specify
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
139 * that all instantiations of <code>doCached</code> get removed if <code>doNormal</code> is
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
140 * instantiated. Alternatively if the <code>contains</code> relation is omitted then all
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
141 * <code>doCached</code> instances remain but no new instances are created.
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
142 *
19300
67ab244ab689 Truffle-DSL: fix formatting issues.
Christian Humer <christian.humer@gmail.com>
parents: 19288
diff changeset
143 * <code>
19771
b249bdba508b Truffle-DSL: @Cached javadoc fixes.
Christian Humer <christian.humer@gmail.com>
parents: 19300
diff changeset
144 * &#064;Specialization(guards = &quot;operand == cachedOperand&quot;)
22127
5a0cccf023c4 Wrap annotation into @code or @link sections
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
145 * void doCached(int operand, {@code @Cached}(&quot;operand&quot;) int cachedOperand) {
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
146 * CompilerAsserts.compilationConstant(cachedOperand);
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
147 * ...
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
148 * }
22503
828c67903db2 Moving profiles into their own project to ensure the core API doesn't reference these utility classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22501
diff changeset
149 *
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
150 * &#064;Specialization(contains = &quot;doCached&quot;)
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
151 * void doNormal(int operand) {...}
22503
828c67903db2 Moving profiles into their own project to ensure the core API doesn't reference these utility classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22501
diff changeset
152 *
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
153 * Example executions with contains = &quot;doCached&quot;:
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
154 * execute(0) => doCached(0, 0) // new instantiation, cachedOperand is bound to 0
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
155 * execute(1) => doCached(1, 1) // new instantiation, cachedOperand is bound to 1
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
156 * execute(1) => doCached(1, 1)
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
157 * execute(2) => doCached(2, 2) // new instantiation, cachedOperand is bound to 2
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
158 * execute(3) => doNormal(3) // new instantiation of doNormal due to limit overflow; doCached gets removed.
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
159 * execute(1) => doNormal(1)
22503
828c67903db2 Moving profiles into their own project to ensure the core API doesn't reference these utility classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22501
diff changeset
160 *
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
161 * Example executions without contains = &quot;doCached&quot;:
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
162 * execute(0) => doCached(0, 0) // new instantiation, cachedOperand is bound to 0
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
163 * execute(1) => doCached(1, 1) // new instantiation, cachedOperand is bound to 1
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
164 * execute(1) => doCached(1, 1)
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
165 * execute(2) => doCached(2, 2) // new instantiation, cachedOperand is bound to 2
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
166 * execute(3) => doNormal(3) // new instantiation of doNormal due to limit overflow
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
167 * execute(1) => doCached(1, 1)
22503
828c67903db2 Moving profiles into their own project to ensure the core API doesn't reference these utility classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22501
diff changeset
168 *
19300
67ab244ab689 Truffle-DSL: fix formatting issues.
Christian Humer <christian.humer@gmail.com>
parents: 19288
diff changeset
169 * </code>
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
170 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
171 * </li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
172 * <li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
173 * This next example shows how methods from the enclosing node can be used to initialize cached
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
174 * parameters. Please note that the visibility of transformLocal must not be <code>private</code>.
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
175 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
176 * <pre>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
177 * &#064;Specialization
22127
5a0cccf023c4 Wrap annotation into @code or @link sections
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
178 * void s(int operand, {@code @Cached}(&quot;transformLocal(operand)&quot;) int cachedOperand) {
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
179 * }
22503
828c67903db2 Moving profiles into their own project to ensure the core API doesn't reference these utility classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22501
diff changeset
180 *
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
181 * int transformLocal(int operand) {
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
182 * return operand & 0x42;
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
183 * }
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
184 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
185 * </li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
186 * </pre>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
187 * <li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
188 * The <code>new</code> keyword can be used to initialize a cached parameter using a constructor of
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
189 * the parameter type.
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
190 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
191 * <pre>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
192 * &#064;Specialization
22127
5a0cccf023c4 Wrap annotation into @code or @link sections
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
193 * void s(Object operand, {@code @Cached}(&quot;new()&quot;) OtherNode someNode) {
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
194 * someNode.execute(operand);
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
195 * }
22503
828c67903db2 Moving profiles into their own project to ensure the core API doesn't reference these utility classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22501
diff changeset
196 *
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
197 * static class OtherNode extends Node {
22503
828c67903db2 Moving profiles into their own project to ensure the core API doesn't reference these utility classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22501
diff changeset
198 *
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
199 * public String execute(Object value) {
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
200 * throw new UnsupportedOperationException();
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
201 * }
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
202 * }
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
203 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
204 * </pre>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
205 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
206 * </li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
207 * <li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
208 * Java types without public constructor but with a static factory methods can be initialized by
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
209 * just referencing its static factory method and its parameters. In this case
22503
828c67903db2 Moving profiles into their own project to ensure the core API doesn't reference these utility classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22501
diff changeset
210 * {@link com.oracle.truffle.api.profiles.BranchProfile#create()} is used to instantiate the
828c67903db2 Moving profiles into their own project to ensure the core API doesn't reference these utility classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22501
diff changeset
211 * {@link com.oracle.truffle.api.profiles.BranchProfile} instance.
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
212 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
213 * <pre>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
214 * &#064;Specialization
22127
5a0cccf023c4 Wrap annotation into @code or @link sections
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
215 * void s(int operand, {@code @Cached}(&quot;create()&quot;) BranchProfile profile) {
19288
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
216 * }
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
217 * </pre>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
218 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
219 * </li>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
220 * </ol>
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
221 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
222 * @see Specialization#guards()
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
223 * @see Specialization#contains()
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
224 * @see Specialization#limit()
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
225 * @see ImportStatic
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
226 */
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
227 @Retention(RetentionPolicy.RUNTIME)
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
228 @Target({ElementType.PARAMETER})
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
229 public @interface Cached {
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
230
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
231 /**
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
232 * Defines the initializer expression of the cached parameter value.
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
233 *
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
234 * @see Cached
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
235 */
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
236 String value();
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
237
3a37116ef37f Truffle-DSL: added @Cached annotation, added limit property and updated @Specialization javadoc.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
238 }