Skip to content

Commit f7c84aa

Browse files
committed
Update to use new introspection API
1 parent 3bec5b4 commit f7c84aa

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@
7171
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
7272
import com.oracle.graal.python.util.PythonUtils;
7373
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
74-
import com.oracle.truffle.api.bytecode.introspection.BytecodeIntrospection;
75-
import com.oracle.truffle.api.bytecode.introspection.Instruction;
76-
import com.oracle.truffle.api.bytecode.introspection.SourceInformation;
74+
import com.oracle.truffle.api.bytecode.BytecodeIntrospection;
75+
import com.oracle.truffle.api.bytecode.Instruction;
76+
import com.oracle.truffle.api.bytecode.SourceInformation;
7777
import com.oracle.truffle.api.dsl.Bind;
7878
import com.oracle.truffle.api.dsl.Cached;
7979
import com.oracle.truffle.api.dsl.Fallback;
@@ -354,7 +354,12 @@ Object positions(PCode self) {
354354
List<PTuple> lines = new ArrayList<>();
355355
if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
356356
PBytecodeDSLRootNode rootNode = (PBytecodeDSLRootNode) self.getRootNodeForExtraction();
357-
for (Instruction instruction : rootNode.getIntrospectionData().getInstructions()) {
357+
for (Instruction instruction : rootNode.getBytecodeNode().getInstructions()) {
358+
if (instruction.isInstrumentation()) {
359+
// Skip instrumented instructions. The co_positions array should agree
360+
// with the logical instruction index.
361+
continue;
362+
}
358363
SourceSection section = rootNode.getSourceSectionForLocation(instruction.getLocation());
359364
lines.add(factory.createTuple(new int[]{
360365
section.getStartLine(),

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ public int lastiToLine(int lasti) {
486486
if (funcRootNode instanceof PBytecodeDSLRootNode bytecodeDSLRootNode) {
487487
BytecodeNode bytecodeNode = bytecodeDSLRootNode.getBytecodeNode();
488488
// Emulate CPython's fixed 2-word instructions.
489-
BytecodeLocation location = BytecodeLocation.fromInstructionIndex((lasti + 1) / 2, bytecodeNode);
490-
return location.findSourceLocation().getStartLine();
489+
BytecodeLocation location = bytecodeNode.getBytecodeLocationFromInstructionIndex(lasti / 2);
490+
return location.getSourceLocation().getStartLine();
491491
}
492492
} else if (funcRootNode instanceof PBytecodeRootNode bytecodeRootNode) {
493493
return bytecodeRootNode.bciToLine(bytecodeRootNode.lastiToBci(lasti));

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/PFrame.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public static int bciToLasti(int bci, Node location) {
311311
if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
312312
if (bci >= 0 && location instanceof BytecodeNode bytecodeNode) {
313313
// Emulate CPython's fixed 2-word instructions.
314-
return bytecodeNode.findInstructionIndex(bci) * 2;
314+
return bytecodeNode.getBytecodeLocation(bci).getInstructionIndex() * 2;
315315
}
316316
} else {
317317
if (location instanceof PBytecodeRootNode bytecodeRootNode) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ public SourceSection getSourceSectionForLocation(int bci, BytecodeNode bytecodeN
424424
if (bytecodeNode != null) {
425425
BytecodeLocation bytecodeLocation = bytecodeNode.getBytecodeLocation(bci);
426426
if (bytecodeLocation != null) {
427-
sourceSection = bytecodeLocation.findSourceLocation();
427+
sourceSection = bytecodeLocation.getSourceLocation();
428428
}
429429
}
430430

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/ExceptionUtils.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@
5656
import com.oracle.graal.python.nodes.BuiltinNames;
5757
import com.oracle.graal.python.nodes.bytecode.BytecodeFrameInfo;
5858
import com.oracle.graal.python.nodes.bytecode.FrameInfo;
59-
import com.oracle.graal.python.nodes.bytecode_dsl.BytecodeDSLFrameInfo;
60-
import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode;
6159
import com.oracle.graal.python.nodes.call.CallNode;
6260
import com.oracle.graal.python.nodes.exception.TopLevelExceptionHandler;
6361
import com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode;
@@ -116,7 +114,7 @@ private static int getLineno(Frame frame, Node location, FrameInstance frameInst
116114
}
117115

118116
if (bytecodeNode != null) {
119-
return bytecodeNode.getBytecodeLocation(frame, location).findSourceLocation().getStartLine();
117+
return bytecodeNode.getBytecodeLocation(frame, location).getSourceLocation().getStartLine();
120118
}
121119
} else {
122120
return ((BytecodeFrameInfo) frameInfo).getLine(frame);

0 commit comments

Comments
 (0)