@@ -440,11 +440,7 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
440440 for i in range (start , end ):
441441 labels .add (target )
442442 starts_line = None
443- cache_counter = 0
444443 for offset , op , arg in _unpack_opargs (code ):
445- if cache_counter > 0 :
446- cache_counter -= 1
447- continue
448444 if linestarts is not None :
449445 starts_line = linestarts .get (offset , None )
450446 if starts_line is not None :
@@ -454,7 +450,6 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
454450 argrepr = ''
455451 positions = Positions (* next (co_positions , ()))
456452 deop = _deoptop (op )
457- cache_counter = _inline_cache_entries [deop ]
458453 if arg is not None :
459454 # Set argval to the dereferenced value of the argument when
460455 # available, and argrepr to the string representation of argval.
@@ -497,7 +492,7 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
497492 yield Instruction (_all_opname [op ], op ,
498493 arg , argval , argrepr ,
499494 offset , starts_line , is_jump_target , positions )
500- if show_caches and cache_counter :
495+ if show_caches and _inline_cache_entries [ deop ] :
501496 for name , caches in _cache_format [opname [deop ]].items ():
502497 data = code [offset + 2 : offset + 2 + caches * 2 ]
503498 argrepr = f"{ name } : { int .from_bytes (data , sys .byteorder )} "
@@ -586,9 +581,16 @@ def _disassemble_str(source, **kwargs):
586581
587582def _unpack_opargs (code ):
588583 extended_arg = 0
584+ caches = 0
589585 for i in range (0 , len (code ), 2 ):
586+ # Skip inline CACHE entries:
587+ if caches :
588+ caches -= 1
589+ continue
590590 op = code [i ]
591- if _deoptop (op ) >= HAVE_ARGUMENT :
591+ deop = _deoptop (op )
592+ caches = _inline_cache_entries [deop ]
593+ if deop >= HAVE_ARGUMENT :
592594 arg = code [i + 1 ] | extended_arg
593595 extended_arg = (arg << 8 ) if op == EXTENDED_ARG else 0
594596 # The oparg is stored as a signed integer
0 commit comments