Skip to content

Commit 368e980

Browse files
committed
Add comments on the values of Specialization.limit
1 parent fa7cc39 commit 368e980

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ abstract static class TRegexCompile extends PythonTernaryBuiltinNode {
480480

481481
private static final TruffleString T__GETLOCALE = tsLiteral("_getlocale");
482482

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
483485
@Specialization(guards = {"tRegexCache == cachedTRegexCache", "method == cachedMethod", "mustAdvance == cachedMustAdvance", "!cachedTRegexCache.isLocaleSensitive()"}, limit = "2")
484486
Object cached(TRegexCache tRegexCache, PythonMethod method, boolean mustAdvance,
485487
@Cached("tRegexCache") TRegexCache cachedTRegexCache,
@@ -493,6 +495,7 @@ protected Object getCompiledRegex(TRegexCache tRegexCache, PythonMethod method,
493495
return localeNonSensitive(tRegexCache, method, mustAdvance, method, mustAdvance);
494496
}
495497

498+
// limit of 6 specializations = 3 Python methods * 2 values of mustAdvance
496499
@Specialization(guards = {"method == cachedMethod", "mustAdvance == cachedMustAdvance", "!tRegexCache.isLocaleSensitive()"}, limit = "6")
497500
Object localeNonSensitive(TRegexCache tRegexCache, PythonMethod method, boolean mustAdvance,
498501
@Cached("method") PythonMethod cachedMethod,
@@ -505,6 +508,7 @@ Object localeNonSensitive(TRegexCache tRegexCache, PythonMethod method, boolean
505508
}
506509
}
507510

511+
// limit of 6 specializations = 3 Python methods * 2 values of mustAdvance
508512
@Specialization(guards = {"method == cachedMethod", "mustAdvance == cachedMustAdvance", "tRegexCache.isLocaleSensitive()"}, limit = "6")
509513
Object localeSensitive(TRegexCache tRegexCache, PythonMethod method, boolean mustAdvance,
510514
@Cached("method") PythonMethod cachedMethod,
@@ -686,6 +690,7 @@ protected Object doCachedRegex(VirtualFrame frame, Object pattern, Object input,
686690
tRegexCallExec, createMatchFromTRegexResultNode);
687691
}
688692

693+
// limit of 3 specializations = 3 Python methods
689694
@Specialization(guards = "method == cachedMethod", limit = "3", replaces = {"doCached", "doCachedRegex"})
690695
@SuppressWarnings("truffle-static-method")
691696
@ReportPolymorphism.Megamorphic
@@ -763,6 +768,8 @@ abstract static class TRegexCallExec extends PythonTernaryBuiltinNode {
763768

764769
@Child private BufferToTruffleStringNode bufferToTruffleStringNode;
765770

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
766773
@Specialization(guards = "callable == cachedCallable", limit = "2")
767774
@SuppressWarnings("truffle-static-method")
768775
Object doCached(VirtualFrame frame, Object callable, Object inputStringOrBytes, Number fromIndex,

0 commit comments

Comments
 (0)