Skip to content

Commit

Permalink
integrate new source section & continuation changes; skip short circu…
Browse files Browse the repository at this point in the history
…it op for unary compare operations
  • Loading branch information
DSouzaM committed Apr 2, 2024
1 parent 012a050 commit 3bec5b4
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import com.oracle.graal.python.lib.PyObjectGetIter;
import com.oracle.graal.python.lib.PyObjectHashNode;
import com.oracle.graal.python.nodes.PGuards;
import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode;
import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode;
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
Expand Down Expand Up @@ -310,10 +309,10 @@ static Object lines(PCode self) {
CodeUnit co = self.getCodeUnit();
if (co != null) {
if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
BytecodeIntrospection introspectionData = ((PBytecodeDSLRootNode) self.getRootNode()).getIntrospectionData();
BytecodeIntrospection introspectionData = ((PBytecodeDSLRootNode) self.getRootNodeForExtraction()).getIntrospectionData();
List<PTuple> lines = new ArrayList<>();
for (SourceInformation sourceInfo : introspectionData.getSourceInformation()) {
lines.add(factory.createTuple(new int[]{sourceInfo.getStartBci(), sourceInfo.getEndBci(), sourceInfo.getSourceSection().getStartLine()}));
lines.add(factory.createTuple(new int[]{sourceInfo.getBeginBci(), sourceInfo.getEndBci(), sourceInfo.getSourceSection().getStartLine()}));
}
tuple = factory.createTuple(lines.toArray());
} else {
Expand Down Expand Up @@ -354,7 +353,7 @@ Object positions(PCode self) {
if (co != null) {
List<PTuple> lines = new ArrayList<>();
if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
PBytecodeDSLRootNode rootNode = (PBytecodeDSLRootNode) self.getRootNode();
PBytecodeDSLRootNode rootNode = (PBytecodeDSLRootNode) self.getRootNodeForExtraction();
for (Instruction instruction : rootNode.getIntrospectionData().getInstructions()) {
SourceSection section = rootNode.getSourceSectionForLocation(instruction.getLocation());
lines.add(factory.createTuple(new int[]{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ RootNode getRootNode() {
return getRootCallTarget().getRootNode();
}

RootNode getRootNodeForExtraction() {
return rootNodeForExtraction(getRootNode());
}

public TruffleString[] getFreeVars() {
if (freevars == null) {
freevars = extractFreeVars(getRootNode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
import com.oracle.graal.python.runtime.PythonOptions;
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
import com.oracle.truffle.api.bytecode.BytecodeNode;
import com.oracle.truffle.api.bytecode.BytecodeLocation;
import com.oracle.truffle.api.bytecode.ContinuationResult;
import com.oracle.truffle.api.dsl.Bind;
import com.oracle.truffle.api.dsl.Cached;
Expand Down Expand Up @@ -197,11 +197,11 @@ static Object getFrame(PGenerator self,
BytecodeDSLFrameInfo info = (BytecodeDSLFrameInfo) generatorFrame.getFrameDescriptor().getInfo();
PBytecodeDSLRootNode rootNode = info.getRootNode();
ContinuationResult continuation = self.getContinuation();
BytecodeNode bytecodeNode = continuation.getBytecodeNode();
PFrame frame = MaterializeFrameNode.materializeGeneratorFrame(bytecodeNode, generatorFrame, PFrame.Reference.EMPTY, factory);
int bci = continuation.getBci();
BytecodeLocation location = continuation.getBytecodeLocation();
PFrame frame = MaterializeFrameNode.materializeGeneratorFrame(location.getBytecodeNode(), generatorFrame, PFrame.Reference.EMPTY, factory);
int bci = location.getBytecodeIndex();
frame.setBci(bci);
frame.setLine(rootNode.bciToLine(bci, bytecodeNode));
frame.setLine(rootNode.bciToLine(bci, location.getBytecodeNode()));
return frame;
} else {
BytecodeFrameInfo info = (BytecodeFrameInfo) generatorFrame.getFrameDescriptor().getInfo();
Expand Down
Loading

0 comments on commit 3bec5b4

Please sign in to comment.