comparison graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Cached.java @ 19300:67ab244ab689

Truffle-DSL: fix formatting issues.
author Christian Humer <christian.humer@gmail.com>
date Wed, 11 Feb 2015 18:33:49 +0100
parents 3a37116ef37f
children b249bdba508b
comparison
equal deleted inserted replaced
19299:8e4f683e16d9 19300:67ab244ab689
88 * &#064;Specialization 88 * &#064;Specialization
89 * void doCached(int operand, @Local(&quot;operand&quot;) int cachedOperand) { 89 * void doCached(int operand, @Local(&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:
95 * execute(1) => doCached(1, 1) // new instantiation, localOperand is bound to 1 95 * execute(1) => doCached(1, 1) // new instantiation, localOperand is bound to 1
96 * execute(0) => doCached(0, 1) 96 * execute(0) => doCached(0, 1)
97 * execute(2) => doCached(2, 1) 97 * execute(2) => doCached(2, 1)
98 * 98 *
136 * <code>doNormal</code> specialization uses <code>contains=&quot;doCached&quot;</code> to specify 136 * <code>doNormal</code> specialization uses <code>contains=&quot;doCached&quot;</code> to specify
137 * that all instantiations of <code>doCached</code> get removed if <code>doNormal</code> is 137 * that all instantiations of <code>doCached</code> get removed if <code>doNormal</code> is
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 * <pre> 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, @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;)
149 * void doNormal(int operand) {...} 149 * void doNormal(int operand) {...}
150 * 150 *
151 * Example executions with contains = &quot;doCached&quot;: 151 * Example executions with contains = &quot;doCached&quot;:
152 * execute(0) => doCached(0, 0) // new instantiation, cachedOperand is bound to 0 152 * execute(0) => doCached(0, 0) // new instantiation, cachedOperand is bound to 0
153 * execute(1) => doCached(1, 1) // new instantiation, cachedOperand is bound to 1 153 * execute(1) => doCached(1, 1) // new instantiation, cachedOperand is bound to 1
154 * execute(1) => doCached(1, 1) 154 * execute(1) => doCached(1, 1)
155 * execute(2) => doCached(2, 2) // new instantiation, cachedOperand is bound to 2 155 * execute(2) => doCached(2, 2) // new instantiation, cachedOperand is bound to 2
156 * execute(3) => doNormal(3) // new instantiation of doNormal due to limit overflow; doCached gets removed. 156 * execute(3) => doNormal(3) // new instantiation of doNormal due to limit overflow; doCached gets removed.
157 * execute(1) => doNormal(1) 157 * execute(1) => doNormal(1)
158 * 158 *
159 * Example executions without contains = &quot;doCached&quot;: 159 * Example executions without contains = &quot;doCached&quot;:
160 * execute(0) => doCached(0, 0) // new instantiation, cachedOperand is bound to 0 160 * execute(0) => doCached(0, 0) // new instantiation, cachedOperand is bound to 0
161 * execute(1) => doCached(1, 1) // new instantiation, cachedOperand is bound to 1 161 * execute(1) => doCached(1, 1) // new instantiation, cachedOperand is bound to 1
162 * execute(1) => doCached(1, 1) 162 * execute(1) => doCached(1, 1)
163 * execute(2) => doCached(2, 2) // new instantiation, cachedOperand is bound to 2 163 * execute(2) => doCached(2, 2) // new instantiation, cachedOperand is bound to 2
164 * execute(3) => doNormal(3) // new instantiation of doNormal due to limit overflow 164 * execute(3) => doNormal(3) // new instantiation of doNormal due to limit overflow
165 * execute(1) => doCached(1, 1) 165 * execute(1) => doCached(1, 1)
166 * 166 *
167 * </pre> 167 * </code>
168 * 168 *
169 * </li> 169 * </li>
170 * <li> 170 * <li>
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, @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 * }
182 * 182 *
183 * </li> 183 * </li>
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, @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 *
197 * public String execute(Object value) { 197 * public String execute(Object value) {
198 * throw new UnsupportedOperationException(); 198 * throw new UnsupportedOperationException();
199 * } 199 * }
200 * } 200 * }
201 * 201 *