Skip to content

Commit d33037d

Browse files
committed
Merge branch 'main' into pythongh-101112
2 parents 406cf4d + fda7445 commit d33037d

File tree

180 files changed

+6621
-2116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+6621
-2116
lines changed

.github/CODEOWNERS

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ configure* @erlend-aasland @corona10
2121
**/*context* @1st1
2222
**/*genobject* @markshannon
2323
**/*hamt* @1st1
24+
**/*jit* @brandtbucher
2425
Objects/set* @rhettinger
2526
Objects/dict* @methane @markshannon
2627
Objects/typevarobject.c @JelleZijlstra
@@ -37,14 +38,37 @@ Python/ast_opt.c @isidentical
3738
Python/bytecodes.c @markshannon @gvanrossum
3839
Python/optimizer*.c @markshannon @gvanrossum
3940
Lib/test/test_patma.py @brandtbucher
40-
Lib/test/test_peepholer.py @brandtbucher
4141
Lib/test/test_type_*.py @JelleZijlstra
4242
Lib/test/test_capi/test_misc.py @markshannon @gvanrossum
4343
Tools/c-analyzer/ @ericsnowcurrently
4444

4545
# dbm
4646
**/*dbm* @corona10 @erlend-aasland @serhiy-storchaka
4747

48+
# runtime state/lifecycle
49+
**/*pylifecycle* @ericsnowcurrently
50+
**/*pystate* @ericsnowcurrently
51+
**/*preconfig* @ericsnowcurrently
52+
**/*initconfig* @ericsnowcurrently
53+
**/*pathconfig* @ericsnowcurrently
54+
**/*sysmodule* @ericsnowcurrently
55+
**/*bltinmodule* @ericsnowcurrently
56+
**/*gil* @ericsnowcurrently
57+
Include/internal/pycore_runtime.h @ericsnowcurrently
58+
Include/internal/pycore_interp.h @ericsnowcurrently
59+
Include/internal/pycore_tstate.h @ericsnowcurrently
60+
Include/internal/pycore_*_state.h @ericsnowcurrently
61+
Include/internal/pycore_*_init.h @ericsnowcurrently
62+
Include/internal/pycore_atexit.h @ericsnowcurrently
63+
Include/internal/pycore_freelist.h @ericsnowcurrently
64+
Include/internal/pycore_global_objects.h @ericsnowcurrently
65+
Include/internal/pycore_obmalloc.h @ericsnowcurrently
66+
Include/internal/pycore_pymem.h @ericsnowcurrently
67+
Modules/main.c @ericsnowcurrently
68+
Programs/_bootstrap_python.c @ericsnowcurrently
69+
Programs/python.c @ericsnowcurrently
70+
Tools/build/generate_global_objects.py @ericsnowcurrently
71+
4872
# Exceptions
4973
Lib/traceback.py @iritkatriel
5074
Lib/test/test_except*.py @iritkatriel
@@ -79,7 +103,20 @@ Modules/_hacl/** @gpshead
79103
# Import (including importlib).
80104
**/*import* @brettcannon @ericsnowcurrently @ncoghlan @warsaw
81105
/Python/import.c @kumaraditya303
82-
**/*importlib/resources/* @jaraco @warsaw @FFY00
106+
Python/dynload_*.c @ericsnowcurrently
107+
**/*freeze* @ericsnowcurrently
108+
**/*frozen* @ericsnowcurrently
109+
**/*modsupport* @ericsnowcurrently
110+
**/*modulefinder* @ericsnowcurrently
111+
**/*moduleobject* @ericsnowcurrently
112+
**/*multiphase* @ericsnowcurrently
113+
**/*pkgutil* @ericsnowcurrently
114+
**/*pythonrun* @ericsnowcurrently
115+
**/*runpy* @ericsnowcurrently
116+
**/*singlephase* @ericsnowcurrently
117+
Lib/test/test_module/ @ericsnowcurrently
118+
Doc/c-api/module.rst @ericsnowcurrently
119+
**/*importlib/resources/* @jaraco @warsaw @FFY00
83120
**/importlib/metadata/* @jaraco @warsaw
84121

85122
# Dates and times
@@ -198,6 +235,8 @@ Doc/c-api/stable.rst @encukou
198235
Doc/howto/clinic.rst @erlend-aasland
199236

200237
# Subinterpreters
238+
**/*interpreteridobject.* @ericsnowcurrently
239+
**/*crossinterp* @ericsnowcurrently
201240
Lib/test/support/interpreters/ @ericsnowcurrently
202241
Modules/_xx*interp*module.c @ericsnowcurrently
203242
Lib/test/test_interpreters/ @ericsnowcurrently

.github/workflows/jit.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: JIT
2+
on:
3+
pull_request:
4+
paths: '**jit**'
5+
push:
6+
paths: '**jit**'
7+
workflow_dispatch:
8+
jobs:
9+
jit:
10+
name: ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }})
11+
runs-on: ${{ matrix.runner }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
target:
16+
- i686-pc-windows-msvc/msvc
17+
- x86_64-pc-windows-msvc/msvc
18+
- x86_64-apple-darwin/clang
19+
- x86_64-unknown-linux-gnu/gcc
20+
- x86_64-unknown-linux-gnu/clang
21+
- aarch64-unknown-linux-gnu/gcc
22+
- aarch64-unknown-linux-gnu/clang
23+
debug:
24+
- true
25+
- false
26+
llvm:
27+
- 16
28+
include:
29+
- target: i686-pc-windows-msvc/msvc
30+
architecture: Win32
31+
runner: windows-latest
32+
compiler: msvc
33+
- target: x86_64-pc-windows-msvc/msvc
34+
architecture: x64
35+
runner: windows-latest
36+
compiler: msvc
37+
- target: x86_64-apple-darwin/clang
38+
architecture: x86_64
39+
runner: macos-latest
40+
compiler: clang
41+
exclude: test_embed
42+
- target: x86_64-unknown-linux-gnu/gcc
43+
architecture: x86_64
44+
runner: ubuntu-latest
45+
compiler: gcc
46+
- target: x86_64-unknown-linux-gnu/clang
47+
architecture: x86_64
48+
runner: ubuntu-latest
49+
compiler: clang
50+
- target: aarch64-unknown-linux-gnu/gcc
51+
architecture: aarch64
52+
runner: ubuntu-latest
53+
compiler: gcc
54+
# These fail because of emulation, not because of the JIT:
55+
exclude: test_unix_events test_init test_process_pool test_shutdown test_multiprocessing_fork test_cmd_line test_faulthandler test_os test_perf_profiler test_posix test_signal test_socket test_subprocess test_threading test_venv
56+
- target: aarch64-unknown-linux-gnu/clang
57+
architecture: aarch64
58+
runner: ubuntu-latest
59+
compiler: clang
60+
# These fail because of emulation, not because of the JIT:
61+
exclude: test_unix_events test_init test_process_pool test_shutdown test_multiprocessing_fork test_cmd_line test_faulthandler test_os test_perf_profiler test_posix test_signal test_socket test_subprocess test_threading test_venv
62+
env:
63+
CC: ${{ matrix.compiler }}
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: actions/setup-python@v5
67+
with:
68+
python-version: '3.11'
69+
70+
- name: Windows
71+
if: runner.os == 'Windows'
72+
run: |
73+
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
74+
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '--pgo' }} -p ${{ matrix.architecture }}
75+
./PCbuild/rt.bat ${{ matrix.debug && '-d' }} -p ${{ matrix.architecture }} -q --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
76+
77+
- name: macOS
78+
if: runner.os == 'macOS'
79+
run: |
80+
brew install llvm@${{ matrix.llvm }}
81+
export SDKROOT="$(xcrun --show-sdk-path)"
82+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
83+
make all --jobs 3
84+
./python.exe -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
85+
86+
- name: Native Linux
87+
if: runner.os == 'Linux' && matrix.architecture == 'x86_64'
88+
run: |
89+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
90+
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
91+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
92+
make all --jobs 4
93+
./python -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
94+
- name: Emulated Linux
95+
if: runner.os == 'Linux' && matrix.architecture != 'x86_64'
96+
run: |
97+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
98+
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
99+
./configure --prefix="$(pwd)/../build"
100+
make install --jobs 4
101+
make clean --jobs 4
102+
export HOST=${{ matrix.architecture }}-linux-gnu
103+
sudo apt install --yes "gcc-$HOST" qemu-user
104+
${{ !matrix.debug && matrix.compiler == 'clang' && './configure --enable-optimizations' || '' }}
105+
${{ !matrix.debug && matrix.compiler == 'clang' && 'make profile-run-stamp --jobs 4' || '' }}
106+
export CC="${{ matrix.compiler == 'clang' && 'clang --target=$HOST' || '$HOST-gcc' }}"
107+
export CPP="$CC --preprocess"
108+
export HOSTRUNNER=qemu-${{ matrix.architecture }}
109+
export QEMU_LD_PREFIX="/usr/$HOST"
110+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }} --build=x86_64-linux-gnu --host="$HOST" --with-build-python=../build/bin/python3 --with-pkg-config=no ac_cv_buggy_getaddrinfo=no ac_cv_file__dev_ptc=no ac_cv_file__dev_ptmx=yes
111+
make all --jobs 4
112+
./python -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3

.github/workflows/mypy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- "Tools/build/generate_sbom.py"
1313
- "Tools/cases_generator/**"
1414
- "Tools/clinic/**"
15+
- "Tools/jit/**"
1516
- "Tools/peg_generator/**"
1617
- "Tools/requirements-dev.txt"
1718
- "Tools/wasm/**"
@@ -38,6 +39,7 @@ jobs:
3839
"Tools/build/",
3940
"Tools/cases_generator",
4041
"Tools/clinic",
42+
"Tools/jit",
4143
"Tools/peg_generator",
4244
"Tools/wasm",
4345
]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ Tools/unicode/data/
126126
# hendrikmuhs/ccache-action@v1
127127
/.ccache
128128
/cross-build/
129+
/jit_stencils.h
129130
/platform
130131
/profile-clean-stamp
131132
/profile-run-stamp

Doc/c-api/conversion.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,42 @@ The return value (*rv*) for these functions should be interpreted as follows:
4848
4949
The following functions provide locale-independent string to number conversions.
5050
51+
.. c:function:: unsigned long PyOS_strtoul(const char *str, char **ptr, int base)
52+
53+
Convert the initial part of the string in ``str`` to an :c:expr:`unsigned
54+
long` value according to the given ``base``, which must be between ``2`` and
55+
``36`` inclusive, or be the special value ``0``.
56+
57+
Leading white space and case of characters are ignored. If ``base`` is zero
58+
it looks for a leading ``0b``, ``0o`` or ``0x`` to tell which base. If
59+
these are absent it defaults to ``10``. Base must be 0 or between 2 and 36
60+
(inclusive). If ``ptr`` is non-``NULL`` it will contain a pointer to the
61+
end of the scan.
62+
63+
If the converted value falls out of range of corresponding return type,
64+
range error occurs (:c:data:`errno` is set to :c:macro:`!ERANGE`) and
65+
:c:macro:`!ULONG_MAX` is returned. If no conversion can be performed, ``0``
66+
is returned.
67+
68+
See also the Unix man page :manpage:`strtoul(3)`.
69+
70+
.. versionadded:: 3.2
71+
72+
73+
.. c:function:: long PyOS_strtol(const char *str, char **ptr, int base)
74+
75+
Convert the initial part of the string in ``str`` to an :c:expr:`long` value
76+
according to the given ``base``, which must be between ``2`` and ``36``
77+
inclusive, or be the special value ``0``.
78+
79+
Same as :c:func:`PyOS_strtoul`, but return a :c:expr:`long` value instead
80+
and :c:macro:`LONG_MAX` on overflows.
81+
82+
See also the Unix man page :manpage:`strtol(3)`.
83+
84+
.. versionadded:: 3.2
85+
86+
5187
.. c:function:: double PyOS_string_to_double(const char *s, char **endptr, PyObject *overflow_exception)
5288
5389
Convert a string ``s`` to a :c:expr:`double`, raising a Python

Doc/c-api/file.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,14 @@ the :mod:`io` APIs instead.
6565
Overrides the normal behavior of :func:`io.open_code` to pass its parameter
6666
through the provided handler.
6767
68-
The handler is a function of type :c:expr:`PyObject *(\*)(PyObject *path,
69-
void *userData)`, where *path* is guaranteed to be :c:type:`PyUnicodeObject`.
68+
The *handler* is a function of type:
69+
70+
.. c:namespace:: NULL
71+
.. c:type:: PyObject * (*Py_OpenCodeHookFunction)(PyObject *, void *)
72+
73+
Equivalent of :c:expr:`PyObject *(\*)(PyObject *path,
74+
void *userData)`, where *path* is guaranteed to be
75+
:c:type:`PyUnicodeObject`.
7076
7177
The *userData* pointer is passed into the hook function. Since hook
7278
functions may be called from different runtimes, this pointer should not

Doc/c-api/memoryview.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ any other object.
2020
read/write, otherwise it may be either read-only or read/write at the
2121
discretion of the exporter.
2222
23+
24+
.. c:macro:: PyBUF_READ
25+
26+
Flag to request a readonly buffer.
27+
28+
29+
.. c:macro:: PyBUF_WRITE
30+
31+
Flag to request a writable buffer.
32+
33+
2334
.. c:function:: PyObject *PyMemoryView_FromMemory(char *mem, Py_ssize_t size, int flags)
2435
2536
Create a memoryview object using *mem* as the underlying buffer.
@@ -41,6 +52,8 @@ any other object.
4152
original memory. Otherwise, a copy is made and the memoryview points to a
4253
new bytes object.
4354
55+
*buffertype* can be one of :c:macro:`PyBUF_READ` or :c:macro:`PyBUF_WRITE`.
56+
4457
4558
.. c:function:: int PyMemoryView_Check(PyObject *obj)
4659

Doc/c-api/object.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ Object Protocol
1919
to NotImplemented and return it).
2020

2121

22+
.. c:macro:: Py_PRINT_RAW
23+
24+
Flag to be used with multiple functions that print the object (like
25+
:c:func:`PyObject_Print` and :c:func:`PyFile_WriteObject`).
26+
If passed, these function would use the :func:`str` of the object
27+
instead of the :func:`repr`.
28+
29+
2230
.. c:function:: int PyObject_Print(PyObject *o, FILE *fp, int flags)
2331
2432
Print an object *o*, on file *fp*. Returns ``-1`` on error. The flags argument
@@ -221,12 +229,8 @@ Object Protocol
221229
.. c:function:: int PyObject_RichCompareBool(PyObject *o1, PyObject *o2, int opid)
222230
223231
Compare the values of *o1* and *o2* using the operation specified by *opid*,
224-
which must be one of :c:macro:`Py_LT`, :c:macro:`Py_LE`, :c:macro:`Py_EQ`,
225-
:c:macro:`Py_NE`, :c:macro:`Py_GT`, or :c:macro:`Py_GE`, corresponding to ``<``,
226-
``<=``, ``==``, ``!=``, ``>``, or ``>=`` respectively. Returns ``-1`` on error,
227-
``0`` if the result is false, ``1`` otherwise. This is the equivalent of the
228-
Python expression ``o1 op o2``, where ``op`` is the operator corresponding to
229-
*opid*.
232+
like :c:func:`PyObject_RichCompare`, but returns ``-1`` on error, ``0`` if
233+
the result is false, ``1`` otherwise.
230234
231235
.. note::
232236
If *o1* and *o2* are the same object, :c:func:`PyObject_RichCompareBool`

0 commit comments

Comments
 (0)