Search in sources :

Example 1 with MaterializedChildExpressionNode

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

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

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

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

Aggregations

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