From b66fc3aa693d61049f873e0370a89693257229a8 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Wed, 15 Jun 2022 21:42:48 +0800 Subject: [PATCH 1/3] Fix specialization cache miss counters --- Python/ceval.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index f9ec640ef1722a..8545f67eaba156 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1551,6 +1551,12 @@ eval_frame_handle_pending(PyThreadState *tstate) #define DECREMENT_ADAPTIVE_COUNTER(cache) \ (cache)->counter -= (1< Date: Wed, 15 Jun 2022 21:46:26 +0800 Subject: [PATCH 2/3] fix name --- Python/ceval.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 8545f67eaba156..122618b0690fc2 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -5614,13 +5614,14 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int opcode = _PyOpcode_Deopt[opcode]; STAT_INC(opcode, miss); /* The counter is always the first cache entry: */ - DECREMENT_ADAPTIVE_COUNTER_CODE(next_instr); - if (ADAPTIVE_COUNTER_CODE_IS_ZERO(next_instr)) { + _Py_CODEUNIT *counter = (_Py_CODEUNIT *)next_instr; + DECREMENT_ADAPTIVE_COUNTER_CODE(counter); + if (ADAPTIVE_COUNTER_CODE_IS_ZERO(counter)) { int adaptive_opcode = _PyOpcode_Adaptive[opcode]; assert(adaptive_opcode); _Py_SET_OPCODE(next_instr[-1], adaptive_opcode); STAT_INC(opcode, deopt); - *next_instr = adaptive_counter_start(); + *counter = adaptive_counter_start(); } next_instr--; DISPATCH_GOTO(); From 98f56f3fee1a48cf989696aa17876008e8ac4282 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Wed, 15 Jun 2022 23:13:25 +0800 Subject: [PATCH 3/3] Apply Guido's suggestions --- Python/ceval.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 122618b0690fc2..f129d604785691 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1546,16 +1546,16 @@ eval_frame_handle_pending(PyThreadState *tstate) } #define ADAPTIVE_COUNTER_IS_ZERO(cache) \ - (cache)->counter < (1<counter < (1<counter -= (1<counter -= (1<