summaryrefslogtreecommitdiffstats
path: root/Lib/test/support/__init__.py
diff options
context:
space:
mode:
authormpage <mpage@cs.stanford.edu>2024-11-04 19:13:32 (GMT)
committerGitHub <noreply@github.com>2024-11-04 19:13:32 (GMT)
commit2e95c5ba3bf7e5004c7e2304afda4a8f8e2443a7 (patch)
treede32ac52ed5ffcb9460dfc062effc6b4b662ee5d /Lib/test/support/__init__.py
parente5a4b402ae55f5eeeb44d3e7bc3f3ec39b249846 (diff)
downloadcpython-2e95c5ba3bf7e5004c7e2304afda4a8f8e2443a7.zip
cpython-2e95c5ba3bf7e5004c7e2304afda4a8f8e2443a7.tar.gz
cpython-2e95c5ba3bf7e5004c7e2304afda4a8f8e2443a7.tar.bz2
gh-115999: Implement thread-local bytecode and enable specialization for `BINARY_OP` (#123926)
Each thread specializes a thread-local copy of the bytecode, created on the first RESUME, in free-threaded builds. All copies of the bytecode for a code object are stored in the co_tlbc array on the code object. Threads reserve a globally unique index identifying its copy of the bytecode in all co_tlbc arrays at thread creation and release the index at thread destruction. The first entry in every co_tlbc array always points to the "main" copy of the bytecode that is stored at the end of the code object. This ensures that no bytecode is copied for programs that do not use threads. Thread-local bytecode can be disabled at runtime by providing either -X tlbc=0 or PYTHON_TLBC=0. Disabling thread-local bytecode also disables specialization. Concurrent modifications to the bytecode made by the specializing interpreter and instrumentation use atomics, with specialization taking care not to overwrite an instruction that was instrumented concurrently.
Diffstat (limited to 'Lib/test/support/__init__.py')
-rw-r--r--Lib/test/support/__init__.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 7c1ef42..2ad267e 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1274,6 +1274,11 @@ def requires_specialization(test):
_opcode.ENABLE_SPECIALIZATION, "requires specialization")(test)
+def requires_specialization_ft(test):
+ return unittest.skipUnless(
+ _opcode.ENABLE_SPECIALIZATION_FT, "requires specialization")(test)
+
+
#=======================================================================
# Check for the presence of docstrings.