Skip to content
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
43740f7
Add `Py_JIT_ENABLED` variable to `pyconfig.h`
Eclips4 Oct 31, 2024
65e6cfa
Changes for Windows build
Eclips4 Oct 31, 2024
718b21e
fix typo
Eclips4 Oct 31, 2024
f4f1748
Another changes for Windows build
Eclips4 Oct 31, 2024
20d51dc
Update _sysconfig.c
Eclips4 Oct 31, 2024
a3e6dda
Don't set Py_JIT_ENABLED to 1 if --enable-experimental-jit=no
Eclips4 Oct 31, 2024
40c001c
Fixes for Windows build..
Eclips4 Oct 31, 2024
81994a9
Set Py_JIT_ENABLED to 2 insetad of 'interpreter'
Eclips4 Oct 31, 2024
1618433
PyLong_FromInt -> PyLong_FromLong
Eclips4 Oct 31, 2024
1773d9e
Fix typo in pyconfigs
Eclips4 Oct 31, 2024
9a50db7
Add a NEWS entry
Eclips4 Oct 31, 2024
4b4e212
Update documentation
Eclips4 Oct 31, 2024
19ddff2
Fix typo
Eclips4 Oct 31, 2024
91b7a78
Move NEWS entry
Eclips4 Oct 31, 2024
e79e0df
Fix typo in path
Eclips4 Oct 31, 2024
759321b
Fix doc formatting
Eclips4 Oct 31, 2024
49e4fdc
Fix configure
Eclips4 Oct 31, 2024
169831e
Revert previous changes
Eclips4 Nov 5, 2024
c83ea49
Revert other part of previous changes
Eclips4 Nov 5, 2024
1dec18a
Merge branch 'main' into add-py-jit
Eclips4 Nov 9, 2024
02d1f60
Add ``sys._jit_enabled``
Eclips4 Nov 10, 2024
a9c5b41
Add a ``NEWS`` entry
Eclips4 Nov 10, 2024
5423c71
Fix typo
Eclips4 Nov 10, 2024
49336ab
Apply suggestions from code review
Eclips4 Nov 10, 2024
67123ee
Add documentation for sys._jit_enabled and what's new entry.
Eclips4 Nov 10, 2024
4ddcd62
``availability`` only works for platforms :(
Eclips4 Nov 10, 2024
aa8f5bb
Apply suggestions from code review
Eclips4 Nov 10, 2024
0b5bce8
Align indentation
Eclips4 Nov 10, 2024
0ffcd9f
Remove unnecessary check
Eclips4 Nov 10, 2024
b6c097b
Update Python/pylifecycle.c
Eclips4 Nov 10, 2024
b4dc9dc
Update Python/sysmodule.c
Eclips4 Nov 11, 2024
46a4a7f
Fix reference leak in error path
Eclips4 Nov 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,25 @@ General Options

.. versionadded:: 3.13

.. option:: --enable-experimental-jit

Enables :ref:`JIT compiler <whatsnew313-jit-compiler>`.

Possible values:
* ``no`` - build interpreter without JIT.
* ``yes`` - build interpreter with JIT.
* ``yes-off`` - build interpreter with JIT but disable it by default.
* ``interpreter`` - build interpreter without JIT, but with enabled tier 2 interpreter.

Defines the ``Py_JIT_ENABLED`` macro, with possible values:
* ``0`` - interpreter was built without JIT.
* ``1`` - interpreter was built with JIT.
* ``2`` - interpreter was built without JIT, but with enabled tier 2 interpreter.

.. versionadded:: next

.. versionadded:: 3.13

.. option:: PKG_CONFIG

Path to ``pkg-config`` utility.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add a ``Py_JIT_ENABLED`` variable to ``pyconfig.h`` to help determine if CPython was built
with JIT or not.
15 changes: 14 additions & 1 deletion Modules/_sysconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,20 @@ _sysconfig_config_vars_impl(PyObject *module)
Py_DECREF(config);
return NULL;
}

#ifdef Py_JIT_ENABLED
PyObject *py_jit_enabled;
if (Py_JIT_ENABLED == 1) {
py_jit_enabled = _PyLong_GetOne();
} else {
py_jit_enabled = PyLong_FromLong(2);
}
#else
PyObject *py_jit_enabled = _PyLong_GetZero();
#endif
if (PyDict_SetItemString(config, "Py_JIT_ENABLED", py_jit_enabled) < 0) {
Py_DECREF(config);
return NULL;
}
return config;
}

Expand Down
6 changes: 6 additions & 0 deletions PC/pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ WIN32 is still required for the locale module.
/* #define Py_GIL_DISABLED 1 */
#endif

/* Define to 1 if you want to build an interpreter with JIT, or define to 2 if
you want to enable tier 2 interpreter */
#ifndef Py_JIT_ENABLED
/* #define Py_JIT_ENABLED 1 */
#endif

/* Compiler specific defines */

/* ------------------------------------------------------------------------*/
Expand Down
6 changes: 6 additions & 0 deletions PCbuild/_freeze_module.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,12 @@
<PropertyGroup Condition="$(DisableGil) == 'true'">
<PyConfigHText>$(PyConfigHText.Replace('#undef Py_GIL_DISABLED', '#define Py_GIL_DISABLED 1'))</PyConfigHText>
</PropertyGroup>
<PropertyGroup Condition="$(UseJIT) == 'true'">
<PyConfigHText>$(PyConfigHText.Replace('/* #define Py_JIT_ENABLED 1 */', '#define Py_JIT_ENABLED 1'))</PyConfigHText>
</PropertyGroup>
<PropertyGroup Condition="$(UseTIER2) == '4' Or $(UseTIER2) == '6'">
<PyConfigHText>$(PyConfigHText.Replace('/* #define Py_JIT_ENABLED 1 */', '#define Py_JIT_ENABLED 2'))</PyConfigHText>
</PropertyGroup>
<Message Text="Updating pyconfig.h" Condition="$(PyConfigHText.TrimEnd()) != $(OldPyConfigH.TrimEnd())" />
<WriteLinesToFile File="$(IntDir)pyconfig.h"
Lines="$(PyConfigHText)"
Expand Down
6 changes: 6 additions & 0 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,12 @@
<PropertyGroup Condition="$(DisableGil) == 'true'">
<PyConfigHText>$(PyConfigHText.Replace('/* #define Py_GIL_DISABLED 1 */', '#define Py_GIL_DISABLED 1'))</PyConfigHText>
</PropertyGroup>
<PropertyGroup Condition="$(UseJIT) == 'true'">
<PyConfigHText>$(PyConfigHText.Replace('/* #define Py_JIT_ENABLED 1 */', '#define Py_JIT_ENABLED 1'))</PyConfigHText>
</PropertyGroup>
<PropertyGroup Condition="$(UseTIER2) == '4' Or $(UseTIER2) == '6'">
<PyConfigHText>$(PyConfigHText.Replace('/* #define Py_JIT_ENABLED 1 */', '#define Py_JIT_ENABLED 2'))</PyConfigHText>
</PropertyGroup>
<Message Text="Updating pyconfig.h" Condition="$(PyConfigHText.TrimEnd()) != $(OldPyConfigH.TrimEnd())" />
<WriteLinesToFile File="$(IntDir)pyconfig.h"
Lines="$(PyConfigHText)"
Expand Down
37 changes: 32 additions & 5 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 24 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1820,11 +1820,30 @@ AC_ARG_ENABLE([experimental-jit],
[],
[enable_experimental_jit=no])
case $enable_experimental_jit in
no) jit_flags=""; tier2_flags="" ;;
yes) jit_flags="-D_Py_JIT"; tier2_flags="-D_Py_TIER2=1" ;;
yes-off) jit_flags="-D_Py_JIT"; tier2_flags="-D_Py_TIER2=3" ;;
interpreter) jit_flags=""; tier2_flags="-D_Py_TIER2=4" ;;
interpreter-off) jit_flags=""; tier2_flags="-D_Py_TIER2=6" ;; # Secret option
no)
jit_flags="";
tier2_flags="";
;;
yes)
jit_flags="-D_Py_JIT";
tier2_flags="-D_Py_TIER2=1";
AC_DEFINE([Py_JIT_ENABLED], [1], [Define to 1 if you want to build an interpreter with JIT, or define to 2 if you want to enable tier 2 interpreter])
;;
yes-off)
jit_flags="-D_Py_JIT";
tier2_flags="-D_Py_TIER2=3";
AC_DEFINE([Py_JIT_ENABLED], [1], [Define to 1 if you want to build an interpreter with JIT, or define to 2 if you want to enable tier 2 interpreter])
;;
interpreter)
jit_flags="";
tier2_flags="-D_Py_TIER2=4";
AC_DEFINE([Py_JIT_ENABLED], [2], [Define to 1 if you want to build an interpreter with JIT, or define to 2 if you want to enable tier 2 interpreter])
;;
interpreter-off)
jit_flags="";
tier2_flags="-D_Py_TIER2=6";
AC_DEFINE([Py_JIT_ENABLED], [2], [Define to 1 if you want to build an interpreter with JIT, or define to 2 if you want to enable tier 2 interpreter]) # Secret option
;;
*) AC_MSG_ERROR(
[invalid argument: --enable-experimental-jit=$enable_experimental_jit; expected no|yes|yes-off|interpreter]) ;;
esac
Expand Down
4 changes: 4 additions & 0 deletions pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,10 @@
/* Defined if _Complex C type is available. */
#undef Py_HAVE_C_COMPLEX

/* Define to 1 if you want to build an interpreter with JIT, or define to 2 if
you want to enable tier 2 interpreter */
#undef Py_JIT_ENABLED

/* Define if year with century should be normalized for strftime. */
#undef Py_NORMALIZE_CENTURY

Expand Down
Loading