|
92 | 92 | import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
|
93 | 93 | import com.oracle.graal.python.builtins.objects.complex.PComplex;
|
94 | 94 | import com.oracle.graal.python.builtins.objects.floats.PFloat;
|
| 95 | +import com.oracle.graal.python.builtins.objects.function.PArguments; |
95 | 96 | import com.oracle.graal.python.builtins.objects.function.PKeyword;
|
96 | 97 | import com.oracle.graal.python.builtins.objects.function.Signature;
|
97 | 98 | import com.oracle.graal.python.builtins.objects.getsetdescriptor.DescriptorDeleteMarker;
|
|
113 | 114 | import com.oracle.graal.python.nodes.SpecialMethodNames;
|
114 | 115 | import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode;
|
115 | 116 | import com.oracle.graal.python.nodes.call.CallNode;
|
| 117 | +import com.oracle.graal.python.nodes.call.CallTargetInvokeNode; |
116 | 118 | import com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode;
|
117 | 119 | import com.oracle.graal.python.nodes.call.special.CallTernaryMethodNode;
|
118 | 120 | import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
|
|
124 | 126 | import com.oracle.graal.python.nodes.truffle.PythonTypes;
|
125 | 127 | import com.oracle.graal.python.nodes.util.CannotCastException;
|
126 | 128 | import com.oracle.graal.python.nodes.util.CastToJavaLongLossyNode;
|
| 129 | +import com.oracle.graal.python.runtime.ExecutionContext.CalleeContext; |
127 | 130 | import com.oracle.graal.python.runtime.PythonContext;
|
128 | 131 | import com.oracle.graal.python.runtime.PythonCore;
|
129 | 132 | import com.oracle.graal.python.runtime.PythonOptions;
|
|
138 | 141 | import com.oracle.truffle.api.CompilerDirectives;
|
139 | 142 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
140 | 143 | import com.oracle.truffle.api.RootCallTarget;
|
141 |
| -import com.oracle.truffle.api.Truffle; |
142 | 144 | import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
143 | 145 | import com.oracle.truffle.api.TruffleLogger;
|
144 | 146 | import com.oracle.truffle.api.dsl.Cached;
|
|
159 | 161 | import com.oracle.truffle.api.interop.UnsupportedMessageException;
|
160 | 162 | import com.oracle.truffle.api.interop.UnsupportedTypeException;
|
161 | 163 | import com.oracle.truffle.api.library.CachedLibrary;
|
162 |
| -import com.oracle.truffle.api.nodes.DirectCallNode; |
163 | 164 | import com.oracle.truffle.api.nodes.ExplodeLoop;
|
164 | 165 | import com.oracle.truffle.api.nodes.InvalidAssumptionException;
|
165 | 166 | import com.oracle.truffle.api.nodes.Node;
|
@@ -2476,27 +2477,40 @@ public static PCallCapiFunction getUncached() {
|
2476 | 2477 | // -----------------------------------------------------------------------------------------------------------------
|
2477 | 2478 | @Builtin(takesVarArgs = true)
|
2478 | 2479 | public static class MayRaiseNode extends PRootNode {
|
2479 |
| - @Child private DirectCallNode callNode; |
| 2480 | + @Child private CallTargetInvokeNode callTargetInvokeNode; |
2480 | 2481 | @Child private TransformExceptionToNativeNode transformExceptionToNativeNode;
|
| 2482 | + @Child private CalleeContext calleeContext; |
2481 | 2483 |
|
2482 | 2484 | private final Signature signature;
|
2483 | 2485 | private final Object errorResult;
|
2484 | 2486 |
|
2485 | 2487 | public MayRaiseNode(PythonLanguage lang, Signature sign, RootCallTarget ct, Object errorResult) {
|
2486 | 2488 | super(lang);
|
2487 | 2489 | this.signature = sign;
|
2488 |
| - this.callNode = Truffle.getRuntime().createDirectCallNode(ct); |
| 2490 | + this.callTargetInvokeNode = CallTargetInvokeNode.create(ct, false, false); |
| 2491 | + this.calleeContext = CalleeContext.create(); |
2489 | 2492 | this.errorResult = errorResult;
|
2490 | 2493 | }
|
2491 | 2494 |
|
2492 | 2495 | @Override
|
2493 | 2496 | public final Object execute(VirtualFrame frame) {
|
| 2497 | + Object[] arguments = frame.getArguments(); |
| 2498 | + int userArgumentLength = PArguments.getUserArgumentLength(arguments); |
| 2499 | + Object[] newArguments = PArguments.create(userArgumentLength); |
| 2500 | + // just copy user arguments, varargs and kwargs |
| 2501 | + System.arraycopy(arguments, PArguments.USER_ARGUMENTS_OFFSET, newArguments, PArguments.USER_ARGUMENTS_OFFSET, userArgumentLength); |
| 2502 | + PArguments.setVariableArguments(newArguments, PArguments.getVariableArguments(arguments)); |
| 2503 | + PArguments.setKeywordArguments(newArguments, PArguments.getKeywordArguments(arguments)); |
| 2504 | + |
| 2505 | + calleeContext.enter(frame); |
2494 | 2506 | try {
|
2495 |
| - return callNode.call(frame.getArguments()); |
| 2507 | + return callTargetInvokeNode.execute(frame, null, PArguments.getGlobals(arguments), PArguments.getClosure(arguments), newArguments); |
2496 | 2508 | } catch (PException e) {
|
2497 | 2509 | // transformExceptionToNativeNode acts as a branch profile
|
2498 | 2510 | ensureTransformExceptionToNativeNode().execute(frame, e);
|
2499 | 2511 | return errorResult;
|
| 2512 | + } finally { |
| 2513 | + calleeContext.exit(frame, this); |
2500 | 2514 | }
|
2501 | 2515 | }
|
2502 | 2516 |
|
|
0 commit comments