Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
markshannon opened this issue Feb 25, 2022 Discussed in #297 · 2 comments
Closed

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

markshannon opened this issue Feb 25, 2022 Discussed in #297 · 2 comments
Assignees

Comments

@markshannon
Copy link
Member

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.

@markshannon markshannon self-assigned this Feb 25, 2022
@markshannon markshannon moved this from Todo to In Progress in Fancy CPython Board Feb 25, 2022
@markshannon markshannon moved this from In Progress to Todo in Fancy CPython Board Mar 2, 2022
@markshannon
Copy link
Member Author

Postponing this until inline caches are fully implemented. Then we can re-assess what changes would be worthwhile.

@markshannon
Copy link
Member Author

With relative branches, and better basic block layout, it looks like this is unnecessary.

Repository owner moved this from Todo to Done in Fancy CPython Board May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant