@@ -440,11 +440,7 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
440
440
for i in range (start , end ):
441
441
labels .add (target )
442
442
starts_line = None
443
- cache_counter = 0
444
443
for offset , op , arg in _unpack_opargs (code ):
445
- if cache_counter > 0 :
446
- cache_counter -= 1
447
- continue
448
444
if linestarts is not None :
449
445
starts_line = linestarts .get (offset , None )
450
446
if starts_line is not None :
@@ -454,7 +450,6 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
454
450
argrepr = ''
455
451
positions = Positions (* next (co_positions , ()))
456
452
deop = _deoptop (op )
457
- cache_counter = _inline_cache_entries [deop ]
458
453
if arg is not None :
459
454
# Set argval to the dereferenced value of the argument when
460
455
# available, and argrepr to the string representation of argval.
@@ -497,7 +492,7 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
497
492
yield Instruction (_all_opname [op ], op ,
498
493
arg , argval , argrepr ,
499
494
offset , starts_line , is_jump_target , positions )
500
- if show_caches and cache_counter :
495
+ if show_caches and _inline_cache_entries [ deop ] :
501
496
for name , caches in _cache_format [opname [deop ]].items ():
502
497
data = code [offset + 2 : offset + 2 + caches * 2 ]
503
498
argrepr = f"{ name } : { int .from_bytes (data , sys .byteorder )} "
@@ -586,9 +581,16 @@ def _disassemble_str(source, **kwargs):
586
581
587
582
def _unpack_opargs (code ):
588
583
extended_arg = 0
584
+ caches = 0
589
585
for i in range (0 , len (code ), 2 ):
586
+ # Skip inline CACHE entries:
587
+ if caches :
588
+ caches -= 1
589
+ continue
590
590
op = code [i ]
591
- if _deoptop (op ) >= HAVE_ARGUMENT :
591
+ deop = _deoptop (op )
592
+ caches = _inline_cache_entries [deop ]
593
+ if deop >= HAVE_ARGUMENT :
592
594
arg = code [i + 1 ] | extended_arg
593
595
extended_arg = (arg << 8 ) if op == EXTENDED_ARG else 0
594
596
# The oparg is stored as a signed integer
0 commit comments