Skip to content

Commit f672d28

Browse files
committed
Add instrumentation tutorial; fix a few typos and annotation processor bugs
1 parent a85fb39 commit f672d28

File tree

11 files changed

+711
-19
lines changed

11 files changed

+711
-19
lines changed

truffle/docs/bytecode_dsl/BytecodeDSL.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ The Bytecode DSL supports a variety of features, including:
100100

101101
- **Serialization**: Bytecode DSL interpreters support serialization/deserialization, which enables a language to persist the bytecode for a guest program and reconstruct it without reprocessing the source program (see the [Serialization tutorial][serialization]).
102102

103-
- **Instrumentation**: Bytecode DSL interpreters support special instrumentation operations and tag-based instrumentation.
103+
- **Instrumentation**: Bytecode DSL interpreters support special instrumentation operations and tag-based instrumentation (see the [Instrumentation tutorial][instrumentation]).
104104

105105
- **Lazy source and instrumentation metadata**: Source and instrumentation metadata increase the footprint of the interpreter. By default, Bytecode DSL interpreters elide this metadata when building bytecode, so they have no footprint overhead when they are not used. The metadata is recomputed on demand by replaying the builder calls.
106106

@@ -122,4 +122,5 @@ The Bytecode DSL implementation for [SimpleLanguage](https://github.com/oracle/g
122122

123123

124124
[serialization]: https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/examples/SerializationTutorial.java
125-
[continuations]: https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/examples/ContinuationsTutorial.java
125+
[continuations]: https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/examples/ContinuationsTutorial.java
126+
[instrumentation]: https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/examples/InstrumentationTutorial.java

truffle/docs/bytecode_dsl/UserGuide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ Take extra care if accessing source information in [compiled code](RuntimeCompil
538538
### Instrumentation
539539

540540
The behaviour of a Bytecode DSL interpreter can be non-intrusively observed (and modified) using instrumentation.
541-
For example, you can instrument your code to trace each guest language statement, or add instrumentation to log return values.
541+
For example, you can instrument your code to trace each guest language statement, or add instrumentation to log return values (see the [Instrumentation tutorial](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/examples/InstrumentationTutorial.java) for more details).
542542

543543
Instrumentations are specified during parsing, but disabled by default.
544544
They incur no overhead until they are enabled at a later time (see [Reparsing metadata](#reparsing)).

truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/InstrumentationTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,18 @@ public static int doInt(@SuppressWarnings("unused") @Variadic Object... args) {
609609
}
610610
}
611611

612+
@ExpectError("An @Instrumentation operation cannot be void and also specify a dynamic operand. " + //
613+
"Instrumentations must have transparent stack effects. " +
614+
"Change the return type or remove the dynamic operand to resolve this.")
615+
@Instrumentation
616+
static final class InvalidInstrumentation4 {
617+
618+
@Specialization
619+
public static void doInt(@SuppressWarnings("unused") Object arg) {
620+
return;
621+
}
622+
}
623+
612624
}
613625

614626
@GenerateBytecode(languageClass = BytecodeInstrumentationTestLanguage.class, //

truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/TagTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2891,7 +2891,7 @@ protected Object createContext(Env env) {
28912891

28922892
}
28932893

2894-
@ExpectError("Tag instrumentation uses implicit root tagging, but the RootTag was not provded by the language class 'com.oracle.truffle.api.bytecode.test.TagTest.NoRootTagTestLanguage'. " +
2894+
@ExpectError("Tag instrumentation uses implicit root tagging, but the RootTag was not provided by the language class 'com.oracle.truffle.api.bytecode.test.TagTest.NoRootTagTestLanguage'. " +
28952895
"Specify the tag using @ProvidedTags(RootTag.class) on the language class or explicitly disable root tagging using @GenerateBytecode(.., enableRootTagging=false) to resolve this.")
28962896
@GenerateBytecode(languageClass = NoRootTagTestLanguage.class, //
28972897
enableTagInstrumentation = true)
@@ -2944,7 +2944,7 @@ protected Object createContext(Env env) {
29442944

29452945
}
29462946

2947-
@ExpectError("Tag instrumentation uses implicit root body tagging, but the RootTag was not provded by the language class 'com.oracle.truffle.api.bytecode.test.TagTest.NoRootBodyTagTestLanguage'. " +
2947+
@ExpectError("Tag instrumentation uses implicit root body tagging, but the RootTag was not provided by the language class 'com.oracle.truffle.api.bytecode.test.TagTest.NoRootBodyTagTestLanguage'. " +
29482948
"Specify the tag using @ProvidedTags(RootBodyTag.class) on the language class or explicitly disable root tagging using @GenerateBytecode(.., enableRootBodyTagging=false) to resolve this.")
29492949
@GenerateBytecode(languageClass = NoRootBodyTagTestLanguage.class, //
29502950
enableTagInstrumentation = true)

truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/error_tests/ErrorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ static int sub(int x, int y) {
934934
}
935935

936936
@GenerateBytecode(languageClass = ErrorLanguage.class)
937-
@ExpectError({"At least one operation must be declared using @Operation, @OperationProxy, or @ShortCircuitOperation."})
937+
@ExpectWarning("No custom operations were declared. Custom operations can be declared using @Operation, @OperationProxy, or @ShortCircuitOperation.")
938938
public abstract static class NoOperationsTest extends RootNode implements BytecodeRootNode {
939939
protected NoOperationsTest(ErrorLanguage language, FrameDescriptor builder) {
940940
super(language, builder);

0 commit comments

Comments
 (0)