comparison truffle/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Cached.java @ 22127:5a0cccf023c4

Wrap annotation into @code or @link sections
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Thu, 03 Sep 2015 16:29:30 +0200
parents 9c8c0937da41
children dc83cc1f94f2
comparison
equal deleted inserted replaced
22126:7d4e42092f39 22127:5a0cccf023c4
69 * The following examples explain the intended use of the {@link Cached} annotation. All of the 69 * The following examples explain the intended use of the {@link Cached} annotation. All of the
70 * examples have to be enclosed in the following node declaration: 70 * examples have to be enclosed in the following node declaration:
71 * </p> 71 * </p>
72 * 72 *
73 * <pre> 73 * <pre>
74 * @NodeChild("operand") 74 * {@link NodeChild @NodeChild}("operand")
75 * abstract TestNode extends Node { 75 * abstract TestNode extends Node {
76 * abstract void execute(Object operandValue); 76 * abstract void execute(Object operandValue);
77 * // ... example here ... 77 * // ... example here ...
78 * } 78 * }
79 * </pre> 79 * </pre>
84 * the dynamic value of the operand while the cachedOperand is initialized once at first execution 84 * the dynamic value of the operand while the cachedOperand is initialized once at first execution
85 * of the specialization (specialization instantiation time). 85 * of the specialization (specialization instantiation time).
86 * 86 *
87 * <pre> 87 * <pre>
88 * &#064;Specialization 88 * &#064;Specialization
89 * void doCached(int operand, @Cached(&quot;operand&quot;) int cachedOperand) { 89 * void doCached(int operand, {@code @Cached}(&quot;operand&quot;) int cachedOperand) {
90 * CompilerAsserts.compilationConstant(cachedOperand); 90 * CompilerAsserts.compilationConstant(cachedOperand);
91 * ... 91 * ...
92 * } 92 * }
93 * 93 *
94 * Example executions: 94 * Example executions:
110 * specializations defined an {@link UnsupportedSpecializationException} is thrown. The default 110 * specializations defined an {@link UnsupportedSpecializationException} is thrown. The default
111 * specialization instantiation limit is <code>3</code>. 111 * specialization instantiation limit is <code>3</code>.
112 * 112 *
113 * <pre> 113 * <pre>
114 * &#064;Specialization(guards = &quot;operand == cachedOperand&quot;) 114 * &#064;Specialization(guards = &quot;operand == cachedOperand&quot;)
115 * void doCached(int operand, @Cached(&quot;operand&quot;) int cachedOperand) { 115 * void doCached(int operand, {@code @Cached}(&quot;operand&quot;) int cachedOperand) {
116 * CompilerAsserts.compilationConstant(cachedOperand); 116 * CompilerAsserts.compilationConstant(cachedOperand);
117 * ... 117 * ...
118 * } 118 * }
119 * 119 *
120 * Example executions: 120 * Example executions:
138 * instantiated. Alternatively if the <code>contains</code> relation is omitted then all 138 * instantiated. Alternatively if the <code>contains</code> relation is omitted then all
139 * <code>doCached</code> instances remain but no new instances are created. 139 * <code>doCached</code> instances remain but no new instances are created.
140 * 140 *
141 * <code> 141 * <code>
142 * &#064;Specialization(guards = &quot;operand == cachedOperand&quot;) 142 * &#064;Specialization(guards = &quot;operand == cachedOperand&quot;)
143 * void doCached(int operand, @Cached(&quot;operand&quot;) int cachedOperand) { 143 * void doCached(int operand, {@code @Cached}(&quot;operand&quot;) int cachedOperand) {
144 * CompilerAsserts.compilationConstant(cachedOperand); 144 * CompilerAsserts.compilationConstant(cachedOperand);
145 * ... 145 * ...
146 * } 146 * }
147 * 147 *
148 * &#064;Specialization(contains = &quot;doCached&quot;) 148 * &#064;Specialization(contains = &quot;doCached&quot;)
171 * This next example shows how methods from the enclosing node can be used to initialize cached 171 * This next example shows how methods from the enclosing node can be used to initialize cached
172 * parameters. Please note that the visibility of transformLocal must not be <code>private</code>. 172 * parameters. Please note that the visibility of transformLocal must not be <code>private</code>.
173 * 173 *
174 * <pre> 174 * <pre>
175 * &#064;Specialization 175 * &#064;Specialization
176 * void s(int operand, @Cached(&quot;transformLocal(operand)&quot;) int cachedOperand) { 176 * void s(int operand, {@code @Cached}(&quot;transformLocal(operand)&quot;) int cachedOperand) {
177 * } 177 * }
178 * 178 *
179 * int transformLocal(int operand) { 179 * int transformLocal(int operand) {
180 * return operand & 0x42; 180 * return operand & 0x42;
181 * } 181 * }
186 * The <code>new</code> keyword can be used to initialize a cached parameter using a constructor of 186 * The <code>new</code> keyword can be used to initialize a cached parameter using a constructor of
187 * the parameter type. 187 * the parameter type.
188 * 188 *
189 * <pre> 189 * <pre>
190 * &#064;Specialization 190 * &#064;Specialization
191 * void s(Object operand, @Cached(&quot;new()&quot;) OtherNode someNode) { 191 * void s(Object operand, {@code @Cached}(&quot;new()&quot;) OtherNode someNode) {
192 * someNode.execute(operand); 192 * someNode.execute(operand);
193 * } 193 * }
194 * 194 *
195 * static class OtherNode extends Node { 195 * static class OtherNode extends Node {
196 * 196 *
207 * just referencing its static factory method and its parameters. In this case 207 * just referencing its static factory method and its parameters. In this case
208 * {@link BranchProfile#create()} is used to instantiate the {@link BranchProfile} instance. 208 * {@link BranchProfile#create()} is used to instantiate the {@link BranchProfile} instance.
209 * 209 *
210 * <pre> 210 * <pre>
211 * &#064;Specialization 211 * &#064;Specialization
212 * void s(int operand, @Cached(&quot;create()&quot;) BranchProfile profile) { 212 * void s(int operand, {@code @Cached}(&quot;create()&quot;) BranchProfile profile) {
213 * } 213 * }
214 * </pre> 214 * </pre>
215 * 215 *
216 * </li> 216 * </li>
217 * </ol> 217 * </ol>