Skip to content

Commit e98f113

Browse files
committed
Insert missing boundaries/PE constant assertions in BytecodeNode helpers
1 parent 8f23410 commit e98f113

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/BytecodeNode.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ public final SourceSection[] getSourceLocations(Frame frame, Node location) {
220220
* @param bytecodeIndex the bytecode index, used to determine liveness of source sections. A
221221
* valid bytecode index can be obtained by calling
222222
* {@link BytecodeLocation#getBytecodeIndex()} or using @{@link Bind
223-
* Bind}("$bytecodeIndex") annotation. The value must be a partial evaluation
224-
* constant.
223+
* Bind}("$bytecodeIndex") annotation.
225224
* @since 24.2
226225
*/
227226
public abstract SourceSection getSourceLocation(int bytecodeIndex);
@@ -237,8 +236,7 @@ public final SourceSection[] getSourceLocations(Frame frame, Node location) {
237236
* @param bytecodeIndex the bytecode index, used to determine liveness of source sections. A
238237
* valid bytecode index can be obtained by calling
239238
* {@link BytecodeLocation#getBytecodeIndex()} or using @{@link Bind
240-
* Bind}("$bytecodeIndex") annotation. The value must be a partial evaluation
241-
* constant.
239+
* Bind}("$bytecodeIndex") annotation.
242240
* @since 24.2
243241
*/
244242
public abstract SourceSection[] getSourceLocations(int bytecodeIndex);
@@ -278,6 +276,7 @@ private Node findOperationNode(Node location) {
278276
* @return the source location, or null if a location could not be found
279277
* @since 24.2
280278
*/
279+
@TruffleBoundary
281280
public final SourceSection getSourceLocation(FrameInstance frameInstance) {
282281
int bci = findBytecodeIndex(frameInstance);
283282
if (bci == -1) {
@@ -296,6 +295,7 @@ public final SourceSection getSourceLocation(FrameInstance frameInstance) {
296295
* @return the source locations, or null if they could not be found
297296
* @since 24.2
298297
*/
298+
@TruffleBoundary
299299
public final SourceSection[] getSourceLocations(FrameInstance frameInstance) {
300300
int bci = findBytecodeIndex(frameInstance);
301301
if (bci == -1) {
@@ -723,6 +723,7 @@ public final void copyLocalValues(int bytecodeIndex, Frame source, Frame destina
723723
*/
724724
@ExplodeLoop
725725
public final void copyLocalValues(int bytecodeIndex, Frame source, Frame destination, int localOffset, int localCount) {
726+
CompilerAsserts.partialEvaluationConstant(bytecodeIndex);
726727
CompilerAsserts.partialEvaluationConstant(localOffset);
727728
CompilerAsserts.partialEvaluationConstant(localCount);
728729
if (localCount < 0) {
@@ -1257,6 +1258,7 @@ protected static final Object createDefaultStackTraceElement(TruffleStackTraceEl
12571258
* {@link BytecodeRootNode}
12581259
* @since 24.2
12591260
*/
1261+
@TruffleBoundary
12601262
public static Object[] getLocalValues(FrameInstance frameInstance) {
12611263
BytecodeNode bytecode = get(frameInstance);
12621264
if (bytecode == null) {
@@ -1278,6 +1280,7 @@ public static Object[] getLocalValues(FrameInstance frameInstance) {
12781280
* {@link BytecodeRootNode}
12791281
* @since 24.2
12801282
*/
1283+
@TruffleBoundary
12811284
public static Object[] getLocalNames(FrameInstance frameInstance) {
12821285
BytecodeNode bytecode = get(frameInstance);
12831286
if (bytecode == null) {
@@ -1297,6 +1300,7 @@ public static Object[] getLocalNames(FrameInstance frameInstance) {
12971300
* @return whether the locals could be set with the information available in the frame instance
12981301
* @since 24.2
12991302
*/
1303+
@TruffleBoundary
13001304
public static boolean setLocalValues(FrameInstance frameInstance, Object[] values) {
13011305
BytecodeNode bytecode = get(frameInstance);
13021306
if (bytecode == null) {
@@ -1359,12 +1363,13 @@ public static BytecodeNode get(FrameInstance frameInstance) {
13591363
/**
13601364
* Gets the bytecode location for a given Node, if it can be found in the parent chain.
13611365
*
1362-
* @param node the node
1366+
* @param node the node, which must be a partial evaluation constant.
13631367
* @return the corresponding bytecode location or null if no location can be found.
13641368
* @since 24.2
13651369
*/
13661370
@ExplodeLoop
13671371
public static BytecodeNode get(Node node) {
1372+
CompilerAsserts.partialEvaluationConstant(node);
13681373
for (Node currentNode = node; currentNode != null; currentNode = currentNode.getParent()) {
13691374
if (currentNode instanceof BytecodeNode bytecodeNode) {
13701375
return bytecodeNode;
@@ -1381,6 +1386,7 @@ public static BytecodeNode get(Node node) {
13811386
* @return the corresponding bytecode location or null if no location can be found.
13821387
* @since 24.2
13831388
*/
1389+
@TruffleBoundary
13841390
public static BytecodeNode get(TruffleStackTraceElement element) {
13851391
Node location = element.getLocation();
13861392
if (location == null) {

truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/bytecode/generator/BytecodeRootNodeElement.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14007,6 +14007,7 @@ private CodeExecutableElement createAdoptNodesAfterUpdate() {
1400714007
private CodeExecutableElement createGetSourceLocation() {
1400814008
CodeExecutableElement ex = GeneratorUtils.override(types.BytecodeNode, "getSourceLocation", new String[]{"bci"}, new TypeMirror[]{type(int.class)});
1400914009
ex.getModifiers().add(FINAL);
14010+
ex.getAnnotationMirrors().add(new CodeAnnotationMirror(types.CompilerDirectives_TruffleBoundary));
1401014011
CodeTreeBuilder b = ex.createBuilder();
1401114012
b.statement("assert validateBytecodeIndex(bci)");
1401214013

@@ -14032,6 +14033,7 @@ private CodeExecutableElement createGetSourceLocation() {
1403214033
private CodeExecutableElement createGetSourceLocations() {
1403314034
CodeExecutableElement ex = GeneratorUtils.override(types.BytecodeNode, "getSourceLocations", new String[]{"bci"}, new TypeMirror[]{type(int.class)});
1403414035
ex.getModifiers().add(FINAL);
14036+
ex.getAnnotationMirrors().add(new CodeAnnotationMirror(types.CompilerDirectives_TruffleBoundary));
1403514037
CodeTreeBuilder b = ex.createBuilder();
1403614038
b.statement("assert validateBytecodeIndex(bci)");
1403714039

0 commit comments

Comments
 (0)