Skip to content

Commit b7dbd07

Browse files
committed
Use new prolog/epilog interface
1 parent cf6800c commit b7dbd07

File tree

2 files changed

+44
-20
lines changed

2 files changed

+44
-20
lines changed

Diff for: graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java

+44-19
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,14 @@
175175
import com.oracle.truffle.api.bytecode.BytecodeLocation;
176176
import com.oracle.truffle.api.bytecode.BytecodeNode;
177177
import com.oracle.truffle.api.bytecode.BytecodeRootNode;
178+
import com.oracle.truffle.api.bytecode.EpilogExceptional;
179+
import com.oracle.truffle.api.bytecode.EpilogReturn;
178180
import com.oracle.truffle.api.bytecode.GenerateBytecode;
179181
import com.oracle.truffle.api.bytecode.LocalSetter;
180182
import com.oracle.truffle.api.bytecode.LocalSetterRange;
181183
import com.oracle.truffle.api.bytecode.Operation;
182184
import com.oracle.truffle.api.bytecode.OperationProxy;
185+
import com.oracle.truffle.api.bytecode.Prolog;
183186
import com.oracle.truffle.api.bytecode.ShortCircuitOperation;
184187
import com.oracle.truffle.api.bytecode.ShortCircuitOperation.Operator;
185188
import com.oracle.truffle.api.bytecode.Variadic;
@@ -302,29 +305,39 @@ public String toString() {
302305
return "<function op " + co.name + ">";
303306
}
304307

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+
}
308315
}
309316

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+
}
320325
}
321326

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);
326340
}
327-
calleeContext.exit(frame, this);
328341
}
329342

330343
@Override
@@ -427,6 +440,18 @@ protected byte[] extractCode() {
427440
return MarshalModuleBuiltins.serializeCodeUnit(co);
428441
}
429442

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+
430455
private static Object checkUnboundCell(PCell cell, int index, PBytecodeDSLRootNode rootNode, Node inliningTarget, PRaiseNode.Lazy raiseNode) {
431456
Object result = cell.getRef();
432457
if (result == null) {
@@ -3339,7 +3364,7 @@ private static void handleException(VirtualFrame frame, PException e, Node inlin
33393364
}
33403365

33413366
@Operation
3342-
@SuppressWarnings("turffle-interpreted-performance")
3367+
@SuppressWarnings("truffle-interpreted-performance")
33433368
public static final class YieldFromThrow {
33443369

33453370
private static final TruffleString T_CLOSE = tsLiteral("close");

Diff for: mx.graalpython/mx_graalpython.py

-1
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,6 @@ def do_junit(use_dsl_interpreter=False):
15191519
mx.run(["env"])
15201520
run_python_unittests(
15211521
graalpy_standalone_jvm(),
1522-
javaAsserts=True,
15231522
exclude=excluded_tests,
15241523
nonZeroIsFatal=nonZeroIsFatal,
15251524
report=report(),

0 commit comments

Comments
 (0)