Skip to content

Commit 8daf0b2

Browse files
committed
Cache if max calelr size exceeded.
1 parent a4c6c46 commit 8daf0b2

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/CallSpecialMethodNode.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
@ReportPolymorphism
7171
abstract class CallSpecialMethodNode extends Node {
7272

73+
/** for interpreter performance: cache if we exceeded the max caller size */
74+
private boolean maxSizeExceeded = false;
75+
7376
/**
7477
* Returns a new instanceof the builtin if it's a subclass of the given class, and null
7578
* otherwise.
@@ -86,11 +89,18 @@ private <T extends PythonBuiltinBaseNode> T getBuiltin(PBuiltinFunction func, Cl
8689

8790
private boolean callerExceedsMaxSize() {
8891
CompilerAsserts.neverPartOfCompilation();
89-
int n = NodeUtil.countNodes(getRootNode());
90-
// nb: option 'BuiltinsInliningMaxCallerSize' is defined as a compatible option, i.e., ASTs
91-
// will only we shared between contexts that have the same value for this option.
92-
int maxSize = PythonOptions.getOption(lookupContextReference(PythonLanguage.class).get(), PythonOptions.BuiltinsInliningMaxCallerSize);
93-
return n >= maxSize;
92+
if(!maxSizeExceeded) {
93+
int n = NodeUtil.countNodes(getRootNode());
94+
// nb: option 'BuiltinsInliningMaxCallerSize' is defined as a compatible option, i.e., ASTs
95+
// will only we shared between contexts that have the same value for this option.
96+
int maxSize = PythonOptions.getOption(lookupContextReference(PythonLanguage.class).get(), PythonOptions.BuiltinsInliningMaxCallerSize);
97+
if(n >= maxSize) {
98+
maxSizeExceeded = true;
99+
return true;
100+
}
101+
return false;
102+
}
103+
return true;
94104
}
95105

96106
protected Assumption singleContextAssumption() {

0 commit comments

Comments
 (0)