Commit 22b0de2
This PR sets up tagged pointers for CPython.
The general idea is to create a separate struct _PyStackRef for everything on the evaluation stack to store the bits. This forces the C compiler to warn us if we try to cast things or pull things out of the struct directly.
Only for free threading: We tag the low bit if something is deferred - that means we skip incref and decref operations on it. This behavior may change in the future if Mark's plans to defer all objects in the interpreter loop pans out.
This implies a strict stack reference discipline is required. ALL incref and decref operations on stackrefs must use the stackref variants. It is unsafe to untag something then do normal incref/decref ops on it.
The new incref and decref variants are called dup and close. They mimic a "handle" API operating on these stackrefs.
Please read Include/internal/pycore_stackref.h for more information!
---------
Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com>
1 parent d611c4c commit 22b0de2Copy full SHA for 22b0de2
35 files changed
+5,215-3,745Lines changed: 5215 additions & 3745 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- Include/internal
- Lib/test
- Misc/NEWS.d/next/Core and Builtins
- Objects
- PCbuild
- Python
- Tools
- cases_generator
- gdb
- jit
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Include/internal/pycore_ceval.h
Copy file name to clipboardExpand all lines: Include/internal/pycore_ceval.h+4-1Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
261 | 261 | |
262 | 262 | |
263 | 263 | |
264 | | - |
| 264 | + |
265 | 265 | |
| 266 | + |
| 267 | + |
| 268 | + |
266 | 269 | |
267 | 270 | |
268 | 271 | |
|
Collapse file
Include/internal/pycore_code.h
Copy file name to clipboardExpand all lines: Include/internal/pycore_code.h+15-14Lines changed: 15 additions & 14 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
8 | 8 | |
9 | 9 | |
10 | 10 | |
| 11 | + |
11 | 12 | |
12 | 13 | |
13 | 14 | |
| ||
317 | 318 | |
318 | 319 | |
319 | 320 | |
320 | | - |
| 321 | + |
321 | 322 | |
322 | | - |
| 323 | + |
323 | 324 | |
324 | | - |
| 325 | + |
325 | 326 | |
326 | 327 | |
327 | 328 | |
328 | | - |
| 329 | + |
329 | 330 | |
330 | | - |
| 331 | + |
331 | 332 | |
332 | | - |
| 333 | + |
333 | 334 | |
334 | | - |
335 | | - |
336 | | - |
| 335 | + |
| 336 | + |
| 337 | + |
337 | 338 | |
338 | | - |
| 339 | + |
339 | 340 | |
340 | | - |
341 | | - |
342 | | - |
343 | | - |
| 341 | + |
| 342 | + |
| 343 | + |
| 344 | + |
344 | 345 | |
345 | 346 | |
346 | 347 | |
|
Collapse file
Include/internal/pycore_frame.h
Copy file name to clipboardExpand all lines: Include/internal/pycore_frame.h+14-13Lines changed: 14 additions & 13 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
11 | 11 | |
12 | 12 | |
13 | 13 | |
| 14 | + |
14 | 15 | |
15 | 16 | |
16 | 17 | |
| ||
67 | 68 | |
68 | 69 | |
69 | 70 | |
70 | | - |
| 71 | + |
71 | 72 | |
72 | 73 | |
73 | 74 | |
| ||
78 | 79 | |
79 | 80 | |
80 | 81 | |
81 | | - |
82 | | - |
| 82 | + |
| 83 | + |
83 | 84 | |
84 | 85 | |
85 | | - |
| 86 | + |
86 | 87 | |
87 | | - |
| 88 | + |
88 | 89 | |
89 | 90 | |
90 | 91 | |
91 | | - |
| 92 | + |
92 | 93 | |
93 | 94 | |
94 | 95 | |
95 | 96 | |
96 | 97 | |
97 | | - |
| 98 | + |
98 | 99 | |
99 | 100 | |
100 | 101 | |
| ||
143 | 144 | |
144 | 145 | |
145 | 146 | |
146 | | - |
| 147 | + |
147 | 148 | |
148 | 149 | |
149 | 150 | |
150 | 151 | |
151 | 152 | |
152 | 153 | |
153 | | - |
| 154 | + |
154 | 155 | |
155 | 156 | |
156 | 157 | |
| ||
160 | 161 | |
161 | 162 | |
162 | 163 | |
163 | | - |
| 164 | + |
164 | 165 | |
165 | 166 | |
166 | | - |
| 167 | + |
167 | 168 | |
168 | 169 | |
169 | 170 | |
170 | 171 | |
171 | 172 | |
172 | | - |
| 173 | + |
173 | 174 | |
174 | 175 | |
175 | 176 | |
| ||
309 | 310 | |
310 | 311 | |
311 | 312 | |
312 | | - |
| 313 | + |
313 | 314 | |
314 | 315 | |
315 | 316 | |
|
Collapse file
Include/internal/pycore_jit.h
Copy file name to clipboardExpand all lines: Include/internal/pycore_jit.h+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
11 | 11 | |
12 | 12 | |
13 | 13 | |
14 | | - |
| 14 | + |
15 | 15 | |
16 | 16 | |
17 | 17 | |
|
Collapse file
Include/internal/pycore_object.h
Copy file name to clipboardExpand all lines: Include/internal/pycore_object.h-15Lines changed: 0 additions & 15 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
159 | 159 | |
160 | 160 | |
161 | 161 | |
162 | | - |
163 | | - |
164 | | - |
165 | | - |
166 | | - |
167 | | - |
168 | | - |
169 | | - |
170 | | - |
171 | | - |
172 | | - |
173 | | - |
174 | | - |
175 | | - |
176 | | - |
177 | 162 | |
178 | 163 | |
179 | 164 | |
|
Collapse file
Include/internal/pycore_object_deferred.h
Copy file name to clipboard+32Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
Collapse file
Include/internal/pycore_optimizer.h
Copy file name to clipboardExpand all lines: Include/internal/pycore_optimizer.h+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
271 | 271 | |
272 | 272 | |
273 | 273 | |
274 | | - |
| 274 | + |
275 | 275 | |
276 | 276 | |
277 | 277 | |
|
0 commit comments