Skip to content

Commit 9f333d1

Browse files
committed
Build time option to override uncached interpreter limit
1 parent 4f051a2 commit 9f333d1

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,9 @@ public void setMetadata(BytecodeDSLCodeUnit co, ParserCallbacksImpl parserErrorC
441441
}
442442
instrumentationDataIndex = co.instrumentationDataIndex;
443443
yieldFromGeneratorIndex = co.yieldFromGeneratorIndex;
444+
if (PythonOptions.UNCACHED_BYTECODE_DSL_INTERPRETER_LIMIT != -1) {
445+
getBytecodeNode().setUncachedThreshold(PythonOptions.UNCACHED_BYTECODE_DSL_INTERPRETER_LIMIT);
446+
}
444447
}
445448

446449
@Override

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonOptions.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ public final class PythonOptions {
8888
* bytecode interpreter.
8989
*/
9090
public static final boolean ENABLE_BYTECODE_DSL_INTERPRETER;
91+
public static final int UNCACHED_BYTECODE_DSL_INTERPRETER_LIMIT;
92+
private static final OptionType<TruffleString> TS_OPTION_TYPE = new OptionType<>("graal.python.TruffleString", PythonUtils::toTruffleStringUncached);
93+
9194
static {
9295
String prop = System.getProperty("python.EnableBytecodeDSLInterpreter");
9396
if (prop != null) {
@@ -104,9 +107,18 @@ public final class PythonOptions {
104107
} else {
105108
ENABLE_BYTECODE_DSL_INTERPRETER = true;
106109
}
107-
}
108110

109-
private static final OptionType<TruffleString> TS_OPTION_TYPE = new OptionType<>("graal.python.TruffleString", PythonUtils::toTruffleStringUncached);
111+
if (Boolean.getBoolean("python.ForceUncachedInterpreter")) {
112+
UNCACHED_BYTECODE_DSL_INTERPRETER_LIMIT = Integer.MIN_VALUE;
113+
} else {
114+
String uncachedLimitStr = System.getProperty("python.UncachedInterpreterLimit");
115+
if (uncachedLimitStr != null) {
116+
UNCACHED_BYTECODE_DSL_INTERPRETER_LIMIT = Integer.parseInt(uncachedLimitStr);
117+
} else {
118+
UNCACHED_BYTECODE_DSL_INTERPRETER_LIMIT = -1;
119+
}
120+
}
121+
}
110122

111123
private PythonOptions() {
112124
// no instances

mx.graalpython/mx_graalpython.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,10 @@ def github_ci_build_args():
284284
def libpythonvm_build_args():
285285
build_args = bytecode_dsl_build_args()
286286

287+
if limit := os.environ.get('GRAALPY_UncachedInterpreterLimit'):
288+
mx.log(f"Uncached interpreter limit explicitly set to {limit}")
289+
build_args += [f'-Dpython.UncachedInterpreterLimit={limit}']
290+
287291
if os.environ.get("GITHUB_CI"):
288292
build_args += github_ci_build_args()
289293

0 commit comments

Comments
 (0)