8000 Step 1: replace 'python -Xuops' with 'configure --enable-experimental… · python/cpython@1eb8fea · GitHub
[go: up one dir, main page]

Skip to content

Commit 1eb8fea

Browse files
committed
Step 1: replace 'python -Xuops' with 'configure --enable-experimental-tier2'
1 parent b43c7e1 commit 1eb8fea

File tree

5 files changed

+47
-18
lines changed

5 files changed

+47
-18
lines changed

Doc/whatsnew/3.13.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,9 +901,8 @@ The internal architecture is roughly as follows.
901901

902902
* There is a Tier 2 interpreter, but it is mostly intended for debugging
903903
the earlier stages of the optimization pipeline. If the JIT is not
904-
enabled, the Tier 2 interpreter can be invoked by passing Python the
905-
``-X uops`` option or by setting the ``PYTHON_UOPS`` environment
906-
variable to ``1``.
904+
enabled, the Tier 2 interpreter can be enabled by configuring Python
905+
with the ``--enable-experimental-tier2`` option.
907906

908907
* When the ``--enable-experimental-jit`` option is used, the optimized
909908
Tier 2 IR is translated to machine code, which is then executed.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Change how to use the tier 2 interpreter. Instead of running Python with
2+
``-X uops`` or setting the environment variable ``PYTHON_UOPS=1``, this
3+
choice is now made at build time by configuring with
4+
``--enable-experimental-tier2``.

Python/pylifecycle.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,30 +1262,19 @@ init_interp_main(PyThreadState *tstate)
12621262
}
12631263

12641264
// Turn on experimental tier 2 (uops-based) optimizer
1265+
// This is also needed when the JIT is enabled
1266+
#if defined(_Py_JIT) || defined(_Py_TIER2)
12651267
if (is_main_interp) {
1266-
#ifndef _Py_JIT
1267-
// No JIT, maybe use the tier two interpreter:
1268-
char *envvar = Py_GETENV("PYTHON_UOPS");
1269-
int enabled = envvar != NULL && *envvar > '0';
1270-
if (_Py_get_xoption(&config->xoptions, L"uops") != NULL) {
1271-
enabled = 1;
1272-
}
1273-
if (enabled) {
1274-
#else
1275-
// Always enable tier two for JIT builds (ignoring the environment
1276-
// variable and command-line option above):
1277-
if (true) {
1278-
#endif
12791268
PyObject *opt = PyUnstable_Optimizer_NewUOpOptimizer();
12801269
if (opt == NULL) {
12811270
return _PyStatus_ERR("can't initialize optimizer");
12821271
}
12831272
if (PyUnstable_SetOptimizer((_PyOptimizerObject *)opt)) {
1284-
return _PyStatus_ERR("can't initialize optimizer");
1273+
return _PyStatus_ERR("can't install optimizer");
12851274
}
12861275
Py_DECREF(opt);
1287-
}
12881276
}
1277+
#endif
12891278

12901279
if (!is_main_interp) {
12911280
// The main interpreter is handled in Py_Main(), for now.

configure

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,6 +1784,19 @@ AC_SUBST([REGEN_JIT_COMMAND])
17841784
AC_SUBST([JIT_STENCILS_H])
17851785
AC_MSG_RESULT([$enable_experimental_jit])
17861786

1787+
# Check for --enable-experimental-tier2:
1788+
AC_MSG_CHECKING([for --enable-experimental-tier2])
1789+
AC_ARG_ENABLE([experimental-tier2],
1790+
[AS_HELP_STRING([--enable-experimental-tier2],
1791+
[use the experimental tier 2 interpreter (default is no)])],
1792+
[],
1793+
[enable_experimental_tier2=no])
1794+
AS_VAR_IF([enable_experimental_tier2],
1795+
[no],
1796+
[],
1797+
[AS_VAR_APPEND([CFLAGS_NODIST], [" -D_Py_TIER2"])])
1798+
AC_MSG_RESULT([$enable_experimental_tier2])
1799+
17871800
# Enable optimization flags
17881801
AC_SUBST([DEF_MAKE_ALL_RULE])
17891802
AC_SUBST([DEF_MAKE_RULE])

0 commit comments

Comments
 (0)
0