Skip to content

Commit c8cac69

Browse files
committed
Merge branch 'main' of https://github.com/python/cpython into fix-circular-finalization
2 parents 0e66c88 + 49f1c30 commit c8cac69

Some content is hidden

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

63 files changed

+2061
-962
lines changed

.github/workflows/jit.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,33 @@ jobs:
134134
make all --jobs 4
135135
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
136136
137+
no-opt-jit:
138+
name: JIT without optimizations (Debug)
139+
needs: interpreter
140+
runs-on: ubuntu-24.04
141+
timeout-minutes: 90
142+
strategy:
143+
fail-fast: false
144+
matrix:
145+
llvm:
146+
- 19
147+
steps:
148+
- uses: actions/checkout@v4
149+
with:
150+
persist-credentials: false
151+
- uses: actions/setup-python@v5
152+
with:
153+
python-version: '3.11'
154+
- name: Build with JIT
155+
run: |
156+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
157+
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
158+
./configure --enable-experimental-jit --with-pydebug
159+
make all --jobs 4
160+
- name: Run tests without optimizations
161+
run: |
162+
PYTHON_UOPS_OPTIMIZE=0 ./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
163+
137164
# XXX: GH-133171
138165
# jit-with-disabled-gil:
139166
# name: Free-Threaded (Debug)

Doc/c-api/unicode.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ APIs:
747747
Return ``0`` on success, ``-1`` on error with an exception set.
748748
749749
This function checks that *unicode* is a Unicode object, that the index is
750-
not out of bounds, and that the object's reference count is one).
750+
not out of bounds, and that the object's reference count is one.
751751
See :c:func:`PyUnicode_WRITE` for a version that skips these checks,
752752
making them your responsibility.
753753

Doc/library/argparse.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -774,16 +774,16 @@ how the command-line arguments should be handled. The supplied actions are:
774774
>>> parser.parse_args('--foo --bar'.split())
775775
Namespace(foo=True, bar=False, baz=True)
776776

777-
* ``'append'`` - This stores a list, and appends each argument value to the
778-
list. It is useful to allow an option to be specified multiple times.
779-
If the default value is non-empty, the default elements will be present
780-
in the parsed value for the option, with any values from the
781-
command line appended after those default values. Example usage::
777+
* ``'append'`` - This appends each argument value to a list.
778+
It is useful for allowing an option to be specified multiple times.
779+
If the default value is a non-empty list, the parsed value will start
780+
with the default list's elements and any values from the command line
781+
will be appended after those default values. Example usage::
782782

783783
>>> parser = argparse.ArgumentParser()
784-
>>> parser.add_argument('--foo', action='append')
784+
>>> parser.add_argument('--foo', action='append', default=['0'])
785785
>>> parser.parse_args('--foo 1 --foo 2'.split())
786-
Namespace(foo=['1', '2'])
786+
Namespace(foo=['0', '1', '2'])
787787

788788
* ``'append_const'`` - This stores a list, and appends the value specified by
789789
the const_ keyword argument to the list; note that the const_ keyword

Doc/library/sqlite3.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ Connection objects
620620
supplied, this must be a :term:`callable` returning
621621
an instance of :class:`Cursor` or its subclasses.
622622

623-
.. method:: blobopen(table, column, row, /, *, readonly=False, name="main")
623+
.. method:: blobopen(table, column, rowid, /, *, readonly=False, name="main")
624624

625625
Open a :class:`Blob` handle to an existing
626626
:abbr:`BLOB (Binary Large OBject)`.
@@ -631,8 +631,8 @@ Connection objects
631631
:param str column:
632632
The name of the column where the blob is located.
633633

634-
:param str row:
635-
The name of the row where the blob is located.
634+
:param int rowid:
635+
The row id where the blob is located.
636636

637637
:param bool readonly:
638638
Set to ``True`` if the blob should be opened without write

Doc/whatsnew/3.15.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,13 @@ shelve
404404
(Contributed by Andrea Oliveri in :gh:`134004`.)
405405

406406

407+
socket
408+
------
409+
410+
* Add constants for the ISO-TP CAN protocol.
411+
(Contributed by Patrick Menschel and Stefan Tatschner in :gh:`86819`.)
412+
413+
407414
sqlite3
408415
-------
409416

Include/cpython/pystate.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ struct _ts {
158158
*/
159159
unsigned long native_thread_id;
160160

161+
/* List of objects that still need to be cleaned up, singly linked
162+
* via their gc headers' gc_next pointers. The list is populated by
163+
* _PyTrash_thread_deposit_object and cleaned up by
164+
* _PyTrash_thread_destroy_chain.
165+
*/
161166
PyObject *delete_later;
162167

163168
/* Tagged pointer to top-most critical section, or zero if there is no

Include/internal/pycore_global_objects_fini_generated.h

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

Include/internal/pycore_global_strings.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ struct _Py_global_strings {
424424
STRUCT_FOR_ID(eager_start)
425425
STRUCT_FOR_ID(effective_ids)
426426
STRUCT_FOR_ID(element_factory)
427+
STRUCT_FOR_ID(emptyerror)
427428
STRUCT_FOR_ID(encode)
428429
STRUCT_FOR_ID(encoding)
429430
STRUCT_FOR_ID(end)
@@ -449,6 +450,7 @@ struct _Py_global_strings {
449450
STRUCT_FOR_ID(extra_tokens)
450451
STRUCT_FOR_ID(facility)
451452
STRUCT_FOR_ID(factory)
453+
STRUCT_FOR_ID(fallback)
452454
STRUCT_FOR_ID(false)
453455
STRUCT_FOR_ID(family)
454456
STRUCT_FOR_ID(fanout)
@@ -481,6 +483,7 @@ struct _Py_global_strings {
481483
STRUCT_FOR_ID(fromtimestamp)
482484
STRUCT_FOR_ID(fromutc)
483485
STRUCT_FOR_ID(fset)
486+
STRUCT_FOR_ID(fullerror)
484487
STRUCT_FOR_ID(func)
485488
STRUCT_FOR_ID(future)
486489
STRUCT_FOR_ID(generation)
@@ -593,6 +596,7 @@ struct _Py_global_strings {
593596
STRUCT_FOR_ID(maxevents)
594597
STRUCT_FOR_ID(maxlen)
595598
STRUCT_FOR_ID(maxmem)
599+
STRUCT_FOR_ID(maxsize)
596600
STRUCT_FOR_ID(maxsplit)
597601
STRUCT_FOR_ID(maxvalue)
598602
STRUCT_FOR_ID(memLevel)
@@ -691,7 +695,9 @@ struct _Py_global_strings {
691695
STRUCT_FOR_ID(protocol)
692696
STRUCT_FOR_ID(ps1)
693697
STRUCT_FOR_ID(ps2)
698+
STRUCT_FOR_ID(qid)
694699
STRUCT_FOR_ID(query)
700+
STRUCT_FOR_ID(queuetype)
695701
STRUCT_FOR_ID(quotetabs)
696702
STRUCT_FOR_ID(raw)
697703
STRUCT_FOR_ID(read)
@@ -817,6 +823,7 @@ struct _Py_global_strings {
817823
STRUCT_FOR_ID(tzinfo)
818824
STRUCT_FOR_ID(tzname)
819825
STRUCT_FOR_ID(uid)
826+
STRUCT_FOR_ID(unboundop)
820827
STRUCT_FOR_ID(unlink)
821828
STRUCT_FOR_ID(unraisablehook)
822829
STRUCT_FOR_ID(updates)

Include/internal/pycore_interp_structs.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern "C" {
1414
#include "pycore_structs.h" // PyHamtObject
1515
#include "pycore_tstate.h" // _PyThreadStateImpl
1616
#include "pycore_typedefs.h" // _PyRuntimeState
17+
#include "pycore_uop.h" // struct _PyUOpInstruction
1718

1819

1920
#define CODE_MAX_WATCHERS 8
@@ -202,12 +203,6 @@ enum _GCPhase {
202203
#define NUM_GENERATIONS 3
203204

204205
struct _gc_runtime_state {
205-
/* List of objects that still need to be cleaned up, singly linked
206-
* via their gc headers' gc_prev pointers. */
207-
PyObject *trash_delete_later;
208-
/* Current call-stack depth of tp_dealloc calls. */
209-
int trash_delete_nesting;
210-
211206
/* Is automatic collection enabled? */
212207
int enabled;
213208
int debug;
@@ -949,6 +944,8 @@ struct _is {
949944
struct callable_cache callable_cache;
950945
PyObject *common_consts[NUM_COMMON_CONSTANTS];
951946
bool jit;
947+
bool compiling;
948+
struct _PyUOpInstruction *jit_uop_buffer;
952949
struct _PyExecutorObject *executor_list_head;
953950
struct _PyExecutorObject *executor_deletion_list_head;
954951
struct _PyExecutorObject *cold_executor;

Include/internal/pycore_optimizer.h

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ extern "C" {
99
#endif
1010

1111
#include "pycore_typedefs.h" // _PyInterpreterFrame
12+
#include "pycore_uop.h" // _PyUOpInstruction
1213
#include "pycore_uop_ids.h"
1314
#include "pycore_stackref.h" // _PyStackRef
1415
#include <stdbool.h>
@@ -41,32 +42,6 @@ typedef struct {
4142
PyCodeObject *code; // Weak (NULL if no corresponding ENTER_EXECUTOR).
4243
} _PyVMData;
4344

44-
/* Depending on the format,
45-
* the 32 bits between the oparg and operand are:
46-
* UOP_FORMAT_TARGET:
47-
* uint32_t target;
48-
* UOP_FORMAT_JUMP
49-
* uint16_t jump_target;
50-
* uint16_t error_target;
51-
*/
52-
typedef struct {
53-
uint16_t opcode:15;
54-
uint16_t format:1;
55-
uint16_t oparg;
56-
union {
57-
uint32_t target;
58-
struct {
59-
uint16_t jump_target;
60-
uint16_t error_target;
61-
};
62-
};
63-
uint64_t operand0; // A cache entry
64-
uint64_t operand1;
65-
#ifdef Py_STATS
66-
uint64_t execution_count;
67-
#endif
68-
} _PyUOpInstruction;
69-
7045
typedef struct _PyExitData {
7146
uint32_t target;
7247
uint16_t index;
@@ -118,9 +93,6 @@ PyAPI_FUNC(void) _Py_Executors_InvalidateCold(PyInterpreterState *interp);
11893
// trace_run_counter is greater than this value.
11994
#define JIT_CLEANUP_THRESHOLD 100000
12095

121-
// This is the length of the trace we project initially.
122-
#define UOP_MAX_TRACE_LENGTH 1200
123-
12496
#define TRACE_STACK_SIZE 5
12597

12698
int _Py_uop_analyze_and_optimize(_PyInterpreterFrame *frame,
@@ -278,9 +250,13 @@ PyJitRef_IsBorrowed(JitOptRef ref)
278250
}
279251

280252
struct _Py_UOpsAbstractFrame {
253+
bool globals_watched;
254+
// The version number of the globals dicts, once checked. 0 if unchecked.
255+
uint32_t globals_checked_version;
281256
// Max stacklen
282257
int stack_len;
283258
int locals_len;
259+
PyFunctionObject *func;
284260

285261
JitOptRef *stack_pointer;
286262
JitOptRef *stack;
@@ -299,6 +275,8 @@ typedef struct _JitOptContext {
299275
char done;
300276
char out_of_space;
301277
bool contradiction;
278+
// Has the builtins dict been watched?
279+
bool builtins_watched;
302280
// The current "executing" frame.
303281
_Py_UOpsAbstractFrame *frame;
304282
_Py_UOpsAbstractFrame frames[MAX_ABSTRACT_FRAME_DEPTH];

0 commit comments

Comments
 (0)