Skip to content

Commit c76b4ce

Browse files
committed
[GR-61282] [GR-63630] Support source sections when linear parsing without look-ahead.
PullRequest: graal/20434
2 parents 993ea44 + 64a6743 commit c76b4ce

File tree

20 files changed

+547
-240
lines changed

20 files changed

+547
-240
lines changed

truffle/CHANGELOG.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ This changelog summarizes major changes between Truffle versions relevant to lan
1212
* GR-50017 TruffleStringIterator.NextNode and TruffleStringIterator.PreviousNode now require the iterated string's encoding as a parameter for performance reasons.
1313
* GR-63075 Java host interop again inherits public method methods from non-public base classes if public access is enabled. This was originally changed in 24.1.
1414
* GR-63201 Added `TruffleLanguage.Registration.optionalResources` and `TruffleInstrument.Registration.optionalResources` attributes to support optional resources which implementations are not available at the runtime. Optional resources, if omitted at runtime, can still be used as long as their resource path is specified via the `polyglot.engine.resourcePath.<componentId>` system property.
15+
* GR-61282 Bytecode DSL: Bytecode builders now also allow emitting source sections using the start and length source indices in the end method in addition to the begin method. This was added to support linear parsing without look-ahead.
16+
* GR-61282 Bytecode DSL: (breaking) If multiple source sections were specified around root operations, only the innermost source section directly encapsulating the root will be accessible. Other encapsulating source sections will be discarded for outer most root operations.
1517

1618
## Version 24.2.0
1719
* GR-60636 Truffle now stops compiling when the code cache fills up on HotSpot. A warning is printed when that happens.
18-
19-
## Version 24.2.0
2020
* GR-57658 Added `TruffleLanguage.Env.getLanguageInfo(Class<? extends TruffleLanguage>)` to lookup a `LanguageInfo` instance for a language class returned by `InteropLibrary.getLanguage(Object)`.
2121
* GR-57164 Added support for reading unaligned ints, shorts and long to `ByteArraySupport`.
2222
* GR-57164 `RootNode.translateStackTraceElement()` is now always consulted for polyglot and debugger stack traces. Stack traces now use the source section, the executable name, the name of the declared meta-object to build `StackTraceElement` instances.
@@ -37,8 +37,6 @@ This changelog summarizes major changes between Truffle versions relevant to lan
3737
* GR-55296 Added support to convert any string to a `byte[]` with a given `Value.StringEncoding` using `Value.asStringBytes(...)`.
3838
* GR-40323 Deprecated `Shape.Builder.layout(Class)` for removal and added replacement API [`Shape.Builder.layout(Class, MethodHandles.Lookup)`](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/object/Shape.Builder.html#layout(java.lang.Class,java.lang.MethodHandles.Lookup)). Replace usages with the new method, additionally providing a `Lookup` that has full privilege access to the layout class or the module in which it is declared, as obtained by `MethodHandles.lookup()`. See javadoc for the updated usage.
3939
* GR-55296 Added support for UTF-16 and UTF-32 in non-system-endianness without dependency on the JCodings library in TruffleString.
40-
41-
4240
* GR-58550 Added `FrameDescriptor.Builder.illegalDefaultValue()` which initializes all frame slots as `FrameSlotKind.Illegal` for newly created frames. This is different from the default behavior, which initializes all frame slot kinds as `FrameSlotKind.Object`. This means that frame slots, when they are read before they were written, throw a `FrameSlotTypeException`, consistent with the behavior after clearing a frame slot.
4341
* GR-58550 Deprecated the default constructor for `FrameSlotTypeException` and replaced it with `FrameSlotTypeException.create(...)`. Exceptions of this kind thrown by the `Frame` now contain the slot index and the expected and the actual frame slot kind which are accessible with the respective instance methods.
4442
* GR-58550 Fixed invalid `PolyglotException.getMessage()` javadoc. A polyglot exception may in fact return a `null` message.

truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/basic_interpreter/AbstractBasicInterpreterTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
import org.junit.function.ThrowingRunnable;
6666
import org.junit.runner.RunWith;
6767
import org.junit.runners.Parameterized;
68-
import org.junit.runners.Parameterized.Parameter;
6968
import org.junit.runners.Parameterized.Parameters;
7069

7170
import com.oracle.truffle.api.CompilerDirectives;
@@ -263,7 +262,11 @@ public static List<TestRun> getParameters() {
263262
return result;
264263
}
265264

266-
@Parameter(0) public TestRun run;
265+
public final TestRun run;
266+
267+
public AbstractBasicInterpreterTest(TestRun run) {
268+
this.run = run;
269+
}
267270

268271
public <T extends BasicInterpreterBuilder> RootCallTarget parse(String rootName, BytecodeParser<T> builder) {
269272
BytecodeRootNode rootNode = parseNode(run.interpreterClass, LANGUAGE, run.testSerialize, rootName, builder);
@@ -305,7 +308,11 @@ public static <T extends BasicInterpreterBuilder> BytecodeRootNodes<BasicInterpr
305308
}
306309

307310
for (BasicInterpreter interpreter : result.getNodes()) {
308-
testIntrospectionInvariants(interpreter.getBytecodeNode());
311+
try {
312+
testIntrospectionInvariants(interpreter.getBytecodeNode());
313+
} catch (Throwable e) {
314+
throw new AssertionError("Invariant failure " + interpreter.dump(), e);
315+
}
309316
}
310317

311318
return result;

truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/basic_interpreter/BasicInterpreterTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@
9494
*/
9595
@RunWith(Parameterized.class)
9696
public class BasicInterpreterTest extends AbstractBasicInterpreterTest {
97+
98+
public BasicInterpreterTest(TestRun run) {
99+
super(run);
100+
}
101+
97102
private record ExpectedArgument(String name, Argument.Kind kind, Object value) {
98103
}
99104

truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/basic_interpreter/BindingsTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848

4949
public class BindingsTest extends AbstractBasicInterpreterTest {
5050

51+
public BindingsTest(TestRun run) {
52+
super(run);
53+
}
54+
5155
@Test
5256
public void testExplicit() {
5357
BasicInterpreter node = parseNode("explicitBindings", b -> {

truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/basic_interpreter/BranchTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
public class BranchTest extends AbstractBasicInterpreterTest {
5656
// @formatter:off
5757

58+
public BranchTest(TestRun run) {
59+
super(run);
60+
}
61+
62+
5863
@Test
5964
public void testBranchForward() {
6065
// goto lbl;

truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/basic_interpreter/BytecodeLocationTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@
6060

6161
@RunWith(Parameterized.class)
6262
public class BytecodeLocationTest extends AbstractBasicInterpreterTest {
63+
64+
public BytecodeLocationTest(TestRun run) {
65+
super(run);
66+
}
67+
6368
@Test
6469
public void testGetBytecodeLocation() {
6570
Source source = Source.newBuilder("test", "getBytecodeLocation", "baz").build();

truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/basic_interpreter/CopyLocalsTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
@RunWith(Parameterized.class)
5454
public class CopyLocalsTest extends AbstractBasicInterpreterTest {
5555

56+
public CopyLocalsTest(TestRun run) {
57+
super(run);
58+
}
59+
5660
@Test
5761
public void testCopyAllLocals() {
5862
/**

truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/basic_interpreter/ExceptionHandlerTableTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@
6969

7070
@RunWith(Parameterized.class)
7171
public class ExceptionHandlerTableTest extends AbstractBasicInterpreterTest {
72+
73+
public ExceptionHandlerTableTest(TestRun run) {
74+
super(run);
75+
}
76+
7277
private record ExceptionRangeTree(int index, String name, HandlerKind kind, ExceptionRangeTree[] nested) {
7378
}
7479

truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/basic_interpreter/LocalsTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868

6969
public class LocalsTest extends AbstractBasicInterpreterTest {
7070

71+
public LocalsTest(TestRun run) {
72+
super(run);
73+
}
74+
7175
@Test
7276
public void testBasicLocals() {
7377
for (int i = 0; i < 100; i++) {

0 commit comments

Comments
 (0)