File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -338,9 +338,23 @@ _PyCode_Quicken(PyCodeObject *code)
338338 assert (opcode < MIN_INSTRUMENTED_OPCODE );
339339 int caches = _PyOpcode_Caches [opcode ];
340340 if (caches ) {
341- // JUMP_BACKWARD counter counts up from 0 until it is > backedge_threshold
342- instructions [i + 1 ].cache =
343- opcode == JUMP_BACKWARD ? 0 : adaptive_counter_warmup ();
341+ // The initial value depends on the opcode
342+ int initial_value ;
343+ switch (opcode ) {
344+ case JUMP_BACKWARD :
345+ initial_value = 0 ;
346+ break ;
347+ case POP_JUMP_IF_FALSE :
348+ case POP_JUMP_IF_TRUE :
349+ case POP_JUMP_IF_NONE :
350+ case POP_JUMP_IF_NOT_NONE :
351+ initial_value = 0x5555 ; // Alternating 0, 1 bits
352+ break ;
353+ default :
354+ initial_value = adaptive_counter_warmup ();
355+ break ;
356+ }
357+ instructions [i + 1 ].cache = initial_value ;
344358 i += caches ;
345359 }
346360 }
You can’t perform that action at this time.
0 commit comments