|
61 | 61 | import com.oracle.graal.python.builtins.objects.function.PArguments; |
62 | 62 | import com.oracle.graal.python.builtins.objects.function.Signature; |
63 | 63 | import com.oracle.graal.python.nodes.PRootNode; |
| 64 | +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; |
64 | 65 | import com.oracle.graal.python.nodes.call.CallDispatchers; |
65 | 66 | import com.oracle.graal.python.nodes.call.CallNode; |
66 | 67 | import com.oracle.graal.python.nodes.frame.ReadCallerFrameNode; |
@@ -164,19 +165,30 @@ public final void execute(PythonContext context, Access access) { |
164 | 165 | Node prev = null; |
165 | 166 | Node location = access.getLocation(); |
166 | 167 | boolean locationAdoptable = location.isAdoptable(); |
| 168 | + EncapsulatingNodeReference encapsulatingNodeRef = EncapsulatingNodeReference.getCurrent(); |
167 | 169 | if (locationAdoptable) { |
168 | 170 | // If the location is not adoptable, then we are in |
169 | | - // IndirectCallContext and SimpleIndirectInvokeNode will do |
| 171 | + // IndirectCallContext and SimpleIndirectInvokeNode below will do |
170 | 172 | // IndirectCalleeContext.enter and transfer the state from thread state to |
171 | | - // the frame. If we were woken-up in middle of Python frame code, we will |
172 | | - // have to do a stack walk, but we still need the location |
173 | | - 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 | + } |
174 | 186 | } |
175 | 187 | try { |
176 | 188 | CallDispatchers.SimpleIndirectInvokeNode.executeUncached(context.getAsyncHandler().callTarget, args); |
177 | 189 | } catch (PException e) { |
178 | 190 | if (locationAdoptable) { |
179 | | - EncapsulatingNodeReference.getCurrent().set(prev); |
| 191 | + encapsulatingNodeRef.set(prev); |
180 | 192 | } |
181 | 193 | handleException(e); |
182 | 194 | } finally { |
|
0 commit comments