Mercurial > hg > truffle
comparison graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/SpecializationNode.java @ 19758:f682b9e6ca07
Truffle: expose non-atomic replace API to Truffle DSL to avoid multiple RootNode lookups for multiple replaces in one atomic block.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 10 Mar 2015 19:38:07 +0100 |
parents | e8d2f3f95dcd |
children | 8caabd6cf363 |
comparison
equal
deleted
inserted
replaced
19757:e8d2f3f95dcd | 19758:f682b9e6ca07 |
---|---|
299 private static SpecializationNode removeSameImpl(SpecializationNode toRemove, CharSequence reason) { | 299 private static SpecializationNode removeSameImpl(SpecializationNode toRemove, CharSequence reason) { |
300 SpecializationNode start = toRemove.findStart(); | 300 SpecializationNode start = toRemove.findStart(); |
301 SpecializationNode current = start; | 301 SpecializationNode current = start; |
302 while (current != null) { | 302 while (current != null) { |
303 if (current.isSame(toRemove)) { | 303 if (current.isSame(toRemove)) { |
304 current.replace(current.next, reason); | 304 NodeUtil.nonAtomicReplace(current, current.next, reason); |
305 if (current == start) { | 305 if (current == start) { |
306 start = start.next; | 306 start = start.next; |
307 } | 307 } |
308 } | 308 } |
309 current = current.next; | 309 current = current.next; |
530 // existing node | 530 // existing node |
531 return start; | 531 return start; |
532 } | 532 } |
533 } | 533 } |
534 | 534 |
535 static <T> SpecializationNode insertAt(SpecializationNode node, SpecializationNode insertBefore, CharSequence message) { | 535 static <T> SpecializationNode insertAt(SpecializationNode node, SpecializationNode insertBefore, CharSequence reason) { |
536 insertBefore.next = node; | 536 insertBefore.next = node; |
537 return node.replace(insertBefore, message); | 537 // always guaranteed to be executed inside of an atomic block |
538 return NodeUtil.nonAtomicReplace(node, insertBefore, reason); | |
538 } | 539 } |
539 | 540 |
540 @Override | 541 @Override |
541 public final String toString() { | 542 public final String toString() { |
542 Class<?> clazz = getClass(); | 543 Class<?> clazz = getClass(); |