Skip to content

Commit 6fd5414

Browse files
committed
Add limit for unbounded @ExplodeLoops
1 parent ed39539 commit 6fd5414

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/KeywordsStorage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ private HashingStorage generalize(HashingStorageLibrary lib, PythonLanguage lang
214214

215215
@ExportMessage
216216
static class ForEachUntyped {
217-
@Specialization(guards = "self.length() == cachedLen", limit = "1")
217+
@Specialization(guards = {"self.length() == cachedLen", "cachedLen <= 32"}, limit = "1")
218218
@ExplodeLoop
219219
static Object cached(KeywordsStorage self, ForEachNode<Object> node, Object arg,
220220
@Exclusive @Cached("self.length()") int cachedLen) {
@@ -239,7 +239,7 @@ static Object generic(KeywordsStorage self, ForEachNode<Object> node, Object arg
239239

240240
@ExportMessage
241241
public static class AddAllToOther {
242-
@Specialization(guards = "self.length() == cachedLen", limit = "1")
242+
@Specialization(guards = {"self.length() == cachedLen", "cachedLen <= 32"}, limit = "1")
243243
@ExplodeLoop
244244
static HashingStorage cached(KeywordsStorage self, HashingStorage other,
245245
@Exclusive @Cached("self.length()") int cachedLen,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/CreateArgumentsNode.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@
6060
import com.oracle.graal.python.nodes.PNodeWithContext;
6161
import com.oracle.graal.python.nodes.PRaiseNode;
6262
import com.oracle.graal.python.nodes.argument.CreateArgumentsNodeGen.ApplyKeywordsNodeGen;
63-
import com.oracle.graal.python.nodes.argument.CreateArgumentsNodeGen.ApplyKeywordsNodeGen.SearchNamedParameterNodeGen;
6463
import com.oracle.graal.python.nodes.argument.CreateArgumentsNodeGen.ApplyPositionalArgumentsNodeGen;
6564
import com.oracle.graal.python.nodes.argument.CreateArgumentsNodeGen.CreateAndCheckArgumentsNodeGen;
6665
import com.oracle.graal.python.nodes.argument.CreateArgumentsNodeGen.FillDefaultsNodeGen;
6766
import com.oracle.graal.python.nodes.argument.CreateArgumentsNodeGen.FillKwDefaultsNodeGen;
6867
import com.oracle.graal.python.nodes.argument.CreateArgumentsNodeGen.FindKwDefaultNodeGen;
6968
import com.oracle.graal.python.nodes.argument.CreateArgumentsNodeGen.HandleTooManyArgumentsNodeGen;
69+
import com.oracle.graal.python.nodes.argument.CreateArgumentsNodeGen.ApplyKeywordsNodeGen.SearchNamedParameterNodeGen;
7070
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetDefaultsNode;
7171
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetKeywordDefaultsNode;
7272
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetSignatureNode;
@@ -375,7 +375,7 @@ protected abstract static class HandleTooManyArgumentsNode extends PNodeWithCont
375375
public abstract PException execute(Object[] scope_w, Object callable, Signature signature, int co_argcount, int co_kwonlyargcount, int ndefaults, int avail, boolean methodcall,
376376
int adjustCount);
377377

378-
@Specialization(guards = {"co_kwonlyargcount == cachedKwOnlyArgCount"})
378+
@Specialization(guards = {"co_kwonlyargcount == cachedKwOnlyArgCount", "cachedKwOnlyArgCount <= 32"})
379379
@ExplodeLoop
380380
static PException doCached(Object[] scope_w, Object callable, Signature signature, int co_argcount, @SuppressWarnings("unused") int co_kwonlyargcount, int ndefaults, int avail,
381381
boolean methodcall, int adjustCount,
@@ -543,7 +543,7 @@ int getUserArgumentLength(Object[] arguments) {
543543
return PArguments.getUserArgumentLength(arguments);
544544
}
545545

546-
@Specialization(guards = {"kwLen == keywords.length", "calleeSignature == cachedSignature"})
546+
@Specialization(guards = {"kwLen == keywords.length", "calleeSignature == cachedSignature", "kwLen <= 32"})
547547
@ExplodeLoop
548548
Object[] applyCached(Object callee, @SuppressWarnings("unused") Signature calleeSignature, Object[] arguments, PKeyword[] keywords,
549549
@Cached PRaiseNode raise,
@@ -687,7 +687,7 @@ private static String joinNames(List<String> names) {
687687
protected abstract static class SearchNamedParameterNode extends Node {
688688
public abstract int execute(String[] parameters, String name);
689689

690-
@Specialization(guards = "cachedLen == parameters.length")
690+
@Specialization(guards = {"cachedLen == parameters.length", "cachedLen <= 32"})
691691
@ExplodeLoop
692692
int cached(String[] parameters, String name,
693693
@Cached("parameters.length") int cachedLen) {
@@ -877,7 +877,7 @@ protected abstract static class FindKwDefaultNode extends Node {
877877

878878
public abstract PKeyword execute(PKeyword[] kwdefaults, String kwname);
879879

880-
@Specialization(guards = {"kwdefaults.length == cachedLength", "kwdefaults.length < 32"})
880+
@Specialization(guards = {"kwdefaults.length == cachedLength", "cachedLength < 32"})
881881
@ExplodeLoop(kind = LoopExplosionKind.FULL_UNROLL_UNTIL_RETURN)
882882
PKeyword doCached(PKeyword[] kwdefaults, String kwname,
883883
@Cached("kwdefaults.length") int cachedLength) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/CompactKeywordsNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
abstract class CompactKeywordsNode extends Node {
5454
public abstract PKeyword[] execute(PKeyword[] keys, int reshape);
5555

56-
@Specialization(guards = {"cachedLen == keys.length", "reshape == cachedReshape"}, limit = "getVariableArgumentInlineCacheLimit()")
56+
@Specialization(guards = {"cachedLen == keys.length", "reshape == cachedReshape", "cachedLen <= 32"}, limit = "getVariableArgumentInlineCacheLimit()")
5757
@ExplodeLoop
5858
PKeyword[] cached(PKeyword[] keys, @SuppressWarnings("unused") int reshape,
5959
@Cached("keys.length") int cachedLen,

0 commit comments

Comments
 (0)