diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2025-05-05 16:46:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-05 16:46:56 (GMT) |
commit | 082dbf77884264a8470b1ea132cc458d0b5bf08a (patch) | |
tree | 3d441ff384d05c127bc67c3a9e4a8df8c8a2f6ad /Python/bytecodes.c | |
parent | 07f416a3f063db6b91b8b99ff61a51b64b0503f1 (diff) | |
download | cpython-082dbf77884264a8470b1ea132cc458d0b5bf08a.zip cpython-082dbf77884264a8470b1ea132cc458d0b5bf08a.tar.gz cpython-082dbf77884264a8470b1ea132cc458d0b5bf08a.tar.bz2 |
gh-133395: add option for extension modules to specialize BINARY_OP/SUBSCR, apply to arrays (#133396)
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r-- | Python/bytecodes.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 5a52efa..cc47e57 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -801,9 +801,19 @@ dummy_func( PyObject *right_o = PyStackRef_AsPyObjectBorrow(right); _PyBinaryOpSpecializationDescr *d = (_PyBinaryOpSpecializationDescr*)descr; assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5); - assert(d && d->guard); + assert(d); + assert(d->guard); int res = d->guard(left_o, right_o); - DEOPT_IF(!res); + ERROR_IF(res < 0); + if (res == 0) { + if (d->free) { + d->free(d); + } + _PyBinaryOpCache *cache = (_PyBinaryOpCache *)(this_instr+1); + write_ptr(cache->external_cache, NULL); + this_instr->op.code = BINARY_OP; + DEOPT_IF(true); + } } pure op(_BINARY_OP_EXTEND, (descr/4, left, right -- res)) { @@ -816,6 +826,7 @@ dummy_func( PyObject *res_o = d->action(left_o, right_o); DECREF_INPUTS(); + ERROR_IF(res_o == NULL); res = PyStackRef_FromPyObjectSteal(res_o); } |