Skip to content

Commit e26568c

Browse files
committed
Delay getting bytecode location for generator state
1 parent ecf0e7b commit e26568c

File tree

1 file changed

+8
-4
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator

1 file changed

+8
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/PGenerator.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,20 @@ public Object handleResult(PythonLanguage language, GeneratorYieldResult result)
116116
public static class BytecodeDSLState {
117117
private final PBytecodeDSLRootNode rootNode;
118118
private final Object[] arguments;
119-
private BytecodeNode bytecodeNode;
119+
private BytecodeLocation lastLocation;
120120
private ContinuationRootNode continuationRootNode;
121121
private boolean isStarted;
122122

123123
public BytecodeDSLState(PBytecodeDSLRootNode rootNode, Object[] arguments, ContinuationRootNode continuationRootNode) {
124124
this.rootNode = rootNode;
125125
this.arguments = arguments;
126126
this.continuationRootNode = continuationRootNode;
127-
this.bytecodeNode = rootNode.getBytecodeNode();
128127
}
129128

130129
public Object handleResult(PGenerator generator, ContinuationResult result) {
131130
assert result.getContinuationRootNode() == null || result.getContinuationRootNode().getFrameDescriptor() == generator.frame.getFrameDescriptor();
132131
isStarted = true;
133-
bytecodeNode = continuationRootNode.getLocation().getBytecodeNode();
132+
lastLocation = continuationRootNode.getLocation();
134133
continuationRootNode = result.getContinuationRootNode();
135134
return result.getResult();
136135
}
@@ -296,7 +295,12 @@ public RootCallTarget getCurrentCallTarget() {
296295
*/
297296
public BytecodeNode getBytecodeNode() {
298297
assert PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER;
299-
return getBytecodeDSLState().bytecodeNode;
298+
BytecodeDSLState state = getBytecodeDSLState();
299+
if (state.lastLocation != null) {
300+
return state.lastLocation.getBytecodeNode();
301+
} else {
302+
return state.rootNode.getBytecodeNode();
303+
}
300304
}
301305

302306
public BytecodeLocation getCurrentLocation() {

0 commit comments

Comments
 (0)