Skip to content

Commit 0f4caef

Browse files
committed
Don't instrument roots without sources
1 parent c500563 commit 0f4caef

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/SourceMap.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ private static int readNum(ByteArrayInputStream offsets) {
117117
}
118118

119119
public static SourceSection getSourceSection(Source source, int startLine, int startColumn, int endLine, int endColumn) {
120+
if (source == null || !source.hasCharacters()) {
121+
return null;
122+
}
120123
/* Truffle columns are 1-based and it doesn't consider the newline a part of the line */
121124
startColumn = Math.max(startColumn + 1, 1);
122125
endColumn = Math.max(Math.min(endColumn + 1, source.getLineLength(endLine)), 1);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/instrumentation/InstrumentationRootImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ public InstrumentableNode materializeInstrumentableNodes(Set<Class<? extends Tag
5757
if (materializedTags.contains(StandardTags.StatementTag.class)) {
5858
if (instrumentationSupport == null) {
5959
PBytecodeRootNode rootNode = (PBytecodeRootNode) getParent();
60-
instrumentationSupport = insert(new InstrumentationSupport(rootNode));
61-
rootNode.materializeContainedFunctionsForInstrumentation(materializedTags);
62-
notifyInserted(instrumentationSupport);
60+
if (rootNode.getSource() != null && rootNode.getSource().hasCharacters()) {
61+
instrumentationSupport = insert(new InstrumentationSupport(rootNode));
62+
rootNode.materializeContainedFunctionsForInstrumentation(materializedTags);
63+
notifyInserted(instrumentationSupport);
64+
}
6365
}
6466
}
6567
return this;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/instrumentation/InstrumentationSupport.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public final class InstrumentationSupport extends Node {
5757
@CompilationFinal(dimensions = 1) public Node[] bciToHelperNode;
5858

5959
public InstrumentationSupport(PBytecodeRootNode rootNode) {
60+
assert rootNode.getSource() != null && rootNode.getSource().hasCharacters();
6061
code = rootNode.getCodeUnit();
6162
lineToNode = new InstrumentedBytecodeStatement[code.endLine + 1];
6263
bciToHelperNode = new Node[code.code.length];

0 commit comments

Comments
 (0)