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

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

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

Node.getRootNode介绍

[英]Get the root node of the tree a node belongs to.
[中]获取节点所属树的根节点。

代码示例

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

/**
 * Returns a lock object that can be used to synchronize modifications to the AST. Don't lock if
 * you call into foreign code with potential recursions to avoid deadlocks. Use responsibly.
 *
 * @since 0.19
 */
protected final Lock getLock() {
  // Major Assumption: parent is never null after a node got adopted
  // it is never reset to null, and thus, rootNode is always reachable.
  // GIL: used for nodes that are replace in ASTs that are not yet adopted
  RootNode root = getRootNode();
  return root == null ? GIL_LOCK : root.lock;
}

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

/**
 * Returns a lock object that can be used to synchronize modifications to the AST. Don't lock if
 * you call into foreign code with potential recursions to avoid deadlocks. Use responsibly.
 *
 * @since 0.19
 */
protected final Lock getLock() {
  // Major Assumption: parent is never null after a node got adopted
  // it is never reset to null, and thus, rootNode is always reachable.
  // GIL: used for nodes that are replace in ASTs that are not yet adopted
  RootNode root = getRootNode();
  return root == null ? GIL_LOCK : root.lock;
}

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

DefaultScopeVariables(Node node) {
  this.root = node.getRootNode();
}

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

public String displayMethodName(Node node) {
  if (node == null) {
    return null;
  }
  RootNode root = node.getRootNode();
  if (root == null) {
    return "unknown";
  }
  return root.getCallTarget().toString();
}

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

public final void atomic(Runnable closure) {
  RootNode rootNode = getRootNode();
  synchronized (rootNode != null ? rootNode : GIL) {
    assert enterAtomic();
    try {
      closure.run();
    } finally {
      assert exitAtomic();
    }
  }
}

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

private static TruffleLanguage.Env getLangEnv(Node node) {
  LanguageInfo languageInfo = node.getRootNode().getLanguageInfo();
  if (languageInfo == null) {
    throw new IllegalArgumentException("No language available for given node.");
  }
  return AccessorInstrumentHandler.engineAccess().getEnvForInstrument(languageInfo);
}

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

private static TruffleLanguage.Env getLangEnv(Node node) {
  LanguageInfo languageInfo = node.getRootNode().getLanguageInfo();
  if (languageInfo == null) {
    throw new IllegalArgumentException("No language available for given node.");
  }
  return AccessorInstrumentHandler.engineAccess().getEnvForInstrument(languageInfo);
}

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

private static Set<Class<?>> getProvidedTags(Node node) {
  Objects.requireNonNull(node);
  RootNode root = node.getRootNode();
  if (root == null) {
    return Collections.emptySet();
  }
  Object sourceVM = InstrumentationHandler.AccessorInstrumentHandler.nodesAccess().getSourceVM(root);
  if (sourceVM == null) {
    return Collections.emptySet();
  }
  InstrumentationHandler handler = (InstrumentationHandler) InstrumentationHandler.AccessorInstrumentHandler.engineAccess().getInstrumentationHandler(sourceVM);
  return handler.getProvidedTags(node);
}

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

RootNode findCurrentRoot() {
  Node node = traceElement.getLocation();
  if (node != null) {
    return node.getRootNode();
  }
  RootCallTarget target = traceElement.getTarget();
  return target.getRootNode();
}

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

public String getRootName() {
  RootNode rootNode = context.getInstrumentedNode().getRootNode();
  if (rootNode == null) {
    // defensive check
    return null;
  }
  try {
    return rootNode.getName();
  } catch (Throwable t) {
    throw wrapHostError(t);
  }
}

代码示例来源:origin: org.graalvm.tools/profiler

private static String extractRootName(Node instrumentedNode) {
  RootNode rootNode = instrumentedNode.getRootNode();
  if (rootNode != null) {
    if (rootNode.getName() == null) {
      return rootNode.toString();
    } else {
      return rootNode.getName();
    }
  } else {
    return "<Unknown>";
  }
}

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

Set<Class<?>> getProvidedTags(Node root) {
  return getProvidedTags(AccessorInstrumentHandler.nodesAccess().getLanguage(root.getRootNode()));
}

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

@Override
protected void onDispose(VirtualFrame frame) {
  FrameDescriptor frameDescriptor = context.getInstrumentedNode().getRootNode().getFrameDescriptor();
  if (frameDescriptor.getIdentifiers().contains(KEY_TIME_STARTED)) {
    frameDescriptor.removeFrameSlot(KEY_TIME_STARTED);
  }
  if (frameDescriptor.getIdentifiers().contains(KEY_PARENT_COUNTER)) {
    frameDescriptor.removeFrameSlot(KEY_PARENT_COUNTER);
  }
}

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

private ExecutionEventNode createCountingNode(EventContext context) {
  SourceSection sourceSection = context.getInstrumentedSourceSection();
  Counter counter = counters.get(sourceSection);
  if (counter == null) {
    final RootNode rootNode = context.getInstrumentedNode().getRootNode();
    counter = new Counter(sourceSection, rootNode == null ? "<unknown>>" : rootNode.getName());
    counters.put(sourceSection, counter);
  }
  if (isTiming) {
    return TimedCounterNode.create(this, counter, context);
  } else {
    return new CounterNode(this, counter);
  }
}

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

TimedCounterNode(Profiler profiler, Counter counter, EventContext context) {
  super(profiler, counter);
  this.context = context;
  FrameDescriptor frameDescriptor = context.getInstrumentedNode().getRootNode().getFrameDescriptor();
  this.timeStartedSlot = frameDescriptor.findOrAddFrameSlot(KEY_TIME_STARTED, "profiler:timeStarted", FrameSlotKind.Long);
  this.parentCounterSlot = frameDescriptor.findOrAddFrameSlot(KEY_PARENT_COUNTER, "profiler:parentCounter", FrameSlotKind.Object);
}

代码示例来源:origin: org.graalvm.compiler/compiler

@Override
  protected void reportPolymorphicSpecialize(Node source) {
    if (TruffleRuntimeOptions.getValue(SharedTruffleRuntimeOptions.TruffleExperimentalSplitting)) {
      TruffleSplittingStrategy.newPolymorphicSpecialize(source);
      final RootNode rootNode = source.getRootNode();
      final OptimizedCallTarget callTarget = rootNode == null ? null : (OptimizedCallTarget) rootNode.getCallTarget();
      if (callTarget != null) {
        callTarget.polymorphicSpecialize(source);
      }
    }
  }
}

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

static Iterable<Scope> lexicalScope(Node node, Frame frame) {
  RootNode root = node.getRootNode();
  String name = root.getName();
  if (name == null) {
    name = "local";
  }
  return Collections.singletonList(Scope.newBuilder(name, getVariables(root, frame)).node(root).arguments(getArguments(frame)).build());
}

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

static Iterable<Scope> lexicalScope(Node node, Frame frame) {
  RootNode root = node.getRootNode();
  String name = root.getName();
  if (name == null) {
    name = "local";
  }
  return Collections.singletonList(Scope.newBuilder(name, getVariables(root, frame)).node(root).arguments(getArguments(frame)).build());
}

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

protected CallTarget parse(Source code, Node context, String... argumentNames) {
  RootNode rootNode = context.getRootNode();
  return languageSupport().parse(engineSupport().getEnvForInstrument(rootNode.getLanguageInfo()), code, context, argumentNames);
}

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

protected CallTarget parse(Source code, Node context, String... argumentNames) {
  RootNode rootNode = context.getRootNode();
  return languageSupport().parse(engineSupport().getEnvForInstrument(rootNode.getLanguageInfo()), code, context, argumentNames);
}

相关文章