From 7bf51d6ed2dbf4af2c6f76a7d9ea4d13172a8280 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Sat, 11 Jan 2025 23:26:27 +0000 Subject: [PATCH] assert rather than deopt if no descr/guard --- Python/bytecodes.c | 3 +-- Python/executor_cases.c.h | 9 +-------- Python/generated_cases.c.h | 3 +-- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index ad32e6dd72c559..aec33dff3f9d2c 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -735,8 +735,7 @@ dummy_func( _PyBinaryOpCache *cache = (_PyBinaryOpCache *)(next_instr - INLINE_CACHE_ENTRIES_BINARY_OP); PyBinaryOpSpecializationDescr *descr = (PyBinaryOpSpecializationDescr *)read_void(cache->external_cache); - EXIT_IF(!descr); - EXIT_IF(!descr->guard); + assert(descr && descr->guard); int res = descr->guard(left_o, right_o); EXIT_IF(!res); } diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 21a9de87827283..7abafe289c59aa 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -909,14 +909,7 @@ PyBinaryOpSpecializationDescr *descr = (PyBinaryOpSpecializationDescr *)read_void(cache->external_cache); stack_pointer = _PyFrame_GetStackPointer(frame); - if (!descr) { - UOP_STAT_INC(uopcode, miss); - JUMP_TO_JUMP_TARGET(); - } - if (!descr->guard) { - UOP_STAT_INC(uopcode, miss); - JUMP_TO_JUMP_TARGET(); - } + assert(descr && descr->guard); _PyFrame_SetStackPointer(frame, stack_pointer); int res = descr->guard(left_o, right_o); stack_pointer = _PyFrame_GetStackPointer(frame); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 11ae13f7f499eb..afca32b609a3b9 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -192,8 +192,7 @@ PyBinaryOpSpecializationDescr *descr = (PyBinaryOpSpecializationDescr *)read_void(cache->external_cache); stack_pointer = _PyFrame_GetStackPointer(frame); - DEOPT_IF(!descr, BINARY_OP); - DEOPT_IF(!descr->guard, BINARY_OP); + assert(descr && descr->guard); _PyFrame_SetStackPointer(frame, stack_pointer); int res = descr->guard(left_o, right_o); stack_pointer = _PyFrame_GetStackPointer(frame);