|
175 | 175 | import com.oracle.truffle.api.bytecode.BytecodeLocation;
|
176 | 176 | import com.oracle.truffle.api.bytecode.BytecodeNode;
|
177 | 177 | import com.oracle.truffle.api.bytecode.BytecodeRootNode;
|
| 178 | +import com.oracle.truffle.api.bytecode.EpilogExceptional; |
| 179 | +import com.oracle.truffle.api.bytecode.EpilogReturn; |
178 | 180 | import com.oracle.truffle.api.bytecode.GenerateBytecode;
|
179 | 181 | import com.oracle.truffle.api.bytecode.LocalSetter;
|
180 | 182 | import com.oracle.truffle.api.bytecode.LocalSetterRange;
|
181 | 183 | import com.oracle.truffle.api.bytecode.Operation;
|
182 | 184 | import com.oracle.truffle.api.bytecode.OperationProxy;
|
| 185 | +import com.oracle.truffle.api.bytecode.Prolog; |
183 | 186 | import com.oracle.truffle.api.bytecode.ShortCircuitOperation;
|
184 | 187 | import com.oracle.truffle.api.bytecode.ShortCircuitOperation.Operator;
|
185 | 188 | import com.oracle.truffle.api.bytecode.Variadic;
|
@@ -302,29 +305,39 @@ public String toString() {
|
302 | 305 | return "<function op " + co.name + ">";
|
303 | 306 | }
|
304 | 307 |
|
305 |
| - @Override |
306 |
| - public void executeProlog(VirtualFrame frame) { |
307 |
| - calleeContext.enter(frame); |
| 308 | + @Prolog |
| 309 | + public static final class EnterCalleeContext { |
| 310 | + @Specialization |
| 311 | + public static void doEnter(VirtualFrame frame, |
| 312 | + @Bind("$root") PBytecodeDSLRootNode root) { |
| 313 | + root.calleeContext.enter(frame); |
| 314 | + } |
308 | 315 | }
|
309 | 316 |
|
310 |
| - public MaterializedFrame createGeneratorFrame(Object[] arguments) { |
311 |
| - Object[] generatorFrameArguments = PArguments.create(); |
312 |
| - MaterializedFrame generatorFrame = Truffle.getRuntime().createMaterializedFrame(generatorFrameArguments, getFrameDescriptor()); |
313 |
| - PArguments.setGeneratorFrame(arguments, generatorFrame); |
314 |
| - PArguments.setCurrentFrameInfo(generatorFrameArguments, new PFrame.Reference(null)); |
315 |
| - // The invoking node will set these two to the correct value only when the callee requests |
316 |
| - // it, otherwise they stay at the initial value, which we must set to null here |
317 |
| - PArguments.setException(arguments, null); |
318 |
| - PArguments.setCallerFrameInfo(arguments, null); |
319 |
| - return generatorFrame; |
| 317 | + @EpilogReturn |
| 318 | + public static final class ExitCalleeContext { |
| 319 | + @Specialization |
| 320 | + public static Object doExit(VirtualFrame frame, Object returnValue, |
| 321 | + @Bind("$root") PBytecodeDSLRootNode root) { |
| 322 | + root.calleeContext.exit(frame, root); |
| 323 | + return returnValue; |
| 324 | + } |
320 | 325 | }
|
321 | 326 |
|
322 |
| - @Override |
323 |
| - public void executeEpilog(VirtualFrame frame, Object returnValue, Throwable throwable) { |
324 |
| - if (throwable != null && throwable instanceof PException pe) { |
325 |
| - pe.notifyAddedTracebackFrame(!isPythonInternal()); |
| 327 | + @EpilogExceptional |
| 328 | + public static final class ExitCalleeContextExceptional { |
| 329 | + @Specialization |
| 330 | + public static void doPException(VirtualFrame frame, PException pe, |
| 331 | + @Bind("$root") PBytecodeDSLRootNode root) { |
| 332 | + pe.notifyAddedTracebackFrame(!root.isPythonInternal()); |
| 333 | + root.calleeContext.exit(frame, root); |
| 334 | + } |
| 335 | + |
| 336 | + @Specialization |
| 337 | + public static void doOther(VirtualFrame frame, AbstractTruffleException ate, |
| 338 | + @Bind("$root") PBytecodeDSLRootNode root) { |
| 339 | + root.calleeContext.exit(frame, root); |
326 | 340 | }
|
327 |
| - calleeContext.exit(frame, this); |
328 | 341 | }
|
329 | 342 |
|
330 | 343 | @Override
|
@@ -427,6 +440,18 @@ protected byte[] extractCode() {
|
427 | 440 | return MarshalModuleBuiltins.serializeCodeUnit(co);
|
428 | 441 | }
|
429 | 442 |
|
| 443 | + public MaterializedFrame createGeneratorFrame(Object[] arguments) { |
| 444 | + Object[] generatorFrameArguments = PArguments.create(); |
| 445 | + MaterializedFrame generatorFrame = Truffle.getRuntime().createMaterializedFrame(generatorFrameArguments, getFrameDescriptor()); |
| 446 | + PArguments.setGeneratorFrame(arguments, generatorFrame); |
| 447 | + PArguments.setCurrentFrameInfo(generatorFrameArguments, new PFrame.Reference(null)); |
| 448 | + // The invoking node will set these two to the correct value only when the callee requests |
| 449 | + // it, otherwise they stay at the initial value, which we must set to null here |
| 450 | + PArguments.setException(arguments, null); |
| 451 | + PArguments.setCallerFrameInfo(arguments, null); |
| 452 | + return generatorFrame; |
| 453 | + } |
| 454 | + |
430 | 455 | private static Object checkUnboundCell(PCell cell, int index, PBytecodeDSLRootNode rootNode, Node inliningTarget, PRaiseNode.Lazy raiseNode) {
|
431 | 456 | Object result = cell.getRef();
|
432 | 457 | if (result == null) {
|
@@ -3339,7 +3364,7 @@ private static void handleException(VirtualFrame frame, PException e, Node inlin
|
3339 | 3364 | }
|
3340 | 3365 |
|
3341 | 3366 | @Operation
|
3342 |
| - @SuppressWarnings("turffle-interpreted-performance") |
| 3367 | + @SuppressWarnings("truffle-interpreted-performance") |
3343 | 3368 | public static final class YieldFromThrow {
|
3344 | 3369 |
|
3345 | 3370 | private static final TruffleString T_CLOSE = tsLiteral("close");
|
|
0 commit comments