|
53 | 53 | import com.oracle.graal.python.nodes.argument.keywords.ExpandKeywordStarargsNode;
|
54 | 54 | import com.oracle.graal.python.nodes.argument.positional.ExecutePositionalStarargsNode;
|
55 | 55 | import com.oracle.graal.python.nodes.argument.positional.PositionalArgumentsNode;
|
56 |
| -import com.oracle.graal.python.nodes.call.CallNode; |
57 | 56 | import com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode;
|
58 | 57 | import com.oracle.graal.python.nodes.call.special.CallTernaryMethodNode;
|
| 58 | +import com.oracle.graal.python.nodes.call.special.CallVarargsMethodNode; |
59 | 59 | import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
|
60 | 60 | import com.oracle.graal.python.runtime.GilNode;
|
61 | 61 | import com.oracle.graal.python.runtime.exception.PException;
|
62 | 62 | import com.oracle.truffle.api.CompilerDirectives;
|
63 | 63 | import com.oracle.truffle.api.dsl.Cached;
|
64 | 64 | import com.oracle.truffle.api.dsl.Cached.Exclusive;
|
| 65 | +import com.oracle.truffle.api.dsl.Specialization; |
65 | 66 | import com.oracle.truffle.api.interop.ArityException;
|
66 | 67 | import com.oracle.truffle.api.interop.InteropLibrary;
|
67 | 68 | import com.oracle.truffle.api.interop.UnsupportedMessageException;
|
@@ -208,44 +209,48 @@ public InitWrapper(Object delegate) {
|
208 | 209 | super(delegate);
|
209 | 210 | }
|
210 | 211 |
|
211 |
| - @ExportMessage |
212 |
| - protected int execute(Object[] arguments, |
213 |
| - @CachedLibrary("this") PythonNativeWrapperLibrary lib, |
214 |
| - @Cached ExecutePositionalStarargsNode.ExecutePositionalStarargsInteropNode posStarargsNode, |
215 |
| - @Cached ExpandKeywordStarargsNode expandKwargsNode, |
216 |
| - @Exclusive @Cached CallNode callNode, |
217 |
| - @Cached ToJavaNode toJavaNode, |
218 |
| - @Cached ConditionProfile arityProfile, |
219 |
| - @Cached BranchProfile errorProfile, |
220 |
| - @Cached TransformExceptionToNativeNode transformExceptionToNativeNode, |
221 |
| - @Exclusive @Cached GilNode gil) throws ArityException { |
222 |
| - boolean mustRelease = gil.acquire(); |
223 |
| - try { |
224 |
| - if (arityProfile.profile(arguments.length != 3)) { |
225 |
| - CompilerDirectives.transferToInterpreterAndInvalidate(); |
226 |
| - throw ArityException.create(3, 3, arguments.length); |
227 |
| - } |
| 212 | + @ExportMessage(name = "execute") |
| 213 | + static class Execute { |
| 214 | + |
| 215 | + @Specialization(guards = "arguments.length == 3") |
| 216 | + static int init(InitWrapper self, Object[] arguments, |
| 217 | + @CachedLibrary("self") PythonNativeWrapperLibrary lib, |
| 218 | + @Cached ExecutePositionalStarargsNode.ExecutePositionalStarargsInteropNode posStarargsNode, |
| 219 | + @Cached ExpandKeywordStarargsNode expandKwargsNode, |
| 220 | + @Cached CallVarargsMethodNode callNode, |
| 221 | + @Cached ToJavaNode toJavaNode, |
| 222 | + @Cached BranchProfile errorProfile, |
| 223 | + @Cached TransformExceptionToNativeNode transformExceptionToNativeNode, |
| 224 | + @Exclusive @Cached GilNode gil) { |
| 225 | + boolean mustRelease = gil.acquire(); |
228 | 226 | try {
|
229 |
| - // convert args |
230 |
| - Object receiver = toJavaNode.execute(arguments[0]); |
231 |
| - Object starArgs = toJavaNode.execute(arguments[1]); |
232 |
| - Object kwArgs = toJavaNode.execute(arguments[2]); |
233 |
| - |
234 |
| - Object[] starArgsArray = posStarargsNode.executeWithGlobalState(starArgs); |
235 |
| - Object[] pArgs = PositionalArgumentsNode.prependArgument(receiver, starArgsArray); |
236 |
| - PKeyword[] kwArgsArray = expandKwargsNode.execute(kwArgs); |
237 |
| - callNode.execute(null, lib.getDelegate(this), pArgs, kwArgsArray); |
238 |
| - return 0; |
239 |
| - } catch (PException e) { |
240 |
| - errorProfile.enter(); |
241 |
| - transformExceptionToNativeNode.execute(null, e); |
242 |
| - return -1; |
| 227 | + try { |
| 228 | + // convert args |
| 229 | + Object receiver = toJavaNode.execute(arguments[0]); |
| 230 | + Object starArgs = toJavaNode.execute(arguments[1]); |
| 231 | + Object kwArgs = toJavaNode.execute(arguments[2]); |
| 232 | + |
| 233 | + Object[] starArgsArray = posStarargsNode.executeWithGlobalState(starArgs); |
| 234 | + Object[] pArgs = PositionalArgumentsNode.prependArgument(receiver, starArgsArray); |
| 235 | + PKeyword[] kwArgsArray = expandKwargsNode.execute(kwArgs); |
| 236 | + callNode.execute(null, lib.getDelegate(self), pArgs, kwArgsArray); |
| 237 | + return 0; |
| 238 | + } catch (PException e) { |
| 239 | + errorProfile.enter(); |
| 240 | + transformExceptionToNativeNode.execute(null, e); |
| 241 | + return -1; |
| 242 | + } |
| 243 | + } finally { |
| 244 | + gil.release(mustRelease); |
243 | 245 | }
|
244 |
| - } finally { |
245 |
| - gil.release(mustRelease); |
246 | 246 | }
|
247 |
| - } |
248 | 247 |
|
| 248 | + @Specialization(guards = "arguments.length != 3") |
| 249 | + static int error(@SuppressWarnings("unused") InitWrapper self, Object[] arguments) throws ArityException { |
| 250 | + throw ArityException.create(3, 3, arguments.length); |
| 251 | + } |
| 252 | + |
| 253 | + } |
249 | 254 | }
|
250 | 255 |
|
251 | 256 | @ExportLibrary(InteropLibrary.class)
|
|
0 commit comments