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

The following examples show how to use com.oracle.truffle.api.instrumentation.SourceSectionFilter. 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 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 #2
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 #3
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 #4
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();
                    }
                }
            };
        }
    });
}