Skip to content

Commit 8b54313

Browse files
authored
gh-144991: Use runtime JIT threshold in _testinternalcapi (gh-145496)
1 parent 72b3e37 commit 8b54313

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Include/internal/pycore_interp_structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ struct _py_func_state {
496496

497497
/* For now we hard-code this to a value for which we are confident
498498
all the static builtin types will fit (for all builds). */
499-
#define _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES 201
499+
#define _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES 202
500500
#define _Py_MAX_MANAGED_STATIC_EXT_TYPES 10
501501
#define _Py_MAX_MANAGED_STATIC_TYPES \
502502
(_Py_MAX_MANAGED_STATIC_BUILTIN_TYPES + _Py_MAX_MANAGED_STATIC_EXT_TYPES)

Modules/_testinternalcapi.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,6 +2970,8 @@ static PyMethodDef module_functions[] = {
29702970
static int
29712971
module_exec(PyObject *module)
29722972
{
2973+
PyInterpreterState *interp = PyInterpreterState_Get();
2974+
29732975
if (_PyTestInternalCapi_Init_Lock(module) < 0) {
29742976
return 1;
29752977
}
@@ -3011,9 +3013,10 @@ module_exec(PyObject *module)
30113013
return 1;
30123014
}
30133015

3016+
// + 1 more due to one loop spent on tracing.
3017+
unsigned long threshold = interp->opt_config.jump_backward_initial_value + 2;
30143018
if (PyModule_Add(module, "TIER2_THRESHOLD",
3015-
// + 1 more due to one loop spent on tracing.
3016-
PyLong_FromLong(JUMP_BACKWARD_INITIAL_VALUE + 2)) < 0) {
3019+
PyLong_FromUnsignedLong(threshold)) < 0) {
30173020
return 1;
30183021
}
30193022

0 commit comments

Comments
 (0)