@@ -3175,49 +3175,75 @@ protected static boolean isMappingOrSequence(Object obj) {
3175
3175
@ ReportPolymorphism
3176
3176
abstract static class PyObjectCallNode extends PythonTernaryBuiltinNode {
3177
3177
3178
- @ Specialization ( limit = "3" )
3178
+ @ Specialization
3179
3179
static Object doGeneric (VirtualFrame frame , Object callableObj , Object argsObj , Object kwargsObj ,
3180
- @ CachedLibrary ("argsObj" ) @ SuppressWarnings ("unused" ) InteropLibrary argsLib ,
3181
- @ CachedLibrary ("kwargsObj" ) @ SuppressWarnings ("unused" ) InteropLibrary kwargsLib ,
3182
- @ Cached ExecutePositionalStarargsNode expandArgsNode ,
3183
- @ Cached ExpandKeywordStarargsNode expandKwargsNode ,
3184
3180
@ Cached AsPythonObjectNode callableToJavaNode ,
3185
- @ Cached AsPythonObjectNode argsToJavaNode ,
3186
- @ Cached AsPythonObjectNode kwargsToJavaNode ,
3187
- @ Cached ("createBinaryProfile()" ) ConditionProfile argsIsNullProfile ,
3188
- @ Cached ("createBinaryProfile()" ) ConditionProfile kwargsIsNullProfile ,
3189
- @ Exclusive @ Cached CallNode callNode ,
3181
+ @ Cached CastArgsNode castArgsNode ,
3182
+ @ Cached CastKwargsNode castKwargsNode ,
3183
+ @ Cached CallNode callNode ,
3190
3184
@ Cached ToNewRefNode toNewRefNode ,
3191
3185
@ Cached GetNativeNullNode getNativeNullNode ,
3192
3186
@ Cached CExtNodes .ToSulongNode nullToSulongNode ,
3193
3187
@ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
3194
3188
3195
3189
try {
3196
3190
Object callable = callableToJavaNode .execute (callableObj );
3197
- Object [] args ;
3198
- PKeyword [] keywords ;
3199
-
3200
- // expand positional arguments
3201
- if (argsIsNullProfile .profile (argsLib .isNull (argsObj ))) {
3202
- args = new Object [0 ];
3203
- } else {
3204
- args = expandArgsNode .executeWith (frame , argsToJavaNode .execute (argsObj ));
3205
- }
3206
-
3207
- // expand keywords
3208
- if (kwargsIsNullProfile .profile (kwargsLib .isNull (kwargsObj ))) {
3209
- keywords = PKeyword .EMPTY_KEYWORDS ;
3210
- } else {
3211
- keywords = expandKwargsNode .executeWith (kwargsToJavaNode .execute (kwargsObj ));
3212
- }
3191
+ Object [] args = castArgsNode .execute (frame , argsObj );
3192
+ PKeyword [] keywords = castKwargsNode .execute (kwargsObj );
3213
3193
return toNewRefNode .execute (callNode .execute (frame , callable , args , keywords ));
3214
3194
} catch (PException e ) {
3215
- // getContext() acts as a branch profile
3195
+ // transformExceptionToNativeNode acts as a branch profile
3216
3196
transformExceptionToNativeNode .execute (frame , e );
3217
3197
return nullToSulongNode .execute (getNativeNullNode .execute ());
3218
3198
}
3219
3199
}
3220
3200
3201
+ }
3202
+
3203
+ @ ReportPolymorphism
3204
+ abstract static class CastArgsNode extends Node {
3205
+
3206
+ public abstract Object [] execute (VirtualFrame frame , Object argsObj );
3207
+
3208
+ @ Specialization (guards = "lib.isNull(argsObj)" )
3209
+ @ SuppressWarnings ("unused" )
3210
+ static Object [] doNull (VirtualFrame frame , Object argsObj ,
3211
+ @ Shared ("lib" ) @ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
3212
+ return new Object [0 ];
3213
+ }
3214
+
3215
+ @ Specialization (guards = "!lib.isNull(argsObj)" )
3216
+ static Object [] doNotNull (VirtualFrame frame , Object argsObj ,
3217
+ @ Cached ExecutePositionalStarargsNode expandArgsNode ,
3218
+ @ Cached AsPythonObjectNode argsToJavaNode ,
3219
+ @ Shared ("lib" ) @ CachedLibrary (limit = "3" ) @ SuppressWarnings ("unused" ) InteropLibrary lib ) {
3220
+ return expandArgsNode .executeWith (frame , argsToJavaNode .execute (argsObj ));
3221
+ }
3222
+ }
3223
+
3224
+ @ ReportPolymorphism
3225
+ abstract static class CastKwargsNode extends Node {
3226
+
3227
+ public abstract PKeyword [] execute (Object kwargsObj );
3228
+
3229
+ @ Specialization (guards = "lib.isNull(kwargsObj) || isEmptyDict(kwargsToJavaNode, lenNode, kwargsObj)" , limit = "1" )
3230
+ @ SuppressWarnings ("unused" )
3231
+ static PKeyword [] doNoKeywords (Object kwargsObj ,
3232
+ @ Shared ("lenNode" ) @ Cached HashingCollectionNodes .LenNode lenNode ,
3233
+ @ Shared ("kwargsToJavaNode" ) @ Cached AsPythonObjectNode kwargsToJavaNode ,
3234
+ @ Shared ("lib" ) @ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
3235
+ return PKeyword .EMPTY_KEYWORDS ;
3236
+ }
3237
+
3238
+ @ Specialization (guards = {"!lib.isNull(kwargsObj)" , "!isEmptyDict(kwargsToJavaNode, lenNode, kwargsObj)" }, limit = "1" )
3239
+ static PKeyword [] doKeywords (Object kwargsObj ,
3240
+ @ Shared ("lenNode" ) @ Cached @ SuppressWarnings ("unused" ) HashingCollectionNodes .LenNode lenNode ,
3241
+ @ Shared ("kwargsToJavaNode" ) @ Cached AsPythonObjectNode kwargsToJavaNode ,
3242
+ @ Shared ("lib" ) @ CachedLibrary (limit = "3" ) @ SuppressWarnings ("unused" ) InteropLibrary lib ,
3243
+ @ Cached ExpandKeywordStarargsNode expandKwargsNode ) {
3244
+ return expandKwargsNode .executeWith (kwargsToJavaNode .execute (kwargsObj ));
3245
+ }
3246
+
3221
3247
static boolean isEmptyDict (AsPythonObjectNode asPythonObjectNode , HashingCollectionNodes .LenNode lenNode , Object kwargsObj ) {
3222
3248
Object unwrapped = asPythonObjectNode .execute (kwargsObj );
3223
3249
if (unwrapped instanceof PDict ) {
0 commit comments