Search in sources :

Example 1 with MaterializeChildExpressionNode

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

Aggregations

SourceSectionFilter (com.oracle.truffle.api.instrumentation.SourceSectionFilter)1 StandardTags (com.oracle.truffle.api.instrumentation.StandardTags)1 ExpressionNode (com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.ExpressionNode)1 MaterializeChildExpressionNode (com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.MaterializeChildExpressionNode)1 MaterializedChildExpressionNode (com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage.MaterializedChildExpressionNode)1 Source (org.graalvm.polyglot.Source)1 Test (org.junit.Test)1