Skip to content

Commit 3b15847

Browse files
authored
Merge branch 'python:main' into fix-test
2 parents 33b2c24 + 56d0f9a commit 3b15847

Some content is hidden

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

69 files changed

+1454
-533
lines changed

Include/internal/pycore_genobject.h

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,9 @@ extern "C" {
99
#endif
1010

1111
#include "pycore_interpframe.h" // _PyInterpreterFrame
12+
#include "pycore_interpframe_structs.h" // _PyGenObject
1213

1314

14-
/* _PyGenObject_HEAD defines the initial segment of generator
15-
and coroutine objects. */
16-
#define _PyGenObject_HEAD(prefix) \
17-
PyObject_HEAD \
18-
/* List of weak reference. */ \
19-
PyObject *prefix##_weakreflist; \
20-
/* Name of the generator. */ \
21-
PyObject *prefix##_name; \
22-
/* Qualified name of the generator. */ \
23-
PyObject *prefix##_qualname; \
24-
_PyErr_StackItem prefix##_exc_state; \
25-
PyObject *prefix##_origin_or_finalizer; \
26-
char prefix##_hooks_inited; \
27-
char prefix##_closed; \
28-
char prefix##_running_async; \
29-
/* The frame */ \
30-
int8_t prefix##_frame_state; \
31-
_PyInterpreterFrame prefix##_iframe; \
32-
33-
struct _PyGenObject {
34-
/* The gi_ prefix is intended to remind of generator-iterator. */
35-
_PyGenObject_HEAD(gi)
36-
};
37-
38-
struct _PyCoroObject {
39-
_PyGenObject_HEAD(cr)
40-
};
41-
42-
struct _PyAsyncGenObject {
43-
_PyGenObject_HEAD(ag)
44-
};
45-
46-
#undef _PyGenObject_HEAD
47-
4815
static inline
4916
PyGenObject *_PyGen_GetGeneratorFromFrame(_PyInterpreterFrame *frame)
5017
{

Include/internal/pycore_interpframe.h

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* See InternalDocs/frames.md for an explanation of the frame stack
2-
* including explanation of the PyFrameObject and _PyInterpreterFrame
3-
* structs. */
4-
51
#ifndef Py_INTERNAL_INTERP_FRAME_H
62
#define Py_INTERNAL_INTERP_FRAME_H
73

@@ -10,49 +6,14 @@
106
#endif
117

128
#include "pycore_code.h" // _PyCode_CODE()
13-
#include "pycore_structs.h" // _PyStackRef
9+
#include "pycore_interpframe_structs.h" // _PyInterpreterFrame
1410
#include "pycore_stackref.h" // PyStackRef_AsPyObjectBorrow()
15-
#include "pycore_typedefs.h" // _PyInterpreterFrame
16-
11+
#include "pycore_stats.h" // CALL_STAT_INC()
1712

1813
#ifdef __cplusplus
1914
extern "C" {
2015
#endif
2116

22-
enum _frameowner {
23-
FRAME_OWNED_BY_THREAD = 0,
24-
FRAME_OWNED_BY_GENERATOR = 1,
25-
FRAME_OWNED_BY_FRAME_OBJECT = 2,
26-
FRAME_OWNED_BY_INTERPRETER = 3,
27-
FRAME_OWNED_BY_CSTACK = 4,
28-
};
29-
30-
struct _PyInterpreterFrame {
31-
_PyStackRef f_executable; /* Deferred or strong reference (code object or None) */
32-
struct _PyInterpreterFrame *previous;
33-
_PyStackRef f_funcobj; /* Deferred or strong reference. Only valid if not on C stack */
34-
PyObject *f_globals; /* Borrowed reference. Only valid if not on C stack */
35-
PyObject *f_builtins; /* Borrowed reference. Only valid if not on C stack */
36-
PyObject *f_locals; /* Strong reference, may be NULL. Only valid if not on C stack */
37-
PyFrameObject *frame_obj; /* Strong reference, may be NULL. Only valid if not on C stack */
38-
_Py_CODEUNIT *instr_ptr; /* Instruction currently executing (or about to begin) */
39-
_PyStackRef *stackpointer;
40-
#ifdef Py_GIL_DISABLED
41-
/* Index of thread-local bytecode containing instr_ptr. */
42-
int32_t tlbc_index;
43-
#endif
44-
uint16_t return_offset; /* Only relevant during a function call */
45-
char owner;
46-
#ifdef Py_DEBUG
47-
uint8_t visited:1;
48-
uint8_t lltrace:7;
49-
#else
50-
uint8_t visited;
51-
#endif
52-
/* Locals and stack */
53-
_PyStackRef localsplus[1];
54-
};
55-
5617
#define _PyInterpreterFrame_LASTI(IF) \
5718
((int)((IF)->instr_ptr - _PyFrame_GetBytecode((IF))))
5819

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/* Structures used by pycore_debug_offsets.h.
2+
*
3+
* See InternalDocs/frames.md for an explanation of the frame stack
4+
* including explanation of the PyFrameObject and _PyInterpreterFrame
5+
* structs.
6+
*/
7+
8+
#ifndef Py_INTERNAL_INTERP_FRAME_STRUCTS_H
9+
#define Py_INTERNAL_INTERP_FRAME_STRUCTS_H
10+
11+
#ifndef Py_BUILD_CORE
12+
# error "this header requires Py_BUILD_CORE define"
13+
#endif
14+
15+
#include "pycore_structs.h" // _PyStackRef
16+
#include "pycore_typedefs.h" // _PyInterpreterFrame
17+
18+
#ifdef __cplusplus
19+
extern "C" {
20+
#endif
21+
22+
enum _frameowner {
23+
FRAME_OWNED_BY_THREAD = 0,
24+
FRAME_OWNED_BY_GENERATOR = 1,
25+
FRAME_OWNED_BY_FRAME_OBJECT = 2,
26+
FRAME_OWNED_BY_INTERPRETER = 3,
27+
FRAME_OWNED_BY_CSTACK = 4,
28+
};
29+
30+
struct _PyInterpreterFrame {
31+
_PyStackRef f_executable; /* Deferred or strong reference (code object or None) */
32+
struct _PyInterpreterFrame *previous;
33+
_PyStackRef f_funcobj; /* Deferred or strong reference. Only valid if not on C stack */
34+
PyObject *f_globals; /* Borrowed reference. Only valid if not on C stack */
35+
PyObject *f_builtins; /* Borrowed reference. Only valid if not on C stack */
36+
PyObject *f_locals; /* Strong reference, may be NULL. Only valid if not on C stack */
37+
PyFrameObject *frame_obj; /* Strong reference, may be NULL. Only valid if not on C stack */
38+
_Py_CODEUNIT *instr_ptr; /* Instruction currently executing (or about to begin) */
39+
_PyStackRef *stackpointer;
40+
#ifdef Py_GIL_DISABLED
41+
/* Index of thread-local bytecode containing instr_ptr. */
42+
int32_t tlbc_index;
43+
#endif
44+
uint16_t return_offset; /* Only relevant during a function call */
45+
char owner;
46+
#ifdef Py_DEBUG
47+
uint8_t visited:1;
48+
uint8_t lltrace:7;
49+
#else
50+
uint8_t visited;
51+
#endif
52+
/* Locals and stack */
53+
_PyStackRef localsplus[1];
54+
};
55+
56+
57+
/* _PyGenObject_HEAD defines the initial segment of generator
58+
and coroutine objects. */
59+
#define _PyGenObject_HEAD(prefix) \
60+
PyObject_HEAD \
61+
/* List of weak reference. */ \
62+
PyObject *prefix##_weakreflist; \
63+
/* Name of the generator. */ \
64+
PyObject *prefix##_name; \
65+
/* Qualified name of the generator. */ \
66+
PyObject *prefix##_qualname; \
67+
_PyErr_StackItem prefix##_exc_state; \
68+
PyObject *prefix##_origin_or_finalizer; \
69+
char prefix##_hooks_inited; \
70+
char prefix##_closed; \
71+
char prefix##_running_async; \
72+
/* The frame */ \
73+
int8_t prefix##_frame_state; \
74+
_PyInterpreterFrame prefix##_iframe; \
75+
76+
struct _PyGenObject {
77+
/* The gi_ prefix is intended to remind of generator-iterator. */
78+
_PyGenObject_HEAD(gi)
79+
};
80+
81+
struct _PyCoroObject {
82+
_PyGenObject_HEAD(cr)
83+
};
84+
85+
struct _PyAsyncGenObject {
86+
_PyGenObject_HEAD(ag)
87+
};
88+
89+
#undef _PyGenObject_HEAD
90+
91+
92+
#ifdef __cplusplus
93+
}
94+
#endif
95+
#endif // !Py_INTERNAL_INTERP_FRAME_STRUCTS_H

Include/internal/pycore_object.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
#include <stdbool.h>
1211
#include "pycore_emscripten_trampoline.h" // _PyCFunction_TrampolineCall()
13-
#include "pycore_object_deferred.h" // _PyObject_HasDeferredRefcount
14-
#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_STORE_PTR_RELAXED
12+
#include "pycore_gc.h" // _PyObject_GC_TRACK()
13+
#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_PTR_ACQUIRE()
1514
#include "pycore_pystate.h" // _PyInterpreterState_GET()
1615
#include "pycore_runtime.h" // _PyRuntime
1716
#include "pycore_typeobject.h" // _PyStaticType_GetState()
1817
#include "pycore_uniqueid.h" // _PyObject_ThreadIncrefSlow()
1918

19+
#include <stdbool.h> // bool
20+
21+
2022
// This value is added to `ob_ref_shared` for objects that use deferred
2123
// reference counting so that they are not immediately deallocated when the
2224
// non-deferred reference count drops to zero.

Include/internal/pycore_optimizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ typedef struct _jit_opt_tuple {
202202

203203
typedef struct {
204204
uint8_t tag;
205-
bool not;
205+
bool invert;
206206
uint16_t value;
207207
} JitOptTruthiness;
208208

Include/internal/pycore_runtime_structs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct _fileutils_state {
6464
int force_ascii;
6565
};
6666

67+
#include "pycore_interpframe_structs.h" // _PyInterpreterFrame
6768
#include "pycore_debug_offsets.h" // _Py_DebugOffsets
6869
#include "pycore_signal.h" // struct _signals_runtime_state
6970
#include "pycore_faulthandler.h" // struct _faulthandler_runtime_state

Include/internal/pycore_stackref.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ extern "C" {
1313
# error "this header requires Py_BUILD_CORE define"
1414
#endif
1515

16-
#include "pycore_object_deferred.h"
17-
#include "pycore_object.h"
16+
#include "pycore_object.h" // Py_DECREF_MORTAL
17+
#include "pycore_object_deferred.h" // _PyObject_HasDeferredRefcount()
18+
19+
#include <stdbool.h> // bool
1820

19-
#include <stddef.h>
20-
#include <stdbool.h>
2121

2222
/*
2323
This file introduces a new API for handling references on the stack, called

Include/internal/pycore_typeobject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
#include "pycore_function.h"
1211
#include "pycore_interp_structs.h" // managed_static_type_state
1312
#include "pycore_moduleobject.h" // PyModuleObject
14-
#include "pycore_stats.h"
1513

1614

1715
/* state */

Include/internal/pycore_uop_ids.h

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

Include/internal/pycore_uop_metadata.h

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

0 commit comments

Comments
 (0)