gh-144991: Use runtime JIT threshold in _testinternalcapi (gh-145496) · python/cpython@8b54313

GitHub

Original file line numberDiff line numberDiff line change@@ -496,7 +496,7 @@ struct _py_func_state {

496496497497/* 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_TYPES201

499+#define_Py_MAX_MANAGED_STATIC_BUILTIN_TYPES202

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)

Original file line numberDiff line numberDiff line change@@ -2970,6 +2970,8 @@ static PyMethodDef module_functions[] = {

29702970staticint

29712971module_exec(PyObject*module)

29722972{

2973+PyInterpreterState*interp=PyInterpreterState_Get();

2974+29732975if (_PyTestInternalCapi_Init_Lock(module) <0) {

29742976return1;

29752977 }

@@ -3011,9 +3013,10 @@ module_exec(PyObject *module)

30113013return1;

30123014 }

301330153016+// + 1 more due to one loop spent on tracing.

3017+unsigned longthreshold=interp->opt_config.jump_backward_initial_value+2;

30143018if (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) {

30173020return1;

30183021 }

30193022