com.oracle.truffle.api.instrumentation.StandardTags Java Examples

The following examples show how to use com.oracle.truffle.api.instrumentation.StandardTags. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RawEventsTracingSupport.java    From nodeprof.js with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static final String getTagNames(JavaScriptNode node) {
    String tags = "";

    if (node.hasTag(StandardTags.StatementTag.class)) {
        tags += "STMT ";
    }
    if (node.hasTag(StandardTags.RootTag.class)) {
        tags += "ROOT ";
    }
    if (node.hasTag(StandardTags.RootBodyTag.class)) {
        tags += "BODY ";
    }
    for (Class<?> c : ALL) {
        if (node.hasTag((Class<? extends Tag>) c)) {
            tags += c.getSimpleName() + " ";
        }
    }
    return tags;
}
 
Example #2
Source File: HashemStatementNode.java    From mr-hashemi with Universal Permissive License v1.0 5 votes vote down vote up
public boolean hasTag(Class<? extends Tag> tag) {
    if (tag == StandardTags.StatementTag.class) {
        return hasStatementTag;
    } else if (tag == StandardTags.RootTag.class || tag == StandardTags.RootBodyTag.class) {
        return hasRootTag;
    }
    return false;
}
 
Example #3
Source File: HashemInvokeNode.java    From mr-hashemi with Universal Permissive License v1.0 5 votes vote down vote up
@Override
public boolean hasTag(Class<? extends Tag> tag) {
    if (tag == StandardTags.CallTag.class) {
        return true;
    }
    return super.hasTag(tag);
}
 
Example #4
Source File: HashemExpressionNode.java    From mr-hashemi with Universal Permissive License v1.0 5 votes vote down vote up
@Override
public boolean hasTag(Class<? extends Tag> tag) {
    if (tag == StandardTags.ExpressionTag.class) {
        return hasExpressionTag;
    }
    return super.hasTag(tag);
}
 
Example #5
Source File: RawEventsTracingSupport.java    From nodeprof.js with Apache License 2.0 5 votes vote down vote up
@TruffleBoundary
public static void enable(Instrumenter instrumenter) {
    if (enabled == false) {
        SourceSectionFilter sourceSectionFilter = SourceSectionFilter.newBuilder().sourceIs(AnalysisFilterSourceList.getDefault()).tagIs(ALL).build();
        SourceSectionFilter inputGeneratingObjects = SourceSectionFilter.newBuilder().tagIs(
                        StandardTags.ExpressionTag.class,
                        JSTags.InputNodeTag.class).build();
        instrumenter.attachExecutionEventFactory(sourceSectionFilter, inputGeneratingObjects, getFactory());
        Logger.info("Low-level event tracing enabled [SVM: " + JSConfig.SubstrateVM + "]");
        enabled = true;
    }
}
 
Example #6
Source File: NodeProfAnalysis.java    From nodeprof.js with Apache License 2.0 5 votes vote down vote up
@TruffleBoundary
public void onAllCallback(ExecutionEventNodeFactory factory,
                SourcePredicate sourcePredicate) {
    getInstrumenter().attachExecutionEventFactory(
                    SourceSectionFilter.newBuilder().tagIs(ProfiledTagEnum.getTags()).sourceIs(sourcePredicate).build(),
                    SourceSectionFilter.newBuilder().tagIs(StandardTags.ExpressionTag.class, JSTags.InputNodeTag.class).build(),
                    factory);
}
 
Example #7
Source File: NodeProfAnalysis.java    From nodeprof.js with Apache License 2.0 5 votes vote down vote up
@TruffleBoundary
public void onSingleTagCallback(Class<? extends Tag> tag, ExecutionEventNodeFactory factory,
                SourcePredicate sourcePredicate) {
    getInstrumenter().attachExecutionEventFactory(
                    SourceSectionFilter.newBuilder().tagIs(tag).sourceIs(sourcePredicate).build(),
                    SourceSectionFilter.newBuilder().tagIs(StandardTags.ExpressionTag.class, JSTags.InputNodeTag.class).build(),
                    factory);
}
 
Example #8
Source File: DebugInstrument.java    From nodeprof.js with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(final Env env) {
    instrumenter = env.getInstrumenter();
    env.registerService(this);
    SourceSectionFilter sourceSectionFilter = SourceSectionFilter.newBuilder().tagIs(JSTags.ALL).build();
    // What generates the input events to track?
    SourceSectionFilter inputGeneratingObjects = SourceSectionFilter.newBuilder().tagIs(
                    StandardTags.ExpressionTag.class,
                    StandardTags.StatementTag.class,
                    InputNodeTag.class).build();
    env.getInstrumenter().attachExecutionEventFactory(sourceSectionFilter, inputGeneratingObjects, new ExecutionEventNodeFactory() {
        public ExecutionEventNode create(EventContext context) {
            // TODO Auto-generated method stub
            return new ExecutionEventNode() {
                @Node.Child private InteropLibrary dispatch = InteropLibrary.getFactory().createDispatched(5);

                @TruffleBoundary
                @Override
                public void onEnter(VirtualFrame frame) {
                    /*
                     * Internal sources are executed at engine startup time. Such sources
                     * include internal code for the registration of builtins like Promise. We
                     * skip all these internal events to ensure that tests are deterministic.
                     */
                    DynamicObject func = (DynamicObject) frame.getArguments()[1];
                    try {
                        dispatch.execute(JSFunction.createEmptyFunction(JSObject.getJSContext(func).getRealm()));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            };
        }
    });
}
 
Example #9
Source File: SendBytecodes.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Override
public final boolean hasTag(final Class<? extends Tag> tag) {
    if (tag == StandardTags.CallTag.class) {
        return true;
    }
    if (tag == DebuggerTags.AlwaysHalt.class) {
        return PrimExitToDebuggerNode.SELECTOR_NAME.equals(selector.asStringUnsafe());
    }
    return super.hasTag(tag);
}
 
Example #10
Source File: TruffleAST.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static void fillNode(Node node, StringBuilder nodes) {
    nodes.append(node.getClass().getName());
    nodes.append('\n');
    nodes.append(node.getDescription());
    nodes.append('\n');
    SourceSection ss = node.getSourceSection();
    if (ss == null) {
        nodes.append('\n');
    } else {
        nodes.append(ss.getSource().getURI().toString());
        nodes.append('\n');
        nodes.append(Integer.toString(ss.getStartLine()));
        nodes.append(':');
        nodes.append(Integer.toString(ss.getStartColumn()));
        nodes.append('-');
        nodes.append(Integer.toString(ss.getEndLine()));
        nodes.append(':');
        nodes.append(Integer.toString(ss.getEndColumn()));
        nodes.append('\n');
        //nodes.add(ss.getCode());
    }
    // TAGS:
    try {
        StringBuilder tags = new StringBuilder();
        if (node instanceof InstrumentableNode) {
            InstrumentableNode inode = (InstrumentableNode) node;
            for (Class<?> tag : StandardTags.class.getDeclaredClasses()) {
                if (Tag.class.isAssignableFrom(tag)) {
                    if (inode.hasTag(tag.asSubclass(Tag.class))) {
                        if (tags.length() > 0) {
                            tags.append(',');
                        }
                        tags.append(tag.getSimpleName());
                    }
                }
            }
        }
        nodes.append(tags);
    } catch (Throwable t) {
    }
    nodes.append('\n');
    List<Node> ch = NodeUtil.findNodeChildren(node);
    nodes.append(Integer.toString(ch.size()));
    nodes.append('\n');
    for (Node n : ch) {
        fillNode(n, nodes);
    }
}
 
Example #11
Source File: ExecuteContextNode.java    From trufflesqueak with MIT License 4 votes vote down vote up
@Override
public boolean hasTag(final Class<? extends Tag> tag) {
    return StandardTags.RootTag.class == tag;
}
 
Example #12
Source File: PushBytecodes.java    From trufflesqueak with MIT License 4 votes vote down vote up
@Override
public boolean hasTag(final Class<? extends Tag> tag) {
    return tag == StandardTags.StatementTag.class;
}
 
Example #13
Source File: AbstractInstrumentableBytecodeNode.java    From trufflesqueak with MIT License 4 votes vote down vote up
@Override
public boolean hasTag(final Class<? extends Tag> tag) {
    return tag == StandardTags.StatementTag.class;
}