157
157
import com .oracle .graal .python .builtins .objects .cext .common .CExtCommonNodes .UnicodeFromWcharNode ;
158
158
import com .oracle .graal .python .builtins .objects .cext .common .CExtContext ;
159
159
import com .oracle .graal .python .builtins .objects .cext .common .CExtParseArgumentsNode ;
160
+ import com .oracle .graal .python .builtins .objects .cext .common .CExtParseArgumentsNode .SplitFormatStringNode ;
160
161
import com .oracle .graal .python .builtins .objects .cext .common .VaListWrapper ;
161
162
import com .oracle .graal .python .builtins .objects .code .PCode ;
162
163
import com .oracle .graal .python .builtins .objects .common .HashingCollectionNodes ;
@@ -3276,34 +3277,27 @@ public Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments,
3276
3277
}
3277
3278
3278
3279
public static int doConvert (CExtContext nativeContext , Object argv , Object nativeKwds , Object nativeFormat , Object nativeKwdnames , Object nativeVarargs ,
3280
+ SplitFormatStringNode splitFormatStringNode ,
3279
3281
InteropLibrary kwdsRefLib ,
3280
3282
InteropLibrary kwdnamesRefLib ,
3281
3283
ConditionProfile kwdsProfile ,
3282
3284
ConditionProfile kwdnamesProfile ,
3283
- ConditionProfile functionNameProfile ,
3284
3285
CExtAsPythonObjectNode kwdsToJavaNode ,
3285
3286
CastToJavaStringNode castToStringNode ,
3286
3287
CExtParseArgumentsNode .ParseTupleAndKeywordsNode parseTupleAndKeywordsNode ) {
3287
3288
3288
3289
// force 'format' to be a String
3289
- String format ;
3290
+ String [] split ;
3290
3291
try {
3291
- format = castToStringNode .execute (nativeFormat );
3292
+ split = splitFormatStringNode .execute (castToStringNode .execute (nativeFormat ));
3293
+ assert split .length == 2 ;
3292
3294
} catch (CannotCastException e ) {
3293
3295
CompilerDirectives .transferToInterpreterAndInvalidate ();
3294
3296
throw new IllegalStateException ();
3295
3297
}
3296
- String functionName = null ;
3297
3298
3298
- int colonIdx = format .indexOf (":" );
3299
- if (functionNameProfile .profile (colonIdx != -1 )) {
3300
- // extract function name
3301
- // use 'colonIdx+1' because we do not want to include the colon
3302
- functionName = format .substring (colonIdx + 1 );
3303
-
3304
- // trim off function name
3305
- format = format .substring (0 , colonIdx );
3306
- }
3299
+ String format = split [0 ];
3300
+ String functionName = split [1 ];
3307
3301
3308
3302
// sort out if kwds is native NULL
3309
3303
Object kwds ;
@@ -3333,21 +3327,21 @@ static Object getKwdnames(Object[] arguments) {
3333
3327
abstract static class ParseTupleAndKeywordsNode extends ParseTupleAndKeywordsBaseNode {
3334
3328
3335
3329
@ Specialization (guards = "arguments.length == 5" , limit = "2" )
3336
- static int doConvert (Object self , Object [] arguments , @ SuppressWarnings ("unused" ) PKeyword [] keywords ,
3330
+ static int doConvert (@ SuppressWarnings ( "unused" ) Object self , Object [] arguments , @ SuppressWarnings ("unused" ) PKeyword [] keywords ,
3337
3331
@ CachedContext (PythonLanguage .class ) PythonContext context ,
3332
+ @ Cached SplitFormatStringNode splitFormatStringNode ,
3338
3333
@ CachedLibrary ("getKwds(arguments)" ) InteropLibrary kwdsInteropLib ,
3339
3334
@ CachedLibrary ("getKwdnames(arguments)" ) InteropLibrary kwdnamesRefLib ,
3340
3335
@ Cached ("createBinaryProfile()" ) ConditionProfile kwdsProfile ,
3341
3336
@ Cached ("createBinaryProfile()" ) ConditionProfile kwdnamesProfile ,
3342
- @ Cached ("createBinaryProfile()" ) ConditionProfile functionNameProfile ,
3343
3337
@ Cached CExtNodes .AsPythonObjectNode argvToJavaNode ,
3344
3338
@ Cached CExtNodes .AsPythonObjectNode kwdsToJavaNode ,
3345
3339
@ Cached CastToJavaStringNode castToStringNode ,
3346
3340
@ Cached CExtParseArgumentsNode .ParseTupleAndKeywordsNode parseTupleAndKeywordsNode ) {
3347
3341
CExtContext nativeContext = context .getCApiContext ();
3348
3342
Object argv = argvToJavaNode .execute (arguments [0 ]);
3349
- return ParseTupleAndKeywordsBaseNode .doConvert (nativeContext , argv , arguments [1 ], arguments [2 ], arguments [3 ], arguments [4 ], kwdsInteropLib , kwdnamesRefLib , kwdsProfile ,
3350
- kwdnamesProfile , functionNameProfile , kwdsToJavaNode , castToStringNode , parseTupleAndKeywordsNode );
3343
+ return ParseTupleAndKeywordsBaseNode .doConvert (nativeContext , argv , arguments [1 ], arguments [2 ], arguments [3 ], arguments [4 ], splitFormatStringNode , kwdsInteropLib , kwdnamesRefLib ,
3344
+ kwdsProfile , kwdnamesProfile , kwdsToJavaNode , castToStringNode , parseTupleAndKeywordsNode );
3351
3345
}
3352
3346
3353
3347
}
@@ -3357,13 +3351,13 @@ static int doConvert(Object self, Object[] arguments, @SuppressWarnings("unused"
3357
3351
abstract static class ParseTupleAndKeywordsVaListNode extends ParseTupleAndKeywordsBaseNode {
3358
3352
3359
3353
@ Specialization (guards = "arguments.length == 5" , limit = "2" )
3360
- static int doConvert (Object self , Object [] arguments , @ SuppressWarnings ("unused" ) PKeyword [] keywords ,
3354
+ static int doConvert (@ SuppressWarnings ( "unused" ) Object self , Object [] arguments , @ SuppressWarnings ("unused" ) PKeyword [] keywords ,
3361
3355
@ CachedContext (PythonLanguage .class ) PythonContext context ,
3356
+ @ Cached SplitFormatStringNode splitFormatStringNode ,
3362
3357
@ CachedLibrary ("getKwds(arguments)" ) InteropLibrary kwdsRefLib ,
3363
3358
@ CachedLibrary ("getKwdnames(arguments)" ) InteropLibrary kwdnamesRefLib ,
3364
3359
@ Cached ("createBinaryProfile()" ) ConditionProfile kwdsProfile ,
3365
3360
@ Cached ("createBinaryProfile()" ) ConditionProfile kwdnamesProfile ,
3366
- @ Cached ("createBinaryProfile()" ) ConditionProfile functionNameProfile ,
3367
3361
@ Cached PCallCExtFunction callMallocOutVarPtr ,
3368
3362
@ Cached CExtNodes .AsPythonObjectNode argvToJavaNode ,
3369
3363
@ Cached CExtNodes .AsPythonObjectNode kwdsToJavaNode ,
@@ -3372,8 +3366,8 @@ static int doConvert(Object self, Object[] arguments, @SuppressWarnings("unused"
3372
3366
CExtContext nativeContext = context .getCApiContext ();
3373
3367
Object argv = argvToJavaNode .execute (arguments [0 ]);
3374
3368
VaListWrapper varargs = new VaListWrapper (nativeContext , arguments [4 ], callMallocOutVarPtr .call (nativeContext , NativeCAPISymbols .FUN_ALLOCATE_OUTVAR ));
3375
- return ParseTupleAndKeywordsBaseNode .doConvert (nativeContext , argv , arguments [1 ], arguments [2 ], arguments [3 ], varargs , kwdsRefLib , kwdnamesRefLib , kwdsProfile , kwdnamesProfile ,
3376
- functionNameProfile , kwdsToJavaNode , castToStringNode , parseTupleAndKeywordsNode );
3369
+ return ParseTupleAndKeywordsBaseNode .doConvert (nativeContext , argv , arguments [1 ], arguments [2 ], arguments [3 ], varargs , splitFormatStringNode , kwdsRefLib , kwdnamesRefLib , kwdsProfile ,
3370
+ kwdnamesProfile , kwdsToJavaNode , castToStringNode , parseTupleAndKeywordsNode );
3377
3371
}
3378
3372
}
3379
3373
0 commit comments