Search in sources :

Example 1 with ExpressionNode

use of com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.ExpressionNode in project graal by oracle.

the class InstrumentableNodeTest method testLateMaterializeSyntax.

/*
     * First instrument statements and then instrument expressions to test materialization at
     * locations where there is already a wrapper.
     */
@Test
public void testLateMaterializeSyntax() {
    Source source = createSource("MATERIALIZE_CHILD_EXPRESSION");
    SourceSectionFilter filter;
    filter = SourceSectionFilter.newBuilder().tagIs(StandardTags.StatementTag.class).build();
    instrumenter.attachExecutionEventFactory(filter, null, factory);
    execute(source);
    assertOn(ENTER, (e) -> {
        assertTrue(e.context.getInstrumentedNode() instanceof MaterializeChildExpressionNode);
    });
    assertOn(RETURN_VALUE, (e) -> {
        assertTrue(e.context.getInstrumentedNode() instanceof MaterializeChildExpressionNode);
    });
    assertAllEventsConsumed();
    filter = SourceSectionFilter.newBuilder().tagIs(StandardTags.ExpressionTag.class).build();
    instrumenter.attachExecutionEventFactory(filter, null, factory);
    execute(source);
    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 : MaterializeChildExpressionNode(com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.MaterializeChildExpressionNode) 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) Source(org.graalvm.polyglot.Source) StandardTags(com.oracle.truffle.api.instrumentation.StandardTags) Test(org.junit.Test)

Example 2 with ExpressionNode

use of com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.ExpressionNode 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 3 with ExpressionNode

use of com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.ExpressionNode 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)

Example 4 with ExpressionNode

use of com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.ExpressionNode in project graal by oracle.

the class InstrumentableNodeTest method testSimpleMaterializeSyntax.

/*
     * Directly instrument and materialize all nodes.
     */
@Test
public void testSimpleMaterializeSyntax() {
    SourceSectionFilter filter = SourceSectionFilter.newBuilder().tagIs(StandardTags.StatementTag.class, StandardTags.ExpressionTag.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) 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)

Example 5 with ExpressionNode

use of com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.ExpressionNode in project graal by oracle.

the class InstrumentableNodeTest method testMaterializeSyntaxNotInstrumented.

/*
     * Test materialize if the parent node is not instrumented. We need to call materializeSyntax
     * for all visited instrumentable nodes. Not just for instrumented ones.
     */
@Test
public void testMaterializeSyntaxNotInstrumented() {
    SourceSectionFilter expressionFilter = SourceSectionFilter.newBuilder().tagIs(StandardTags.ExpressionTag.class).build();
    instrumenter.attachExecutionEventFactory(expressionFilter, null, factory);
    execute("MATERIALIZE_CHILD_EXPRESSION");
    assertOn(ENTER, (e) -> {
        assertTrue(e.context.getInstrumentedNode() instanceof ExpressionNode);
    });
    assertOn(RETURN_VALUE, (e) -> {
        assertTrue(e.context.getInstrumentedNode() instanceof ExpressionNode);
    });
}
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) SourceSectionFilter(com.oracle.truffle.api.instrumentation.SourceSectionFilter) Test(org.junit.Test)

Aggregations

SourceSectionFilter (com.oracle.truffle.api.instrumentation.SourceSectionFilter)5 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 Test (org.junit.Test)5 ExpressionTag (com.oracle.truffle.api.instrumentation.StandardTags.ExpressionTag)3 StandardTags (com.oracle.truffle.api.instrumentation.StandardTags)2 Source (org.graalvm.polyglot.Source)1