gh-100239: specialize long tail of binary operations (#128722)

This commit is contained in:
Irit Katriel 2025-01-16 15:22:13 +00:00 committed by GitHub
parent e81fe940c9
commit 3893a92d95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 796 additions and 492 deletions

View file

@ -100,6 +100,7 @@ typedef struct {
typedef struct {
_Py_BackoffCounter counter;
uint16_t external_cache[4];
} _PyBinaryOpCache;
#define INLINE_CACHE_ENTRIES_BINARY_OP CACHE_ENTRIES(_PyBinaryOpCache)
@ -438,7 +439,7 @@ write_u64(uint16_t *p, uint64_t val)
}
static inline void
write_obj(uint16_t *p, PyObject *val)
write_ptr(uint16_t *p, void *val)
{
memcpy(p, &val, sizeof(val));
}
@ -576,6 +577,16 @@ adaptive_counter_backoff(_Py_BackoffCounter counter) {
return restart_backoff_counter(counter);
}
/* Specialization Extensions */
/* callbacks for an external specialization */
typedef int (*binaryopguardfunc)(PyObject *lhs, PyObject *rhs);
typedef PyObject *(*binaryopactionfunc)(PyObject *lhs, PyObject *rhs);
typedef struct {
binaryopguardfunc guard;
binaryopactionfunc action;
} _PyBinaryOpSpecializationDescr;
/* Comparison bit masks. */