Skip to content

Commit 291ace9

Browse files
committed
Consider all instructions when computing mutations
derp
1 parent e765735 commit 291ace9

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

Python/specialize.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -491,22 +491,26 @@ _PyCode_Quicken(_Py_CODEUNIT *instructions, Py_ssize_t size, int enable_counters
491491
opcode = instructions[i].op.code;
492492
int caches = _PyOpcode_Caches[opcode];
493493
oparg = (oparg << 8) | instructions[i].op.arg;
494+
switch (opcode) {
495+
case LOAD_FAST_AND_CLEAR:
496+
case DELETE_FAST:
497+
case MAKE_CELL:
498+
case STORE_FAST:
499+
set_mutated(mutated, oparg);
500+
break;
501+
case STORE_FAST_STORE_FAST:
502+
set_mutated(mutated, oparg >> 4);
503+
set_mutated(mutated, oparg & 15);
504+
break;
505+
case STORE_FAST_LOAD_FAST:
506+
set_mutated(mutated, oparg >> 4);
507+
break;
508+
default:
509+
break;
510+
}
494511
if (caches) {
495512
// The initial value depends on the opcode
496513
switch (opcode) {
497-
case LOAD_FAST_AND_CLEAR:
498-
case DELETE_FAST:
499-
case MAKE_CELL:
500-
case STORE_FAST:
501-
set_mutated(mutated, oparg);
502-
break;
503-
case STORE_FAST_STORE_FAST:
504-
set_mutated(mutated, oparg >> 4);
505-
set_mutated(mutated, oparg & 15);
506-
break;
507-
case STORE_FAST_LOAD_FAST:
508-
set_mutated(mutated, oparg >> 4);
509-
break;
510514
case JUMP_BACKWARD:
511515
instructions[i + 1].counter = jump_counter;
512516
break;
@@ -534,8 +538,8 @@ _PyCode_Quicken(_Py_CODEUNIT *instructions, Py_ssize_t size, int enable_counters
534538
int total = 0;
535539
for (Py_ssize_t i = 0; i < size; i++) {
536540
opcode = instructions[i].op.code;
541+
oparg = (oparg << 8) | instructions[i].op.arg;
537542
if (opcode == LOAD_FAST) {
538-
oparg = (oparg << 8) | instructions[i].op.arg;
539543
total++;
540544
if (!get_mutated(mutated, oparg)) {
541545
instructions[i].op.code = LOAD_FAST_BORROW;

0 commit comments

Comments
 (0)