Search in sources :

Example 21 with SourceSectionFilter

use of com.oracle.truffle.api.instrumentation.SourceSectionFilter in project graal by oracle.

the class InputFilterTest method testNoInputFilter.

@Test
public void testNoInputFilter() {
    SourceSectionFilter expressionFilter = SourceSectionFilter.newBuilder().tagIs(StandardTags.ExpressionTag.class).build();
    instrumenter.attachExecutionEventFactory(expressionFilter, null, factory);
    execute("ROOT(EXPRESSION(EXPRESSION,EXPRESSION))");
    assertOn(ENTER);
    assertOn(ENTER);
    assertOn(RETURN_VALUE, (e) -> {
        assertEquals("()", e.result);
        assertArrayEquals(new Object[0], e.inputs);
    });
    assertOn(ENTER);
    assertOn(RETURN_VALUE, (e) -> {
        assertEquals("()", e.result);
        assertArrayEquals(new Object[0], e.inputs);
    });
    assertOn(RETURN_VALUE, (e) -> {
        assertEquals("(()+())", e.result);
        assertArrayEquals(new Object[0], e.inputs);
    });
}
Also used : SourceSectionFilter(com.oracle.truffle.api.instrumentation.SourceSectionFilter) Test(org.junit.Test)

Example 22 with SourceSectionFilter

use of com.oracle.truffle.api.instrumentation.SourceSectionFilter in project graal by oracle.

the class InstrumentableNodeTest method testTagIsNot.

/*
     * First instrument statements and then instrument expressions to test materialization at
     * locations where there is already a wrapper.
     */
@Test
public void testTagIsNot() {
    SourceSectionFilter filter;
    filter = SourceSectionFilter.newBuilder().tagIsNot(StandardTags.RootTag.class).build();
    instrumenter.attachExecutionEventFactory(filter, null, factory);
    execute("MATERIALIZE_CHILD_EXPRESSION");
    assertOn(ENTER, (e) -> {
        assertTrue(e.context.getInstrumentedNode() instanceof MaterializedChildExpressionNode);
    });
    assertOn(ENTER, (e) -> {
        assertTrue(e.context.getInstrumentedNode() instanceof ExpressionNode);
    });
    assertOn(RETURN_VALUE, (e) -> {
        assertTrue(e.context.getInstrumentedNode() instanceof ExpressionNode);
    });
    assertOn(RETURN_VALUE, (e) -> {
        assertTrue(e.context.getInstrumentedNode() instanceof MaterializedChildExpressionNode);
    });
}
Also used : ExpressionNode(com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.ExpressionNode) MaterializeChildExpressionNode(com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.MaterializeChildExpressionNode) MaterializedChildExpressionNode(com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.MaterializedChildExpressionNode) MaterializedChildExpressionNode(com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.MaterializedChildExpressionNode) SourceSectionFilter(com.oracle.truffle.api.instrumentation.SourceSectionFilter) StandardTags(com.oracle.truffle.api.instrumentation.StandardTags) Test(org.junit.Test)

Example 23 with SourceSectionFilter

use of com.oracle.truffle.api.instrumentation.SourceSectionFilter in project graal by oracle.

the class InstrumentableNodeTest method testNoSourceSectionWithFilter.

@Test
public void testNoSourceSectionWithFilter() {
    SourceSectionFilter filter = SourceSectionFilter.newBuilder().tagIs(BlockTag.class).lineIn(1, 1).build();
    instrumenter.attachExecutionEventFactory(filter, null, factory);
    execute("BLOCK_NO_SOURCE_SECTION(BLOCK())");
    assertOn(ENTER, (e) -> {
        assertProperties(e.context.getNodeObject(), "simpleName", "BlockNode");
    });
    assertOn(RETURN_VALUE, (e) -> {
        assertProperties(e.context.getNodeObject(), "simpleName", "BlockNode");
    });
}
Also used : SourceSectionFilter(com.oracle.truffle.api.instrumentation.SourceSectionFilter) Test(org.junit.Test)

Example 24 with SourceSectionFilter

use of com.oracle.truffle.api.instrumentation.SourceSectionFilter in project graal by oracle.

the class InstrumentableNodeTest method testNoSourceSectionNoFilter.

@Test
public void testNoSourceSectionNoFilter() {
    SourceSectionFilter filter = SourceSectionFilter.newBuilder().tagIs(BlockTag.class).build();
    instrumenter.attachExecutionEventFactory(filter, null, factory);
    execute("BLOCK_NO_SOURCE_SECTION(BLOCK())");
    assertOn(ENTER, (e) -> {
        assertProperties(e.context.getNodeObject(), "simpleName", "BlockNoSourceSectionNode");
    });
    assertOn(ENTER, (e) -> {
        assertProperties(e.context.getNodeObject(), "simpleName", "BlockNode");
    });
    assertOn(RETURN_VALUE, (e) -> {
        assertProperties(e.context.getNodeObject(), "simpleName", "BlockNode");
    });
    assertOn(RETURN_VALUE, (e) -> {
        assertProperties(e.context.getNodeObject(), "simpleName", "BlockNoSourceSectionNode");
    });
}
Also used : BlockTag(com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.BlockTag) SourceSectionFilter(com.oracle.truffle.api.instrumentation.SourceSectionFilter) Test(org.junit.Test)

Example 25 with SourceSectionFilter

use of com.oracle.truffle.api.instrumentation.SourceSectionFilter in project graal by oracle.

the class InstrumentableNodeTest method testSimpleMaterializeSyntaxWithInput.

/*
     * Directly instrument and materialize all nodes with input values.
     */
@Test
public void testSimpleMaterializeSyntaxWithInput() {
    SourceSectionFilter filter = SourceSectionFilter.newBuilder().tagIs(StandardTags.StatementTag.class, StandardTags.ExpressionTag.class).build();
    instrumenter.attachExecutionEventFactory(filter, filter, factory);
    execute("MATERIALIZE_CHILD_EXPRESSION");
    assertOn(ENTER, (e) -> {
        assertTrue(e.context.getInstrumentedNode() instanceof MaterializedChildExpressionNode);
    });
    assertOn(ENTER, (e) -> {
        assertTrue(e.context.getInstrumentedNode() instanceof ExpressionNode);
    });
    assertOn(RETURN_VALUE, (e) -> {
        assertTrue(e.context.getInstrumentedNode() instanceof ExpressionNode);
    });
    assertOn(INPUT_VALUE, (e) -> {
        assertTrue(e.context.getInstrumentedNode() instanceof MaterializedChildExpressionNode);
    });
    assertOn(RETURN_VALUE, (e) -> {
        assertTrue(e.context.getInstrumentedNode() instanceof MaterializedChildExpressionNode);
    });
}
Also used : ExpressionNode(com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.ExpressionNode) MaterializeChildExpressionNode(com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.MaterializeChildExpressionNode) MaterializedChildExpressionNode(com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.MaterializedChildExpressionNode) ExpressionTag(com.oracle.truffle.api.instrumentation.StandardTags.ExpressionTag) MaterializedChildExpressionNode(com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.MaterializedChildExpressionNode) SourceSectionFilter(com.oracle.truffle.api.instrumentation.SourceSectionFilter) Test(org.junit.Test)

Aggregations

SourceSectionFilter (com.oracle.truffle.api.instrumentation.SourceSectionFilter)32 Test (org.junit.Test)21 StandardTags (com.oracle.truffle.api.instrumentation.StandardTags)7 Source (com.oracle.truffle.api.source.Source)7 ExpressionNode (com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.ExpressionNode)5 MaterializeChildExpressionNode (com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.MaterializeChildExpressionNode)5 MaterializedChildExpressionNode (com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.MaterializedChildExpressionNode)5 ExpressionTag (com.oracle.truffle.api.instrumentation.StandardTags.ExpressionTag)4 InstrumentableNode (com.oracle.truffle.api.instrumentation.InstrumentableNode)3 Node (com.oracle.truffle.api.nodes.Node)3 RootNode (com.oracle.truffle.api.nodes.RootNode)3 EventContext (com.oracle.truffle.api.instrumentation.EventContext)2 ExecutionEventNodeFactory (com.oracle.truffle.api.instrumentation.ExecutionEventNodeFactory)2 Instrumenter (com.oracle.truffle.api.instrumentation.Instrumenter)2 ProbeNode (com.oracle.truffle.api.instrumentation.ProbeNode)2 Builder (com.oracle.truffle.api.instrumentation.SourceSectionFilter.Builder)2 SourceSection (com.oracle.truffle.api.source.SourceSection)2 Source (org.graalvm.polyglot.Source)2 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)1 AllocationListener (com.oracle.truffle.api.instrumentation.AllocationListener)1