Skip to content

Make all jumps use a two "word" instruction format. #301

Closed
@markshannon

Description

@markshannon

Discussed in #297

Using inline caches has some nice advantages in terms of cache locality, and should get us a several percent speedup, but not if it makes all jumps slower due to extra EXTENDED_ARG instructions.

As an initial implementation, we will keep all the original jump instructions (including FOR_ITER) and just make them two "code units" long.
The second oparg be the low 8 bits of the jump. Jumps over 2**16 can use EXTENDED_ARG as before.

The change is simple, all jump instructions get this extra code at the start:

    oparg = (oparg<<8) | ((uint8_t *)next_instr)[1];
    next_instr++;

The compiler will need to account for the addition offset, but that should be simple.

We can then implement a more principled approach later. Ideally, for 3.11 if we have time.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions