Skip to content

Commit dc699df

Browse files
committed
gh-141504: Move PYTHON_UOPS_OPTIMIZE to policy object
1 parent a126893 commit dc699df

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

Include/internal/pycore_interp_structs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ typedef struct _PyOptimizationConfig {
411411

412412
// Optimization flags
413413
bool specialization_enabled;
414+
bool uops_optimize_enabled;
414415
} _PyOptimizationConfig;
415416

416417
struct

Python/optimizer.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,11 +1514,7 @@ uop_optimize(
15141514
_PyBloomFilter *dependencies = &_tstate->jit_tracer_state->prev_state.dependencies;
15151515
_PyUOpInstruction *buffer = _tstate->jit_tracer_state->code_buffer;
15161516
OPT_STAT_INC(attempts);
1517-
char *env_var = Py_GETENV("PYTHON_UOPS_OPTIMIZE");
1518-
bool is_noopt = true;
1519-
if (env_var == NULL || *env_var == '\0' || *env_var > '0') {
1520-
is_noopt = false;
1521-
}
1517+
bool is_noopt = !tstate->interp->opt_config.uops_optimize_enabled;
15221518
int curr_stackentries = _tstate->jit_tracer_state->initial_state.stack_depth;
15231519
int length = _tstate->jit_tracer_state->prev_state.code_curr_size;
15241520
if (length <= CODE_SIZE_NO_PROGRESS) {

Python/pystate.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ init_interpreter(PyInterpreterState *interp,
619619
SIDE_EXIT_INITIAL_BACKOFF, 0, MAX_BACKOFF);
620620

621621
interp->opt_config.specialization_enabled = !is_env_enabled("PYTHON_SPECIALIZATION_OFF");
622+
interp->opt_config.uops_optimize_enabled = !is_env_enabled("PYTHON_UOPS_OPTIMIZE_OFF");
622623
if (interp != &runtime->_main_interpreter) {
623624
/* Fix the self-referential, statically initialized fields. */
624625
interp->dtoa = (struct _dtoa_state)_dtoa_state_INIT(interp);

0 commit comments

Comments
 (0)