4747import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
4848import com .oracle .truffle .api .RootCallTarget ;
4949import com .oracle .truffle .api .TruffleStackTraceElement ;
50+ import com .oracle .truffle .api .bytecode .BytecodeLocation ;
51+ import com .oracle .truffle .api .bytecode .BytecodeNode ;
5052import com .oracle .truffle .api .bytecode .ContinuationResult ;
5153import com .oracle .truffle .api .bytecode .ContinuationRootNode ;
5254import com .oracle .truffle .api .frame .Frame ;
@@ -116,17 +118,20 @@ public Object handleResult(PythonLanguage language, GeneratorYieldResult result)
116118 private static class BytecodeDSLState {
117119 private final PBytecodeDSLRootNode rootNode ;
118120 private final Object [] arguments ;
121+ private BytecodeNode bytecodeNode ;
119122 private ContinuationRootNode continuationRootNode ;
120123 private boolean isStarted ;
121124
122125 public BytecodeDSLState (PBytecodeDSLRootNode rootNode , Object [] arguments , ContinuationRootNode continuationRootNode ) {
123126 this .rootNode = rootNode ;
124127 this .arguments = arguments ;
125128 this .continuationRootNode = continuationRootNode ;
129+ this .bytecodeNode = rootNode .getBytecodeNode ();
126130 }
127131
128132 public Object handleResult (ContinuationResult result ) {
129133 isStarted = true ;
134+ bytecodeNode = continuationRootNode .getLocation ().getBytecodeNode ();
130135 continuationRootNode = result .getContinuationRootNode ();
131136 return result .getResult ();
132137 }
@@ -312,9 +317,17 @@ public RootCallTarget getCurrentCallTarget() {
312317 }
313318 }
314319
315- public ContinuationRootNode getCurrentRootNode () {
320+ /**
321+ * Return the BytecodeNode that should be used for accessing the frame
322+ */
323+ public BytecodeNode getBytecodeNode () {
324+ assert PythonOptions .ENABLE_BYTECODE_DSL_INTERPRETER ;
325+ return getBytecodeDSLState ().bytecodeNode ;
326+ }
327+
328+ public BytecodeLocation getCurrentLocation () {
316329 assert PythonOptions .ENABLE_BYTECODE_DSL_INTERPRETER ;
317- return getBytecodeDSLState ().continuationRootNode ;
330+ return getBytecodeDSLState ().continuationRootNode . getLocation () ;
318331 }
319332
320333 public Object getYieldFrom () {
@@ -327,7 +340,7 @@ public Object getYieldFrom() {
327340 if (rootNode .yieldFromGeneratorIndex == -1 || !getBytecodeDSLState ().isStarted ) {
328341 return null ;
329342 }
330- return rootNode . getBytecodeNode ().getLocalValue (0 , getGeneratorFrame (), rootNode .yieldFromGeneratorIndex );
343+ return getBytecodeNode ().getLocalValue (0 , getGeneratorFrame (), rootNode .yieldFromGeneratorIndex );
331344 } else {
332345 return frameInfo .getYieldFrom (frame , getBci (), getBytecodeState ().getCurrentRootNode ().getResumeStackTop ());
333346 }
0 commit comments