diff options
author | mpage <mpage@meta.com> | 2024-11-21 19:22:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-21 19:22:21 (GMT) |
commit | 09c240f20c47db126ad7e162df41e5c2596962d4 (patch) | |
tree | b9d2c0c6fec8392210040e554bb6569278430df3 /Tools | |
parent | 9dabace39d118ec7a204b6970f8a3f475a11522c (diff) | |
download | cpython-09c240f20c47db126ad7e162df41e5c2596962d4.zip cpython-09c240f20c47db126ad7e162df41e5c2596962d4.tar.gz cpython-09c240f20c47db126ad7e162df41e5c2596962d4.tar.bz2 |
gh-115999: Specialize `LOAD_GLOBAL` in free-threaded builds (#126607)
Enable specialization of LOAD_GLOBAL in free-threaded builds.
Thread-safety of specialization in free-threaded builds is provided by the following:
A critical section is held on both the globals and builtins objects during specialization. This ensures we get an atomic view of both builtins and globals during specialization.
Generation of new keys versions is made atomic in free-threaded builds.
Existing helpers are used to atomically modify the opcode.
Thread-safety of specialized instructions in free-threaded builds is provided by the following:
Relaxed atomics are used when loading and storing dict keys versions. This avoids potential data races as the dict keys versions are read without holding the dictionary's per-object lock in version guards.
Dicts keys objects are passed from keys version guards to the downstream uops. This ensures that we are loading from the correct offset in the keys object. Once a unicode key has been stored in a keys object for a combined dictionary in free-threaded builds, the offset that it is stored in will never be reused for a different key. Once the version guard passes, we know that we are reading from the correct offset.
The dictionary read fast-path is used to read values from the dictionary once we know the correct offset.
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/cases_generator/analyzer.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Tools/cases_generator/analyzer.py b/Tools/cases_generator/analyzer.py index 96b3244..e02e07e 100644 --- a/Tools/cases_generator/analyzer.py +++ b/Tools/cases_generator/analyzer.py @@ -623,6 +623,9 @@ NON_ESCAPING_FUNCTIONS = ( "_Py_NewRef", "_Py_SINGLETON", "_Py_STR", + "_Py_TryIncrefCompare", + "_Py_TryIncrefCompareStackRef", + "_Py_atomic_load_ptr_acquire", "_Py_atomic_load_uintptr_relaxed", "_Py_set_eval_breaker_bit", "advance_backoff_counter", |