Skip to content

Commit ac932be

Browse files
committed
Add better uncached versions of PassCallerFrameNode and PassExceptionStateNode
1 parent cc1af0c commit ac932be

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ExecutionContext.java

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@
7979
import com.oracle.truffle.api.frame.FrameInstance;
8080
import com.oracle.truffle.api.frame.MaterializedFrame;
8181
import com.oracle.truffle.api.frame.VirtualFrame;
82+
import com.oracle.truffle.api.nodes.DenyReplace;
8283
import com.oracle.truffle.api.nodes.EncapsulatingNodeReference;
8384
import com.oracle.truffle.api.nodes.Node;
85+
import com.oracle.truffle.api.nodes.UnadoptableNode;
8486
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
8587
import com.oracle.truffle.api.profiles.InlinedCountingConditionProfile;
8688

@@ -199,7 +201,6 @@ protected static void prepareCall(VirtualFrame frame, Object[] callArguments, in
199201
* the stack up once.
200202
*/
201203
@GenerateCached(false)
202-
@GenerateUncached
203204
@GenerateInline
204205
@ImportStatic({PArguments.class, CallerFlags.class})
205206
protected abstract static class PassCallerFrameNode extends Node {
@@ -240,10 +241,25 @@ protected static void passCallerFrame(VirtualFrame frame, Object[] callArguments
240241
protected static void passEmptyCallerFrame(VirtualFrame frame, Object[] callArguments, int callerFlags) {
241242
PArguments.setCallerFrameInfo(callArguments, PFrame.Reference.EMPTY);
242243
}
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+
}
243260
}
244261

245262
@GenerateCached(false)
246-
@GenerateUncached
247263
@GenerateInline
248264
@ImportStatic(PArguments.class)
249265
protected abstract static class PassExceptionStateNode extends Node {
@@ -327,6 +343,29 @@ protected static void passNoExceptionState(VirtualFrame frame, Node inliningTarg
327343
// inside Python led us here
328344
PArguments.setException(callArguments, PException.NO_EXCEPTION);
329345
}
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+
}
330369
}
331370
}
332371

0 commit comments

Comments
 (0)