diff options
author | Neil Schemenauer <nas-github@arctrix.com> | 2024-12-03 18:25:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-03 18:25:12 (GMT) |
commit | 276cd66ccbbf85996a57bd1db3dd29b93a6eab64 (patch) | |
tree | a8f7f3676314b21b546c77e5928f28a5efff52e2 /Python/specialize.c | |
parent | 13b68e1a61e92a032d255aff5d5af435bbb63e8b (diff) | |
download | cpython-276cd66ccbbf85996a57bd1db3dd29b93a6eab64.zip cpython-276cd66ccbbf85996a57bd1db3dd29b93a6eab64.tar.gz cpython-276cd66ccbbf85996a57bd1db3dd29b93a6eab64.tar.bz2 |
gh-115999: Add free-threaded specialization for `SEND` (gh-127426)
No additional thread safety changes are required. Note that sending to
a generator that is shared between threads is currently not safe in the
free-threaded build.
Diffstat (limited to 'Python/specialize.c')
-rw-r--r-- | Python/specialize.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/Python/specialize.c b/Python/specialize.c index 0fe4e79..8b2d1a1 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -2627,28 +2627,21 @@ _Py_Specialize_Send(_PyStackRef receiver_st, _Py_CODEUNIT *instr) { PyObject *receiver = PyStackRef_AsPyObjectBorrow(receiver_st); - assert(ENABLE_SPECIALIZATION); + assert(ENABLE_SPECIALIZATION_FT); assert(_PyOpcode_Caches[SEND] == INLINE_CACHE_ENTRIES_SEND); - _PySendCache *cache = (_PySendCache *)(instr + 1); PyTypeObject *tp = Py_TYPE(receiver); if (tp == &PyGen_Type || tp == &PyCoro_Type) { if (_PyInterpreterState_GET()->eval_frame) { SPECIALIZATION_FAIL(SEND, SPEC_FAIL_OTHER); goto failure; } - instr->op.code = SEND_GEN; - goto success; + specialize(instr, SEND_GEN); + return; } SPECIALIZATION_FAIL(SEND, _PySpecialization_ClassifyIterator(receiver)); failure: - STAT_INC(SEND, failure); - instr->op.code = SEND; - cache->counter = adaptive_counter_backoff(cache->counter); - return; -success: - STAT_INC(SEND, success); - cache->counter = adaptive_counter_cooldown(); + unspecialize(instr); } #ifdef Py_STATS |