aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Tools/cases_generator/generators_common.py
diff options
context:
space:
mode:
authorKen Jin <kenjin@python.org>2024-06-27 03:10:43 +0800
committerGitHub <noreply@github.com>2024-06-27 03:10:43 +0800
commit22b0de2755ee2d0e2dd21cd8761f15421ed2da3d (patch)
tree364c4bcd1b193482a111531924af51d688acf32e /Tools/cases_generator/generators_common.py
parentd611c4c8e9893c0816969e19ab6ca4992a3a15e3 (diff)
downloadcpython-22b0de2755ee2d0e2dd21cd8761f15421ed2da3d.tar.gz
cpython-22b0de2755ee2d0e2dd21cd8761f15421ed2da3d.zip
gh-117139: Convert the evaluation stack to stack refs (#118450)
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>
Diffstat (limited to 'Tools/cases_generator/generators_common.py')
-rw-r--r--Tools/cases_generator/generators_common.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Tools/cases_generator/generators_common.py b/Tools/cases_generator/generators_common.py
index efbfc94b415..e4e0c9b658c 100644
--- a/Tools/cases_generator/generators_common.py
+++ b/Tools/cases_generator/generators_common.py
@@ -128,15 +128,15 @@ def replace_decrefs(
continue
if var.size != "1":
out.emit(f"for (int _i = {var.size}; --_i >= 0;) {{\n")
- out.emit(f"Py_DECREF({var.name}[_i]);\n")
+ out.emit(f"PyStackRef_CLOSE({var.name}[_i]);\n")
out.emit("}\n")
elif var.condition:
if var.condition == "1":
- out.emit(f"Py_DECREF({var.name});\n")
+ out.emit(f"PyStackRef_CLOSE({var.name});\n")
elif var.condition != "0":
- out.emit(f"Py_XDECREF({var.name});\n")
+ out.emit(f"PyStackRef_XCLOSE({var.name});\n")
else:
- out.emit(f"Py_DECREF({var.name});\n")
+ out.emit(f"PyStackRef_CLOSE({var.name});\n")
def replace_sync_sp(