Skip to content

Commit d6ef1a6

Browse files
2 parents 39d158f + 12b5a3c commit d6ef1a6

File tree

215 files changed

+4247
-2902
lines changed

Some content is hidden

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

215 files changed

+4247
-2902
lines changed

Doc/library/_thread.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ This module defines the following constants and functions:
5757
When the function raises a :exc:`SystemExit` exception, it is silently
5858
ignored.
5959

60+
.. audit-event:: _thread.start_new_thread function,args,kwargs start_new_thread
61+
6062
.. versionchanged:: 3.8
6163
:func:`sys.unraisablehook` is now used to handle unhandled exceptions.
6264

Include/cpython/modsupport.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,3 @@ PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywordsWithVararg(
106106
(minpos), (maxpos), (minkw), (buf)))
107107

108108
PyAPI_FUNC(PyObject *) _PyModule_CreateInitialized(PyModuleDef*, int apiver);
109-
110-
PyAPI_DATA(const char *) _Py_PackageContext;

Include/internal/pycore_context.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ void _PyContext_Fini(PyInterpreterState *);
1818

1919
/* other API */
2020

21+
typedef struct {
22+
PyObject_HEAD
23+
} _PyContextTokenMissing;
24+
2125
#ifndef WITH_FREELISTS
2226
// without freelists
2327
# define PyContext_MAXFREELIST 0

Include/internal/pycore_dict.h

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ extern "C" {
99
# error "this header requires Py_BUILD_CORE define"
1010
#endif
1111

12+
#include "pycore_dict_state.h"
13+
#include "pycore_runtime.h" // _PyRuntime
14+
1215

1316
/* runtime lifecycle */
1417

@@ -17,25 +20,6 @@ extern void _PyDict_Fini(PyInterpreterState *interp);
1720

1821
/* other API */
1922

20-
#ifndef WITH_FREELISTS
21-
// without freelists
22-
# define PyDict_MAXFREELIST 0
23-
#endif
24-
25-
#ifndef PyDict_MAXFREELIST
26-
# define PyDict_MAXFREELIST 80
27-
#endif
28-
29-
struct _Py_dict_state {
30-
#if PyDict_MAXFREELIST > 0
31-
/* Dictionary reuse scheme to save calls to malloc and free */
32-
PyDictObject *free_list[PyDict_MAXFREELIST];
33-
int numfree;
34-
PyDictKeysObject *keys_free_list[PyDict_MAXFREELIST];
35-
int keys_numfree;
36-
#endif
37-
};
38-
3923
typedef struct {
4024
/* Cached hash code of me_key. */
4125
Py_hash_t me_hash;
@@ -152,13 +136,11 @@ struct _dictvalues {
152136
(PyDictUnicodeEntry*)(&((int8_t*)((dk)->dk_indices))[(size_t)1 << (dk)->dk_log2_index_bytes]))
153137
#define DK_IS_UNICODE(dk) ((dk)->dk_kind != DICT_KEYS_GENERAL)
154138

155-
extern uint64_t _pydict_global_version;
156-
157-
#define DICT_MAX_WATCHERS 8
158139
#define DICT_VERSION_INCREMENT (1 << DICT_MAX_WATCHERS)
159140
#define DICT_VERSION_MASK (DICT_VERSION_INCREMENT - 1)
160141

161-
#define DICT_NEXT_VERSION() (_pydict_global_version += DICT_VERSION_INCREMENT)
142+
#define DICT_NEXT_VERSION() \
143+
(_PyRuntime.dict_state.global_version += DICT_VERSION_INCREMENT)
162144

163145
void
164146
_PyDict_SendEvent(int watcher_bits,
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#ifndef Py_INTERNAL_DICT_STATE_H
2+
#define Py_INTERNAL_DICT_STATE_H
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
#ifndef Py_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
9+
#endif
10+
11+
12+
struct _Py_dict_runtime_state {
13+
/*Global counter used to set ma_version_tag field of dictionary.
14+
* It is incremented each time that a dictionary is created and each
15+
* time that a dictionary is modified. */
16+
uint64_t global_version;
17+
uint32_t next_keys_version;
18+
};
19+
20+
21+
#ifndef WITH_FREELISTS
22+
// without freelists
23+
# define PyDict_MAXFREELIST 0
24+
#endif
25+
26+
#ifndef PyDict_MAXFREELIST
27+
# define PyDict_MAXFREELIST 80
28+
#endif
29+
30+
#define DICT_MAX_WATCHERS 8
31+
32+
struct _Py_dict_state {
33+
#if PyDict_MAXFREELIST > 0
34+
/* Dictionary reuse scheme to save calls to malloc and free */
35+
PyDictObject *free_list[PyDict_MAXFREELIST];
36+
PyDictKeysObject *keys_free_list[PyDict_MAXFREELIST];
37+
int numfree;
38+
int keys_numfree;
39+
#endif
40+
PyDict_WatchCallback watchers[DICT_MAX_WATCHERS];
41+
};
42+
43+
44+
#ifdef __cplusplus
45+
}
46+
#endif
47+
#endif /* !Py_INTERNAL_DICT_STATE_H */

Include/internal/pycore_dtoa.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifndef Py_INTERNAL_DTOA_H
2+
#define Py_INTERNAL_DTOA_H
13
#ifdef __cplusplus
24
extern "C" {
35
#endif
@@ -11,6 +13,46 @@ extern "C" {
1113

1214
#if _PY_SHORT_FLOAT_REPR == 1
1315

16+
typedef uint32_t ULong;
17+
18+
struct
19+
Bigint {
20+
struct Bigint *next;
21+
int k, maxwds, sign, wds;
22+
ULong x[1];
23+
};
24+
25+
#ifdef Py_USING_MEMORY_DEBUGGER
26+
27+
struct _dtoa_runtime_state {
28+
int _not_used;
29+
};
30+
#define _dtoa_runtime_state_INIT {0}
31+
32+
#else // !Py_USING_MEMORY_DEBUGGER
33+
34+
/* The size of the Bigint freelist */
35+
#define Bigint_Kmax 7
36+
37+
#ifndef PRIVATE_MEM
38+
#define PRIVATE_MEM 2304
39+
#endif
40+
#define Bigint_PREALLOC_SIZE \
41+
((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
42+
43+
struct _dtoa_runtime_state {
44+
struct Bigint *freelist[Bigint_Kmax+1];
45+
double preallocated[Bigint_PREALLOC_SIZE];
46+
double *preallocated_next;
47+
};
48+
#define _dtoa_runtime_state_INIT(runtime) \
49+
{ \
50+
.preallocated_next = runtime.dtoa.preallocated, \
51+
}
52+
53+
#endif // !Py_USING_MEMORY_DEBUGGER
54+
55+
1456
/* These functions are used by modules compiled as C extension like math:
1557
they must be exported. */
1658

@@ -26,3 +68,4 @@ PyAPI_FUNC(double) _Py_dg_infinity(int sign);
2668
#ifdef __cplusplus
2769
}
2870
#endif
71+
#endif /* !Py_INTERNAL_DTOA_H */

Include/internal/pycore_fileutils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ extern "C" {
1010

1111
#include <locale.h> /* struct lconv */
1212

13+
14+
struct _fileutils_state {
15+
int force_ascii;
16+
};
17+
1318
typedef enum {
1419
_Py_ERROR_UNKNOWN=0,
1520
_Py_ERROR_STRICT,

Include/internal/pycore_floatobject.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ extern void _PyFloat_FiniType(PyInterpreterState *);
1919

2020
/* other API */
2121

22+
enum _py_float_format_type {
23+
_py_float_format_unknown,
24+
_py_float_format_ieee_big_endian,
25+
_py_float_format_ieee_little_endian,
26+
};
27+
28+
struct _Py_float_runtime_state {
29+
enum _py_float_format_type float_format;
30+
enum _py_float_format_type double_format;
31+
};
32+
33+
2234
#ifndef WITH_FREELISTS
2335
// without freelists
2436
# define PyFloat_MAXFREELIST 0

Include/internal/pycore_function.h

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

11+
struct _py_func_runtime_state {
12+
uint32_t next_version;
13+
};
14+
1115
extern PyFunctionObject* _PyFunction_FromConstructor(PyFrameConstructor *constr);
1216

1317
extern uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func);

Include/internal/pycore_global_objects.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ extern "C" {
1010

1111
#include "pycore_gc.h" // PyGC_Head
1212
#include "pycore_global_strings.h" // struct _Py_global_strings
13+
#include "pycore_hamt.h" // PyHamtNode_Bitmap
14+
#include "pycore_context.h" // _PyContextTokenMissing
1315
#include "pycore_typeobject.h" // pytype_slotdef
1416

1517

@@ -52,6 +54,10 @@ struct _Py_global_objects {
5254

5355
_PyGC_Head_UNUSED _tuple_empty_gc_not_used;
5456
PyTupleObject tuple_empty;
57+
58+
_PyGC_Head_UNUSED _hamt_bitmap_node_empty_gc_not_used;
59+
PyHamtNode_Bitmap hamt_bitmap_node_empty;
60+
_PyContextTokenMissing context_token_missing;
5561
} singletons;
5662

5763
PyObject *interned;
@@ -76,6 +82,9 @@ struct _Py_interp_cached_objects {
7682
struct _Py_interp_static_objects {
7783
struct {
7884
int _not_used;
85+
// hamt_empty is here instead of global because of its weakreflist.
86+
_PyGC_Head_UNUSED _hamt_empty_gc_not_used;
87+
PyHamtObject hamt_empty;
7988
} singletons;
8089
};
8190

0 commit comments

Comments
 (0)