Skip to content

Improvements to the dispatching logic in the interpreter #33

Closed
@markshannon

Description

@markshannon

No big ideas here. Just cleaning up the code around dispatching so it does less work and thus runs faster.

I don't expect to see much, if any, speed up on Linux, but Windows should gain parity (approximately) by allowing the compiler to combine the jumps.

  1. Move tracing logic out of fast dispatch path:
if (tracing_possible) {
    goto tracing_dispatch;
}
fetch_and_decode();
#ifdef COMPUTED
     goto *dispatch_table[opcode]
#else
     goto dispatch_opcode
#endif
  1. Remove anything between the label and the switch:
dispatch_opcode:
    switch(oparg) {

Which should allow the compiler to combine the goto and the computed jump.

We may need to generate cases for all undefined opcodes, so that the range check is guaranteed to be eliminated.

Metadata

Metadata

Assignees

Labels

3.11Things we intend to do for 3.11

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions