@@ -100,6 +100,7 @@ typedef struct {
100100
101101typedef struct {
102102 _Py_BackoffCounter counter ;
103+ uint16_t external_cache [4 ];
103104} _PyBinaryOpCache ;
104105
105106#define INLINE_CACHE_ENTRIES_BINARY_OP CACHE_ENTRIES(_PyBinaryOpCache)
@@ -345,8 +346,8 @@ extern void _Py_Specialize_Call(_PyStackRef callable, _Py_CODEUNIT *instr,
345346 int nargs );
346347extern void _Py_Specialize_CallKw (_PyStackRef callable , _Py_CODEUNIT * instr ,
347348 int nargs );
348- extern void _Py_Specialize_BinaryOp (_PyStackRef lhs , _PyStackRef rhs , _Py_CODEUNIT * instr ,
349- int oparg , _PyStackRef * locals );
349+ extern int _Py_Specialize_BinaryOp (_PyStackRef lhs , _PyStackRef rhs , _Py_CODEUNIT * instr ,
350+ int oparg , _PyStackRef * locals );
350351extern void _Py_Specialize_CompareOp (_PyStackRef lhs , _PyStackRef rhs ,
351352 _Py_CODEUNIT * instr , int oparg );
352353extern void _Py_Specialize_UnpackSequence (_PyStackRef seq , _Py_CODEUNIT * instr ,
@@ -443,6 +444,12 @@ write_obj(uint16_t *p, PyObject *val)
443444 memcpy (p , & val , sizeof (val ));
444445}
445446
447+ static inline void
448+ write_void (uint16_t * p , void * val )
449+ {
450+ memcpy (p , & val , sizeof (val ));
451+ }
452+
446453static inline uint16_t
447454read_u16 (uint16_t * p )
448455{
@@ -473,6 +480,14 @@ read_obj(uint16_t *p)
473480 return val ;
474481}
475482
483+ static inline void *
484+ read_void (uint16_t * p )
485+ {
486+ void * val ;
487+ memcpy (& val , p , sizeof (val ));
488+ return val ;
489+ }
490+
476491/* See Objects/exception_handling_notes.txt for details.
477492 */
478493static inline unsigned char *
@@ -576,6 +591,17 @@ adaptive_counter_backoff(_Py_BackoffCounter counter) {
576591 return restart_backoff_counter (counter );
577592}
578593
594+ /* Specialization Extensions */
595+
596+ /* callbacks for an external specialization */
597+ typedef int (* binaryopguardfunc )(PyObject * lhs , PyObject * rhs );
598+ typedef PyObject * (* binaryopactionfunc )(PyObject * lhs , PyObject * rhs );
599+
600+ typedef struct _PyBinaryOpSpecializationDescr {
601+ binaryopguardfunc guard ;
602+ binaryopactionfunc action ;
603+ struct _PyBinaryOpSpecializationDescr * prev , * next ; /* For the tstate linked list */
604+ } PyBinaryOpSpecializationDescr ;
579605
580606/* Comparison bit masks. */
581607
0 commit comments