79
79
import com .oracle .graal .python .builtins .objects .bytes .BytesNodes ;
80
80
import com .oracle .graal .python .builtins .objects .bytes .PBytes ;
81
81
import com .oracle .graal .python .builtins .objects .bytes .PIBytesLike ;
82
- import com .oracle .graal .python .builtins .objects .cext .CAPIConversionNodeSupplier ;
83
82
import com .oracle .graal .python .builtins .objects .cext .CArrayWrappers .CByteArrayWrapper ;
84
83
import com .oracle .graal .python .builtins .objects .cext .CArrayWrappers .CStringWrapper ;
85
- import com .oracle .graal .python .builtins .objects .cext .CExtModsupportNodes ;
84
+ import com .oracle .graal .python .builtins .objects .cext .common . CExtParseArgumentsNode ;
86
85
import com .oracle .graal .python .builtins .objects .cext .CExtNodes ;
87
86
import com .oracle .graal .python .builtins .objects .cext .CExtNodes .CastToJavaDoubleNode ;
88
87
import com .oracle .graal .python .builtins .objects .cext .CExtNodes .GetNativeNullNode ;
112
111
import com .oracle .graal .python .builtins .objects .cext .PythonNativeWrapper ;
113
112
import com .oracle .graal .python .builtins .objects .cext .PythonNativeWrapperLibrary ;
114
113
import com .oracle .graal .python .builtins .objects .cext .UnicodeObjectNodes .UnicodeAsWideCharNode ;
115
- import com .oracle .graal .python .builtins .objects .cext .VaListWrapper ;
114
+ import com .oracle .graal .python .builtins .objects .cext .common .VaListWrapper ;
115
+ import com .oracle .graal .python .builtins .objects .cext .common .CExtAsPythonObjectNode ;
116
+ import com .oracle .graal .python .builtins .objects .cext .common .CExtCommonNodes .PCallCExtFunction ;
117
+ import com .oracle .graal .python .builtins .objects .cext .common .CExtContext ;
116
118
import com .oracle .graal .python .builtins .objects .code .PCode ;
117
119
import com .oracle .graal .python .builtins .objects .common .HashingCollectionNodes ;
118
120
import com .oracle .graal .python .builtins .objects .common .IndexNodes .NormalizeIndexNode ;
@@ -2971,25 +2973,22 @@ static boolean isEmptyDict(CExtNodes.AsPythonObjectNode asPythonObjectNode, Hash
2971
2973
}
2972
2974
}
2973
2975
2974
- abstract static class ParseTupleAndKeywordsBaseNode extends PythonVarargsBuiltinNode {
2976
+ public abstract static class ParseTupleAndKeywordsBaseNode extends PythonVarargsBuiltinNode {
2975
2977
2976
2978
@ Override
2977
2979
public Object varArgExecute (VirtualFrame frame , Object self , Object [] arguments , PKeyword [] keywords ) throws VarargsBuiltinDirectInvocationNotSupported {
2978
2980
return execute (frame , self , arguments , PKeyword .EMPTY_KEYWORDS );
2979
2981
}
2980
2982
2981
- static int doConvert (Object cextModule , Object argv , Object nativeKwds , Object nativeFormat , Object nativeKwdnames , Object nativeVarargs ,
2983
+ public static int doConvert (CExtContext nativeContext , Object nativeNull , Object argv , Object nativeKwds , Object nativeFormat , Object nativeKwdnames , Object nativeVarargs ,
2982
2984
ReferenceLibrary kwdsRefLib ,
2983
2985
ReferenceLibrary kwdnamesRefLib ,
2984
2986
ValueProfile kwdsProfile ,
2985
2987
ConditionProfile kwdnamesProfile ,
2986
2988
ConditionProfile functionNameProfile ,
2987
- CExtNodes . AsPythonObjectNode kwdsToJavaNode ,
2989
+ CExtAsPythonObjectNode kwdsToJavaNode ,
2988
2990
CastToJavaStringNode castToStringNode ,
2989
- CExtNodes .ToSulongNode nativeNullToSulongNode ,
2990
- GetNativeNullNode getNativeNullNode ,
2991
- CExtModsupportNodes .ParseTupleAndKeywordsNode parseTupleAndKeywordsNode ) {
2992
- Object nativeNull = nativeNullToSulongNode .execute (getNativeNullNode .execute (cextModule ));
2991
+ CExtParseArgumentsNode .ParseTupleAndKeywordsNode parseTupleAndKeywordsNode ) {
2993
2992
2994
2993
// force 'format' to be a String
2995
2994
String format = castToStringNode .execute (nativeFormat );
@@ -3010,13 +3009,13 @@ static int doConvert(Object cextModule, Object argv, Object nativeKwds, Object n
3010
3009
if (kwdsRefLib .isSame (nativeKwds , nativeNull )) {
3011
3010
kwds = null ;
3012
3011
} else {
3013
- kwds = kwdsToJavaNode .execute (nativeKwds );
3012
+ kwds = kwdsToJavaNode .execute (nativeContext , nativeKwds );
3014
3013
}
3015
3014
3016
3015
// sort out if kwdnames is native NULL
3017
3016
Object kwdnames = kwdnamesProfile .profile (kwdnamesRefLib .isSame (nativeKwdnames , nativeNull )) ? null : nativeKwdnames ;
3018
3017
3019
- return parseTupleAndKeywordsNode .execute (functionName , argv , kwdsProfile .profile (kwds ), format , kwdnames , nativeVarargs , CAPIConversionNodeSupplier . INSTANCE );
3018
+ return parseTupleAndKeywordsNode .execute (functionName , argv , kwdsProfile .profile (kwds ), format , kwdnames , nativeVarargs , nativeContext );
3020
3019
}
3021
3020
3022
3021
static Object getKwds (Object [] arguments ) {
@@ -3034,6 +3033,7 @@ abstract static class ParseTupleAndKeywordsNode extends ParseTupleAndKeywordsBas
3034
3033
3035
3034
@ Specialization (guards = "arguments.length == 5" , limit = "2" )
3036
3035
static int doConvert (Object cextModule , Object [] arguments , @ SuppressWarnings ("unused" ) PKeyword [] keywords ,
3036
+ @ CachedContext (PythonLanguage .class ) PythonContext context ,
3037
3037
@ CachedLibrary ("getKwds(arguments)" ) ReferenceLibrary kwdsRefLib ,
3038
3038
@ CachedLibrary ("getKwdnames(arguments)" ) ReferenceLibrary kwdnamesRefLib ,
3039
3039
@ Cached ("createIdentityProfile()" ) ValueProfile kwdsProfile ,
@@ -3044,10 +3044,12 @@ static int doConvert(Object cextModule, Object[] arguments, @SuppressWarnings("u
3044
3044
@ Cached CastToJavaStringNode castToStringNode ,
3045
3045
@ Cached CExtNodes .ToSulongNode nativeNullToSulongNode ,
3046
3046
@ Cached GetNativeNullNode getNativeNullNode ,
3047
- @ Cached CExtModsupportNodes .ParseTupleAndKeywordsNode parseTupleAndKeywordsNode ) {
3047
+ @ Cached CExtParseArgumentsNode .ParseTupleAndKeywordsNode parseTupleAndKeywordsNode ) {
3048
+ CExtContext nativeContext = context .getCApiContext ();
3048
3049
Object argv = argvToJavaNode .execute (arguments [0 ]);
3049
- return ParseTupleAndKeywordsBaseNode .doConvert (cextModule , argv , arguments [1 ], arguments [2 ], arguments [3 ], arguments [4 ], kwdsRefLib , kwdnamesRefLib , kwdsProfile , kwdnamesProfile ,
3050
- functionNameProfile , kwdsToJavaNode , castToStringNode , nativeNullToSulongNode , getNativeNullNode , parseTupleAndKeywordsNode );
3050
+ Object nativeNull = nativeNullToSulongNode .execute (getNativeNullNode .execute (cextModule ));
3051
+ return ParseTupleAndKeywordsBaseNode .doConvert (nativeContext , nativeNull , argv , arguments [1 ], arguments [2 ], arguments [3 ], arguments [4 ], kwdsRefLib , kwdnamesRefLib , kwdsProfile ,
3052
+ kwdnamesProfile , functionNameProfile , kwdsToJavaNode , castToStringNode , parseTupleAndKeywordsNode );
3051
3053
}
3052
3054
3053
3055
}
@@ -3058,6 +3060,7 @@ abstract static class ParseStackAndKeywordsNode extends ParseTupleAndKeywordsBas
3058
3060
3059
3061
@ Specialization (guards = "arguments.length == 5" , limit = "2" )
3060
3062
int doConvert (VirtualFrame frame , Object cextModule , Object [] arguments , @ SuppressWarnings ("unused" ) PKeyword [] keywords ,
3063
+ @ CachedContext (PythonLanguage .class ) PythonContext context ,
3061
3064
@ CachedLibrary ("getArgsArray(arguments)" ) InteropLibrary argsArrayLib ,
3062
3065
@ CachedLibrary ("getKwds(arguments)" ) ReferenceLibrary kwdsRefLib ,
3063
3066
@ CachedLibrary ("getKwdnames(arguments)" ) ReferenceLibrary kwdnamesRefLib ,
@@ -3069,18 +3072,20 @@ int doConvert(VirtualFrame frame, Object cextModule, Object[] arguments, @Suppre
3069
3072
@ Cached CastToJavaStringNode castToStringNode ,
3070
3073
@ Cached CExtNodes .ToSulongNode nativeNullToSulongNode ,
3071
3074
@ Cached GetNativeNullNode getNativeNullNode ,
3072
- @ Cached CExtModsupportNodes .ParseTupleAndKeywordsNode parseTupleAndKeywordsNode ,
3075
+ @ Cached CExtParseArgumentsNode .ParseTupleAndKeywordsNode parseTupleAndKeywordsNode ,
3073
3076
@ Cached PRaiseNativeNode raiseNode ) {
3074
3077
try {
3078
+ CExtContext nativeContext = context .getCApiContext ();
3075
3079
Object argsArray = arguments [0 ];
3076
3080
int n = PInt .intValueExact (argsArrayLib .getArraySize (argsArray ));
3077
3081
Object [] args = new Object [n ];
3078
3082
for (int i = 0 ; i < args .length ; i ++) {
3079
3083
args [i ] = argvToJavaNode .execute (argsArrayLib .readArrayElement (argsArray , i ));
3080
3084
}
3085
+ Object nativeNull = nativeNullToSulongNode .execute (getNativeNullNode .execute (cextModule ));
3081
3086
PTuple argv = factory ().createTuple (args );
3082
- return ParseTupleAndKeywordsBaseNode .doConvert (cextModule , argv , arguments [1 ], arguments [2 ], arguments [3 ], arguments [4 ], kwdsRefLib , kwdnamesRefLib , kwdsProfile , kwdnamesProfile ,
3083
- functionNameProfile , kwdsToJavaNode , castToStringNode , nativeNullToSulongNode , getNativeNullNode , parseTupleAndKeywordsNode );
3087
+ return ParseTupleAndKeywordsBaseNode .doConvert (nativeContext , nativeNull , argv , arguments [1 ], arguments [2 ], arguments [3 ], arguments [4 ], kwdsRefLib , kwdnamesRefLib , kwdsProfile ,
3088
+ kwdnamesProfile , functionNameProfile , kwdsToJavaNode , castToStringNode , parseTupleAndKeywordsNode );
3084
3089
} catch (InteropException e ) {
3085
3090
CompilerDirectives .transferToInterpreter ();
3086
3091
return raiseNode .raiseInt (frame , 0 , SystemError , "error when reading native argument stack: %s" , e );
@@ -3098,22 +3103,25 @@ abstract static class ParseTupleAndKeywordsVaListNode extends ParseTupleAndKeywo
3098
3103
3099
3104
@ Specialization (guards = "arguments.length == 5" , limit = "2" )
3100
3105
static int doConvert (Object cextModule , Object [] arguments , @ SuppressWarnings ("unused" ) PKeyword [] keywords ,
3106
+ @ CachedContext (PythonLanguage .class ) PythonContext context ,
3101
3107
@ CachedLibrary ("getKwds(arguments)" ) ReferenceLibrary kwdsRefLib ,
3102
3108
@ CachedLibrary ("getKwdnames(arguments)" ) ReferenceLibrary kwdnamesRefLib ,
3103
3109
@ Cached ("createIdentityProfile()" ) ValueProfile kwdsProfile ,
3104
3110
@ Cached ("createBinaryProfile()" ) ConditionProfile kwdnamesProfile ,
3105
3111
@ Cached ("createBinaryProfile()" ) ConditionProfile functionNameProfile ,
3106
- @ Cached PCallCapiFunction callMallocOutVarPtr ,
3112
+ @ Cached PCallCExtFunction callMallocOutVarPtr ,
3107
3113
@ Cached CExtNodes .AsPythonObjectNode argvToJavaNode ,
3108
3114
@ Cached CExtNodes .AsPythonObjectNode kwdsToJavaNode ,
3109
3115
@ Cached CastToJavaStringNode castToStringNode ,
3110
3116
@ Cached CExtNodes .ToSulongNode nativeNullToSulongNode ,
3111
3117
@ Cached GetNativeNullNode getNativeNullNode ,
3112
- @ Cached CExtModsupportNodes .ParseTupleAndKeywordsNode parseTupleAndKeywordsNode ) {
3118
+ @ Cached CExtParseArgumentsNode .ParseTupleAndKeywordsNode parseTupleAndKeywordsNode ) {
3119
+ CExtContext nativeContext = context .getCApiContext ();
3120
+ Object nativeNull = nativeNullToSulongNode .execute (getNativeNullNode .execute (cextModule ));
3113
3121
Object argv = argvToJavaNode .execute (arguments [0 ]);
3114
- VaListWrapper varargs = new VaListWrapper (arguments [4 ], callMallocOutVarPtr .call (NativeCAPISymbols .FUN_ALLOCATE_OUTVAR ));
3115
- return ParseTupleAndKeywordsBaseNode .doConvert (cextModule , argv , arguments [1 ], arguments [2 ], arguments [3 ], varargs , kwdsRefLib , kwdnamesRefLib , kwdsProfile , kwdnamesProfile ,
3116
- functionNameProfile , kwdsToJavaNode , castToStringNode , nativeNullToSulongNode , getNativeNullNode , parseTupleAndKeywordsNode );
3122
+ VaListWrapper varargs = new VaListWrapper (nativeContext , arguments [4 ], callMallocOutVarPtr .call (nativeContext , NativeCAPISymbols .FUN_ALLOCATE_OUTVAR ));
3123
+ return ParseTupleAndKeywordsBaseNode .doConvert (nativeContext , nativeNull , argv , arguments [1 ], arguments [2 ], arguments [3 ], varargs , kwdsRefLib , kwdnamesRefLib , kwdsProfile , kwdnamesProfile ,
3124
+ functionNameProfile , kwdsToJavaNode , castToStringNode , parseTupleAndKeywordsNode );
3117
3125
}
3118
3126
}
3119
3127
0 commit comments