comparison truffle/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/SpecializationNode.java @ 22514:6fe6d2cb7cc1

SpecializationNode: inline method removeSameImpl
author Andreas Woess <andreas.woess@oracle.com>
date Fri, 18 Dec 2015 14:29:20 +0100
parents 53d05fc21834
children
comparison
equal deleted inserted replaced
22513:8d5a558f4279 22514:6fe6d2cb7cc1
267 this.replace(this.next, reason); 267 this.replace(this.next, reason);
268 return findEnd().findStart(); 268 return findEnd().findStart();
269 } 269 }
270 270
271 protected final SpecializationNode removeSame(final CharSequence reason) { 271 protected final SpecializationNode removeSame(final CharSequence reason) {
272 return removeSameImpl(SpecializationNode.this, reason); 272 SpecializationNode start = SpecializationNode.this.findStart();
273 SpecializationNode current = start;
274 while (current != null) {
275 if (current.isSame(SpecializationNode.this)) {
276 NodeUtil.nonAtomicReplace(current, current.next, reason);
277 if (current == start) {
278 start = start.next;
279 }
280 }
281 current = current.next;
282 }
283 return SpecializationNode.this.findEnd().findStart();
273 } 284 }
274 285
275 /** Find the topmost of the specialization chain. */ 286 /** Find the topmost of the specialization chain. */
276 private SpecializationNode findStart() { 287 private SpecializationNode findStart() {
277 SpecializationNode node = this; 288 SpecializationNode node = this;
287 return node; 298 return node;
288 } 299 }
289 300
290 private Node findRoot() { 301 private Node findRoot() {
291 return findStart().getParent(); 302 return findStart().getParent();
292 }
293
294 private static SpecializationNode removeSameImpl(SpecializationNode toRemove, CharSequence reason) {
295 SpecializationNode start = toRemove.findStart();
296 SpecializationNode current = start;
297 while (current != null) {
298 if (current.isSame(toRemove)) {
299 NodeUtil.nonAtomicReplace(current, current.next, reason);
300 if (current == start) {
301 start = start.next;
302 }
303 }
304 current = current.next;
305 }
306 return toRemove.findEnd().findStart();
307 } 303 }
308 304
309 @SuppressWarnings("unused") 305 @SuppressWarnings("unused")
310 public Object acceptAndExecute(Frame frame) { 306 public Object acceptAndExecute(Frame frame) {
311 throw new UnsupportedOperationException(); 307 throw new UnsupportedOperationException();