use of com.oracle.truffle.api.instrumentation.SourceSectionFilter in project graal by oracle.
the class InputFilterTest method testFilterChildren2.
@Test
public void testFilterChildren2() {
SourceSectionFilter line1 = SourceSectionFilter.newBuilder().tagIs(StandardTags.ExpressionTag.class).lineStartsIn(IndexRange.between(1, 2)).build();
String code = "EXPRESSION(\nEXPRESSION(CONSTANT(0)))";
// test that input filter does not match to any inputs
EventBinding<?> binding = instrumenter.attachExecutionEventFactory(line1, line1, factory);
execute(code);
assertOn(ENTER, (e) -> {
assertCharacters(e, code);
});
assertOn(RETURN_VALUE, (e) -> {
assertCharacters(e, code);
assertArrayEquals(new Object[] {}, e.inputs);
assertEquals("((0))", e.result);
});
binding.dispose();
assertCleanedUp(code);
assertAllEventsConsumed();
}
use of com.oracle.truffle.api.instrumentation.SourceSectionFilter in project graal by oracle.
the class InputFilterTest method testInnerFrames.
@Test
public void testInnerFrames() {
SourceSectionFilter expressionFilter = SourceSectionFilter.newBuilder().tagIs(StandardTags.ExpressionTag.class).build();
String code = "EXPRESSION(INNER_FRAME(EXPRESSION(INNER_FRAME(EXPRESSION))))";
EventBinding<?> binding1 = instrumenter.attachExecutionEventFactory(expressionFilter, expressionFilter, factory);
execute(code);
assertOn(ENTER);
assertOn(ENTER);
assertOn(ENTER);
assertOn(RETURN_VALUE, (e) -> {
assertEquals("()", e.result);
assertArrayEquals(new Object[] {}, e.inputs);
});
assertOn(INPUT_VALUE, (e) -> {
assertEquals(0, e.inputValueIndex);
assertEquals("()", e.inputValue);
});
assertOn(RETURN_VALUE, (e) -> {
assertEquals("(())", e.result);
// the expression value is not recoverable for inner frames.
assertArrayEquals(new Object[] { null }, e.inputs);
});
assertOn(INPUT_VALUE, (e) -> {
assertEquals(0, e.inputValueIndex);
assertEquals("(())", e.inputValue);
});
assertOn(RETURN_VALUE, (e) -> {
assertEquals("((()))", e.result);
assertArrayEquals(new Object[] { null }, e.inputs);
});
binding1.dispose();
assertCleanedUp(code);
}
use of com.oracle.truffle.api.instrumentation.SourceSectionFilter in project graal by oracle.
the class InputFilterTest method testCleanupFrameDescriptor.
@Test
public void testCleanupFrameDescriptor() {
SourceSectionFilter expressionFilter = SourceSectionFilter.newBuilder().tagIs(StandardTags.ExpressionTag.class).build();
String code = "EXPRESSION(INTERNAL(EXPRESSION))";
assertCleanedUp(code);
EventBinding<?> binding = instrumenter.attachExecutionEventFactory(expressionFilter, expressionFilter, factory);
// lazy initialize
execute(code);
assertOn(ENTER);
assertOn(ENTER);
assertOn(RETURN_VALUE, (e) -> {
assertEquals("()", e.result);
assertArrayEquals(new Object[] {}, e.inputs);
});
assertOn(INPUT_VALUE, (e) -> {
assertEquals(0, e.inputValueIndex);
assertEquals("()", e.inputValue);
});
assertOn(RETURN_VALUE, (e) -> {
assertEquals("(())", e.result);
assertArrayEquals(new Object[] { "()" }, e.inputs);
});
binding.dispose();
assertCleanedUp(code);
}
use of com.oracle.truffle.api.instrumentation.SourceSectionFilter in project graal by oracle.
the class InputFilterTest method testSameInputFilter.
@Test
public void testSameInputFilter() {
SourceSectionFilter expressionFilter = SourceSectionFilter.newBuilder().tagIs(StandardTags.ExpressionTag.class).build();
EventBinding<?> binding = instrumenter.attachExecutionEventFactory(expressionFilter, expressionFilter, factory);
String code = "ROOT(EXPRESSION(" + "INTERNAL(INTERNAL(EXPRESSION), INTERNAL)," + "STATEMENT(CONSTANT(42))," + "EXPRESSION)" + ")";
execute(code);
assertOn(ENTER);
assertOn(ENTER);
assertOn(RETURN_VALUE, (e) -> {
assertEquals("()", e.result);
assertArrayEquals(new Object[] {}, e.inputs);
});
assertOn(INPUT_VALUE, (e) -> {
assertEquals(0, e.inputValueIndex);
assertEquals("()", e.inputValue);
});
assertOn(ENTER);
assertOn(RETURN_VALUE, (e) -> {
assertEquals("()", e.result);
assertArrayEquals(new Object[] {}, e.inputs);
});
assertOn(INPUT_VALUE, (e) -> {
assertEquals(1, e.inputValueIndex);
assertEquals("()", e.inputValue);
});
assertOn(RETURN_VALUE, (e) -> {
assertEquals("(()+42+())", e.result);
assertArrayEquals(new Object[] { "()", "()" }, e.inputs);
});
binding.dispose();
assertCleanedUp(code);
}
use of com.oracle.truffle.api.instrumentation.SourceSectionFilter in project graal by oracle.
the class InputFilterTest method testMultipleFactories.
@Test
public void testMultipleFactories() {
SourceSectionFilter expressionFilter = SourceSectionFilter.newBuilder().tagIs(StandardTags.ExpressionTag.class).build();
String code = "EXPRESSION(INTERNAL(EXPRESSION))";
EventBinding<?> binding1 = instrumenter.attachExecutionEventFactory(expressionFilter, expressionFilter, factory);
EventBinding<?> binding2 = instrumenter.attachExecutionEventFactory(expressionFilter, expressionFilter, factory);
EventBinding<?> binding3 = instrumenter.attachExecutionEventFactory(expressionFilter, expressionFilter, factory);
// lazy initialize
execute(code);
assertOn(ENTER);
assertOn(ENTER);
assertOn(ENTER);
assertOn(ENTER);
assertOn(ENTER);
assertOn(ENTER);
assertOn(RETURN_VALUE, (e) -> {
assertEquals("()", e.result);
assertArrayEquals(new Object[] {}, e.inputs);
});
assertOn(INPUT_VALUE, (e) -> {
assertEquals(0, e.inputValueIndex);
assertEquals("()", e.inputValue);
});
assertOn(RETURN_VALUE, (e) -> {
assertEquals("()", e.result);
assertArrayEquals(new Object[] {}, e.inputs);
});
assertOn(INPUT_VALUE, (e) -> {
assertEquals(0, e.inputValueIndex);
assertEquals("()", e.inputValue);
});
assertOn(RETURN_VALUE, (e) -> {
assertEquals("()", e.result);
assertArrayEquals(new Object[] {}, e.inputs);
});
assertOn(INPUT_VALUE, (e) -> {
assertEquals(0, e.inputValueIndex);
assertEquals("()", e.inputValue);
});
assertOn(RETURN_VALUE, (e) -> {
assertEquals("(())", e.result);
assertArrayEquals(new Object[] { "()" }, e.inputs);
});
assertOn(RETURN_VALUE, (e) -> {
assertEquals("(())", e.result);
assertArrayEquals(new Object[] { "()" }, e.inputs);
});
assertOn(RETURN_VALUE, (e) -> {
assertEquals("(())", e.result);
assertArrayEquals(new Object[] { "()" }, e.inputs);
});
binding1.dispose();
binding2.dispose();
binding3.dispose();
assertCleanedUp(code);
}
Aggregations