com.oracle.truffle.api.nodes.Node.atomic()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(630)

本文整理了Java中com.oracle.truffle.api.nodes.Node.atomic()方法的一些代码示例,展示了Node.atomic()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.atomic()方法的具体详情如下:
包路径:com.oracle.truffle.api.nodes.Node
类名称:Node
方法名:atomic

Node.atomic介绍

暂无

代码示例

代码示例来源:origin: com.oracle/truffle

  1. public static <T extends Node & DSLNode> T rewriteUninitialized(final Node uninitialized, final T newNode) {
  2. return uninitialized.atomic(new Callable<T>() {
  3. public T call() {
  4. Node prev = getPrevious(uninitialized);
  5. if (prev == null) {
  6. newNode.adoptChildren0(uninitialized, null);
  7. return uninitialized.replace(newNode, "Uninitialized monomorphic");
  8. } else {
  9. return appendPolymorphic(uninitialized, newNode);
  10. }
  11. }
  12. });
  13. }

代码示例来源:origin: com.oracle/truffle

  1. public static <T extends Node & DSLNode> T rewrite(final Node thisNode, final T newNode, final String message) {
  2. return thisNode.atomic(new Callable<T>() {
  3. public T call() {
  4. assert newNode != null;
  5. if (getNext(thisNode) != null || getPrevious(thisNode) != null) {
  6. // already polymorphic -> append
  7. return appendPolymorphic(findUninitialized(thisNode), newNode);
  8. } else if (includes(thisNode, newNode)) {
  9. // included -> remains monomorphic
  10. newNode.adoptChildren0(thisNode, null);
  11. return thisNode.replace(newNode, message);
  12. } else {
  13. // goto polymorphic
  14. return null;
  15. }
  16. }
  17. });
  18. }

代码示例来源:origin: com.oracle/truffle

  1. public static <T extends Node & DSLNode> T rewriteToPolymorphic(final Node oldNode, final DSLNode uninitializedDSL, final T polymorphic, final DSLNode currentCopy, final DSLNode newNodeDSL,
  2. final String message) {
  3. return oldNode.atomic(new Callable<T>() {
  4. public T call() {
  5. assert getNext(oldNode) == null;
  6. assert getPrevious(oldNode) == null;
  7. assert newNodeDSL != null;
  8. Node uninitialized = (Node) uninitializedDSL;
  9. Node newNode = (Node) newNodeDSL;
  10. polymorphic.adoptChildren0(oldNode, (Node) currentCopy);
  11. updateSourceSection(oldNode, uninitialized);
  12. // new specialization
  13. updateSourceSection(oldNode, newNode);
  14. newNodeDSL.adoptChildren0(null, uninitialized);
  15. currentCopy.adoptChildren0(null, newNode);
  16. oldNode.replace(polymorphic, message);
  17. assert newNode != null ? currentCopy.getNext0() == newNode : currentCopy.getNext0() == uninitialized;
  18. assert uninitializedDSL.getNext0() == null;
  19. return polymorphic;
  20. }
  21. });
  22. }

代码示例来源:origin: org.graalvm.truffle/truffle-api

  1. /**
  2. * Replaces this node with another node. If there is a source section (see
  3. * {@link #getSourceSection()}) associated with this node, it is transferred to the new node.
  4. *
  5. * @param newNode the new node that is the replacement
  6. * @param reason a description of the reason for the replacement
  7. * @return the new node
  8. * @since 0.8 or earlier
  9. */
  10. public final <T extends Node> T replace(final T newNode, final CharSequence reason) {
  11. CompilerDirectives.transferToInterpreterAndInvalidate();
  12. atomic(new Runnable() {
  13. public void run() {
  14. replaceHelper(newNode, reason);
  15. }
  16. });
  17. return newNode;
  18. }

代码示例来源:origin: com.oracle/truffle

  1. /**
  2. * Replaces this node with another node. If there is a source section (see
  3. * {@link #getSourceSection()}) associated with this node, it is transferred to the new node.
  4. *
  5. * @param newNode the new node that is the replacement
  6. * @param reason a description of the reason for the replacement
  7. * @return the new node
  8. */
  9. public final <T extends Node> T replace(final T newNode, final CharSequence reason) {
  10. CompilerDirectives.transferToInterpreterAndInvalidate();
  11. atomic(new Runnable() {
  12. public void run() {
  13. replaceHelper(newNode, reason);
  14. }
  15. });
  16. return newNode;
  17. }

代码示例来源:origin: com.oracle.truffle/truffle-api

  1. /**
  2. * Replaces this node with another node. If there is a source section (see
  3. * {@link #getSourceSection()}) associated with this node, it is transferred to the new node.
  4. *
  5. * @param newNode the new node that is the replacement
  6. * @param reason a description of the reason for the replacement
  7. * @return the new node
  8. * @since 0.8 or earlier
  9. */
  10. public final <T extends Node> T replace(final T newNode, final CharSequence reason) {
  11. CompilerDirectives.transferToInterpreterAndInvalidate();
  12. atomic(new Runnable() {
  13. public void run() {
  14. replaceHelper(newNode, reason);
  15. }
  16. });
  17. return newNode;
  18. }

相关文章