aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
authorDonghee Na <donghee.na@python.org>2024-11-06 12:35:10 +0900
committerGitHub <noreply@github.com>2024-11-06 03:35:10 +0000
commit4ea214ea982944b59ff543a5c6f4ec782a47588c (patch)
treef8d66aefcaf94379c8f67acc70c74f22f9082c6f /Python/bytecodes.c
parenta204c63919ca7ce528d8e3ab4196a4aa1a2b6ac4 (diff)
downloadcpython-4ea214ea982944b59ff543a5c6f4ec782a47588c.tar.gz
cpython-4ea214ea982944b59ff543a5c6f4ec782a47588c.zip
gh-115999: Add free-threaded specialization for CONTAINS_OP (gh-126450)
- The specialization logic determines the appropriate specialization using only the operand's type, which is safe to read non-atomically (changing it requires stopping the world). We are guaranteed that the type will not change in between when it is checked and when we specialize the bytecode because the types involved are immutable (you cannot assign to `__class__` for exact instances of `dict`, `set`, or `frozenset`). The bytecode is mutated atomically using helpers. - The specialized instructions rely on the operand type not changing in between the `DEOPT_IF` checks and the calls to the appropriate type-specific helpers (e.g. `_PySet_Contains`). This is a correctness requirement in the default builds and there are no changes to the opcodes in the free-threaded builds that would invalidate this.
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 8c52db6ab68..7ae0f203696 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -2508,7 +2508,7 @@ dummy_func(
}
specializing op(_SPECIALIZE_CONTAINS_OP, (counter/1, left, right -- left, right)) {
- #if ENABLE_SPECIALIZATION
+ #if ENABLE_SPECIALIZATION_FT
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_Py_Specialize_ContainsOp(right, next_instr);