@@ -3175,49 +3175,75 @@ protected static boolean isMappingOrSequence(Object obj) {
31753175 @ ReportPolymorphism
31763176 abstract static class PyObjectCallNode extends PythonTernaryBuiltinNode {
31773177
3178- @ Specialization ( limit = "3" )
3178+ @ Specialization
31793179 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 ,
31843180 @ 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 ,
31903184 @ Cached ToNewRefNode toNewRefNode ,
31913185 @ Cached GetNativeNullNode getNativeNullNode ,
31923186 @ Cached CExtNodes .ToSulongNode nullToSulongNode ,
31933187 @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
31943188
31953189 try {
31963190 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 );
32133193 return toNewRefNode .execute (callNode .execute (frame , callable , args , keywords ));
32143194 } catch (PException e ) {
3215- // getContext() acts as a branch profile
3195+ // transformExceptionToNativeNode acts as a branch profile
32163196 transformExceptionToNativeNode .execute (frame , e );
32173197 return nullToSulongNode .execute (getNativeNullNode .execute ());
32183198 }
32193199 }
32203200
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+
32213247 static boolean isEmptyDict (AsPythonObjectNode asPythonObjectNode , HashingCollectionNodes .LenNode lenNode , Object kwargsObj ) {
32223248 Object unwrapped = asPythonObjectNode .execute (kwargsObj );
32233249 if (unwrapped instanceof PDict ) {
0 commit comments