|
79 | 79 | import com.oracle.truffle.api.frame.FrameInstance; |
80 | 80 | import com.oracle.truffle.api.frame.MaterializedFrame; |
81 | 81 | import com.oracle.truffle.api.frame.VirtualFrame; |
| 82 | +import com.oracle.truffle.api.nodes.DenyReplace; |
82 | 83 | import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; |
83 | 84 | import com.oracle.truffle.api.nodes.Node; |
| 85 | +import com.oracle.truffle.api.nodes.UnadoptableNode; |
84 | 86 | import com.oracle.truffle.api.profiles.InlinedConditionProfile; |
85 | 87 | import com.oracle.truffle.api.profiles.InlinedCountingConditionProfile; |
86 | 88 |
|
@@ -199,7 +201,6 @@ protected static void prepareCall(VirtualFrame frame, Object[] callArguments, in |
199 | 201 | * the stack up once. |
200 | 202 | */ |
201 | 203 | @GenerateCached(false) |
202 | | - @GenerateUncached |
203 | 204 | @GenerateInline |
204 | 205 | @ImportStatic({PArguments.class, CallerFlags.class}) |
205 | 206 | protected abstract static class PassCallerFrameNode extends Node { |
@@ -240,10 +241,25 @@ protected static void passCallerFrame(VirtualFrame frame, Object[] callArguments |
240 | 241 | protected static void passEmptyCallerFrame(VirtualFrame frame, Object[] callArguments, int callerFlags) { |
241 | 242 | PArguments.setCallerFrameInfo(callArguments, PFrame.Reference.EMPTY); |
242 | 243 | } |
| 244 | + |
| 245 | + @DenyReplace |
| 246 | + @GenerateCached(false) |
| 247 | + private static final class Uncached extends PassCallerFrameNode implements UnadoptableNode { |
| 248 | + private static final Uncached INSTANCE = new Uncached(); |
| 249 | + |
| 250 | + @Override |
| 251 | + protected void execute(VirtualFrame frame, Node inliningTarget, Object[] callArguments, int callerFlags) { |
| 252 | + // Always pass the reference when uncached |
| 253 | + passCallerFrame(frame, callArguments, callerFlags, MaterializeFrameNode.getUncached()); |
| 254 | + } |
| 255 | + } |
| 256 | + |
| 257 | + public static PassCallerFrameNode getUncached() { |
| 258 | + return Uncached.INSTANCE; |
| 259 | + } |
243 | 260 | } |
244 | 261 |
|
245 | 262 | @GenerateCached(false) |
246 | | - @GenerateUncached |
247 | 263 | @GenerateInline |
248 | 264 | @ImportStatic(PArguments.class) |
249 | 265 | protected abstract static class PassExceptionStateNode extends Node { |
@@ -327,6 +343,29 @@ protected static void passNoExceptionState(VirtualFrame frame, Node inliningTarg |
327 | 343 | // inside Python led us here |
328 | 344 | PArguments.setException(callArguments, PException.NO_EXCEPTION); |
329 | 345 | } |
| 346 | + |
| 347 | + @DenyReplace |
| 348 | + @GenerateCached(false) |
| 349 | + private static final class Uncached extends PassExceptionStateNode implements UnadoptableNode { |
| 350 | + private static final Uncached INSTANCE = new Uncached(); |
| 351 | + |
| 352 | + @Override |
| 353 | + protected void execute(VirtualFrame frame, Node inliningTarget, Object[] callArguments, boolean needsExceptionState) { |
| 354 | + if (PArguments.isPythonFrame(frame)) { |
| 355 | + AbstractTruffleException exception = PArguments.getException(frame); |
| 356 | + // Always pass the exception when we have it |
| 357 | + if (exception != null) { |
| 358 | + PArguments.setException(callArguments, exception); |
| 359 | + } else if (needsExceptionState) { |
| 360 | + passExceptionStateFromStackWalk(frame, null, callArguments, true); |
| 361 | + } |
| 362 | + } |
| 363 | + } |
| 364 | + } |
| 365 | + |
| 366 | + public static PassExceptionStateNode getUncached() { |
| 367 | + return Uncached.INSTANCE; |
| 368 | + } |
330 | 369 | } |
331 | 370 | } |
332 | 371 |
|
|
0 commit comments