Skip to content

Commit 78f51e6

Browse files
committed
Fix: add missing ExplodeLoop.
1 parent 7bc1453 commit 78f51e6

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/FunctionDefinitionNode.java

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.oracle.graal.python.parser.ExecutionCellSlots;
3939
import com.oracle.truffle.api.RootCallTarget;
4040
import com.oracle.truffle.api.frame.VirtualFrame;
41+
import com.oracle.truffle.api.nodes.ExplodeLoop;
4142
import com.oracle.truffle.api.nodes.RootNode;
4243

4344
public class FunctionDefinitionNode extends ExpressionDefinitionNode {
@@ -67,22 +68,34 @@ public FunctionDefinitionNode(String functionName, String enclosingClassName, Ex
6768

6869
@Override
6970
public Object execute(VirtualFrame frame) {
70-
Object[] defaultValues = null;
71-
if (defaults != null) {
72-
defaultValues = new Object[defaults.length];
73-
for (int i = 0; i < defaults.length; i++) {
74-
defaultValues[i] = defaults[i].execute(frame);
75-
}
76-
}
71+
Object[] defaultValues = computeDefaultValues(frame);
72+
PKeyword[] kwDefaultValues = computeKwDefaultValues(frame);
73+
PCell[] closure = getClosureFromGeneratorOrFunctionLocals(frame);
74+
return withDocString(frame, factory().createFunction(functionName, enclosingClassName, callTarget, PArguments.getGlobals(frame), defaultValues, kwDefaultValues, closure));
75+
}
76+
77+
@ExplodeLoop
78+
private PKeyword[] computeKwDefaultValues(VirtualFrame frame) {
7779
PKeyword[] kwDefaultValues = null;
7880
if (kwDefaults != null) {
7981
kwDefaultValues = new PKeyword[kwDefaults.length];
8082
for (int i = 0; i < kwDefaults.length; i++) {
8183
kwDefaultValues[i] = new PKeyword(kwDefaults[i].name, kwDefaults[i].execute(frame));
8284
}
8385
}
84-
PCell[] closure = getClosureFromGeneratorOrFunctionLocals(frame);
85-
return withDocString(frame, factory().createFunction(functionName, enclosingClassName, callTarget, PArguments.getGlobals(frame), defaultValues, kwDefaultValues, closure));
86+
return kwDefaultValues;
87+
}
88+
89+
@ExplodeLoop
90+
private Object[] computeDefaultValues(VirtualFrame frame) {
91+
Object[] defaultValues = null;
92+
if (defaults != null) {
93+
defaultValues = new Object[defaults.length];
94+
for (int i = 0; i < defaults.length; i++) {
95+
defaultValues[i] = defaults[i].execute(frame);
96+
}
97+
}
98+
return defaultValues;
8699
}
87100

88101
protected final <T extends PFunction> T withDocString(VirtualFrame frame, T func) {

0 commit comments

Comments
 (0)