Currently we go through a two stage process to get to the adaptive form of instructions.
The explanation below uses CALL, but it applies to all specializable instructions.
- When unmarshaling the code object we create the bytecode
CALL, oparg, 0, 0, 0 ... where the zeros are the cache.
- When executing, check a counter and quicken when that counter reaches zero.
- When quickening, replace all
CALLs with CALL_ADAPTIVEs.
Instead we should quicken when unmarshaling, so that we create:
(CALL_ADAPTIVE oparg)
7 # uint16_t not byte pair
...
instead of
The marshaled form only needs one byte for instructions without an oparg and two for other instructions. No space is needed for the cache.
Currently we go through a two stage process to get to the adaptive form of instructions.
The explanation below uses
CALL, but it applies to all specializable instructions.CALL, oparg, 0, 0, 0 ...where the zeros are the cache.CALLs withCALL_ADAPTIVEs.Instead we should quicken when unmarshaling, so that we create:
instead of
The marshaled form only needs one byte for instructions without an oparg and two for other instructions. No space is needed for the cache.