From 7820a5897e7762df23bff1cbe749652130654a08 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 1 Mar 2022 05:53:13 -0800 Subject: bpo-46841: Use inline caching for `COMPARE_OP` (GH-31622) --- Include/internal/pycore_code.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'Include/internal/pycore_code.h') diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index dfa15b8cd6..47c1998c88 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -77,13 +77,20 @@ typedef struct { } _PyBinaryOpCache; #define INLINE_CACHE_ENTRIES_BINARY_OP CACHE_ENTRIES(_PyBinaryOpCache) + typedef struct { _Py_CODEUNIT counter; } _PyUnpackSequenceCache; - #define INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE \ - (sizeof(_PyUnpackSequenceCache) / sizeof(_Py_CODEUNIT)) + CACHE_ENTRIES(_PyUnpackSequenceCache) + +typedef struct { + _Py_CODEUNIT counter; + _Py_CODEUNIT mask; +} _PyCompareOpCache; + +#define INLINE_CACHE_ENTRIES_COMPARE_OP CACHE_ENTRIES(_PyCompareOpCache) /* Maximum size of code to quicken, in code units. */ #define MAX_SIZE_TO_QUICKEN 5000 @@ -323,8 +330,9 @@ extern int _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int narg extern int _Py_Specialize_Precall(PyObject *callable, _Py_CODEUNIT *instr, int nargs, PyObject *kwnames, SpecializedCacheEntry *cache, PyObject *builtins); extern void _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr, - int oparg); -extern void _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr, SpecializedCacheEntry *cache); + int oparg); +extern void _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs, + _Py_CODEUNIT *instr, int oparg); extern void _Py_Specialize_UnpackSequence(PyObject *seq, _Py_CODEUNIT *instr, int oparg); -- cgit v1.2.1