/** * 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; }
/** * 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; }
DefaultScopeVariables(Node node) { this.root = node.getRootNode(); }
public String displayMethodName(Node node) { if (node == null) { return null; } RootNode root = node.getRootNode(); if (root == null) { return "unknown"; } return root.getCallTarget().toString(); }
public final void atomic(Runnable closure) { RootNode rootNode = getRootNode(); synchronized (rootNode != null ? rootNode : GIL) { assert enterAtomic(); try { closure.run(); } finally { assert exitAtomic(); } } }
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); }
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); }
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); }
RootNode findCurrentRoot() { Node node = traceElement.getLocation(); if (node != null) { return node.getRootNode(); } RootCallTarget target = traceElement.getTarget(); return target.getRootNode(); }
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); } }
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>"; } }
Set<Class<?>> getProvidedTags(Node root) { return getProvidedTags(AccessorInstrumentHandler.nodesAccess().getLanguage(root.getRootNode())); }
@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); } }
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); } }
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); }
@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); } } } }
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()); }
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()); }
protected CallTarget parse(Source code, Node context, String... argumentNames) { RootNode rootNode = context.getRootNode(); return languageSupport().parse(engineSupport().getEnvForInstrument(rootNode.getLanguageInfo()), code, context, argumentNames); }
protected CallTarget parse(Source code, Node context, String... argumentNames) { RootNode rootNode = context.getRootNode(); return languageSupport().parse(engineSupport().getEnvForInstrument(rootNode.getLanguageInfo()), code, context, argumentNames); }