Skip to content

Commit 9e82f9d

Browse files
committed
[GR-13779] Add missing @ExplodeLoop in 'KeywordArgumentsNode'.
PullRequest: graalpython/398
2 parents 5fcfbb5 + dbe7a05 commit 9e82f9d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2018, Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2019, Oracle and/or its affiliates.
33
* Copyright (c) 2014, Regents of the University of California
44
*
55
* All rights reserved.
@@ -54,7 +54,7 @@ public static KeywordArgumentsNode create(ExpressionNode[] arguments, Expression
5454

5555
public abstract PKeyword[] execute(VirtualFrame frame);
5656

57-
@Specialization(guards = "starargs.length == cachedLen", limit = "getVariableArgumentInlineCacheLimit()")
57+
@Specialization(guards = {"starargs.length == cachedLen", "starargs.length < 32"}, limit = "getVariableArgumentInlineCacheLimit()")
5858
@ExplodeLoop
5959
PKeyword[] makeKeywords(VirtualFrame frame, PKeyword[] starargs,
6060
@Cached("starargs.length") int cachedLen) {
@@ -83,6 +83,7 @@ PKeyword[] makeKeywords(VirtualFrame frame, PKeyword[] starargs,
8383
}
8484

8585
@Specialization(replaces = "makeKeywords")
86+
@ExplodeLoop
8687
PKeyword[] makeKeywordsUncached(VirtualFrame frame, PKeyword[] starargs) {
8788
int length = arguments.length;
8889
CompilerAsserts.partialEvaluationConstant(length);
@@ -97,14 +98,20 @@ PKeyword[] makeKeywordsUncached(VirtualFrame frame, PKeyword[] starargs) {
9798
}
9899
}
99100

100-
for (int i = 0; i < starargs.length; i++) {
101-
keywords[arguments.length + i] = starargs[i];
102-
}
101+
copyStarargs(keywords, starargs);
103102

104103
if (reshape > 0) {
105104
return compactNode.execute(keywords, reshape);
106105
} else {
107106
return keywords;
108107
}
109108
}
109+
110+
private void copyStarargs(PKeyword[] keywords, PKeyword[] starargs) {
111+
// This loop has deliberately been moved out such that it won't be exploded since the length
112+
// of iterations is not constant.
113+
for (int i = 0; i < starargs.length; i++) {
114+
keywords[arguments.length + i] = starargs[i];
115+
}
116+
}
110117
}

0 commit comments

Comments
 (0)