@@ -480,6 +480,8 @@ abstract static class TRegexCompile extends PythonTernaryBuiltinNode {
480
480
481
481
private static final TruffleString T__GETLOCALE = tsLiteral ("_getlocale" );
482
482
483
+ // limit of 2 specializations to allow inlining of both a must_advance=False and a
484
+ // must_advance=True version in re builtins like sub, split, findall
483
485
@ Specialization (guards = {"tRegexCache == cachedTRegexCache" , "method == cachedMethod" , "mustAdvance == cachedMustAdvance" , "!cachedTRegexCache.isLocaleSensitive()" }, limit = "2" )
484
486
Object cached (TRegexCache tRegexCache , PythonMethod method , boolean mustAdvance ,
485
487
@ Cached ("tRegexCache" ) TRegexCache cachedTRegexCache ,
@@ -493,6 +495,7 @@ protected Object getCompiledRegex(TRegexCache tRegexCache, PythonMethod method,
493
495
return localeNonSensitive (tRegexCache , method , mustAdvance , method , mustAdvance );
494
496
}
495
497
498
+ // limit of 6 specializations = 3 Python methods * 2 values of mustAdvance
496
499
@ Specialization (guards = {"method == cachedMethod" , "mustAdvance == cachedMustAdvance" , "!tRegexCache.isLocaleSensitive()" }, limit = "6" )
497
500
Object localeNonSensitive (TRegexCache tRegexCache , PythonMethod method , boolean mustAdvance ,
498
501
@ Cached ("method" ) PythonMethod cachedMethod ,
@@ -505,6 +508,7 @@ Object localeNonSensitive(TRegexCache tRegexCache, PythonMethod method, boolean
505
508
}
506
509
}
507
510
511
+ // limit of 6 specializations = 3 Python methods * 2 values of mustAdvance
508
512
@ Specialization (guards = {"method == cachedMethod" , "mustAdvance == cachedMustAdvance" , "tRegexCache.isLocaleSensitive()" }, limit = "6" )
509
513
Object localeSensitive (TRegexCache tRegexCache , PythonMethod method , boolean mustAdvance ,
510
514
@ Cached ("method" ) PythonMethod cachedMethod ,
@@ -686,6 +690,7 @@ protected Object doCachedRegex(VirtualFrame frame, Object pattern, Object input,
686
690
tRegexCallExec , createMatchFromTRegexResultNode );
687
691
}
688
692
693
+ // limit of 3 specializations = 3 Python methods
689
694
@ Specialization (guards = "method == cachedMethod" , limit = "3" , replaces = {"doCached" , "doCachedRegex" })
690
695
@ SuppressWarnings ("truffle-static-method" )
691
696
@ ReportPolymorphism .Megamorphic
@@ -763,6 +768,8 @@ abstract static class TRegexCallExec extends PythonTernaryBuiltinNode {
763
768
764
769
@ Child private BufferToTruffleStringNode bufferToTruffleStringNode ;
765
770
771
+ // limit of 2 specializations to allow inlining of both a must_advance=False and a
772
+ // must_advance=True version in re builtins like sub, split, findall
766
773
@ Specialization (guards = "callable == cachedCallable" , limit = "2" )
767
774
@ SuppressWarnings ("truffle-static-method" )
768
775
Object doCached (VirtualFrame frame , Object callable , Object inputStringOrBytes , Number fromIndex ,
0 commit comments