@@ -165,21 +165,30 @@ public final void execute(PythonContext context, Access access) {
165165 Node prev = null ;
166166 Node location = access .getLocation ();
167167 boolean locationAdoptable = location .isAdoptable ();
168+ EncapsulatingNodeReference encapsulatingNodeRef = EncapsulatingNodeReference .getCurrent ();
168169 if (locationAdoptable ) {
169170 // If the location is not adoptable, then we are in
170- // IndirectCallContext and SimpleIndirectInvokeNode will do
171+ // IndirectCallContext and SimpleIndirectInvokeNode below will do
171172 // IndirectCalleeContext.enter and transfer the state from thread state to
172- // the frame. If we were woken-up in middle of Python frame code, we will
173- // have to do a stack walk, but we still need the location
174- assert !PythonOptions .ENABLE_BYTECODE_DSL_INTERPRETER ||
175- !(location instanceof PBytecodeDSLRootNode ) : String .format ("Async action: location must not be PBytecodeDSLRootNode, was: %s" , location );
176- prev = EncapsulatingNodeReference .getCurrent ().set (location );
173+ // the frame. Otherwise, we were woken-up in middle of Python frame code, we
174+ // will have to do a stack walk if caller frame is needed, but we still need
175+ // the "call" location
176+ if (location instanceof PBytecodeDSLRootNode ) {
177+ // PBytecodeDSLRootNode is not usable as a location. To resolve the BCI
178+ // stored in the frame, we need the currently executing BytecodeNode,
179+ // using PBytecodeRootNode.getBytecodeNode() is not correct. We use the
180+ // dummy node to pass our assertions during stack walking that "call
181+ // node" is never PBytecodeDSLRootNode
182+ prev = encapsulatingNodeRef .set (language .unavailableSafepointLocation );
183+ } else {
184+ prev = encapsulatingNodeRef .set (location );
185+ }
177186 }
178187 try {
179188 CallDispatchers .SimpleIndirectInvokeNode .executeUncached (context .getAsyncHandler ().callTarget , args );
180189 } catch (PException e ) {
181190 if (locationAdoptable ) {
182- EncapsulatingNodeReference . getCurrent () .set (prev );
191+ encapsulatingNodeRef .set (prev );
183192 }
184193 handleException (e );
185194 } finally {
0 commit comments