faster-cpython / ideas

1.67k stars 49 forks source link

Leave skipping of next instruction to the cases generator, or don't skip at all #572

Closed Fidget-Spinner closed 8 months ago

Fidget-Spinner commented 1 year ago

We have "secret" super instructions like CALL_NO_KW_LIST_APPEND, and BINARY_OP_INPLACE_ADD_UNICODE, and some of the FOR_ITER family.

We should either add the instruction pointer effect to the DSL, or get rid of these outright, as they make alternative interpreters harder to implement.

Fidget-Spinner commented 1 year ago

Related to https://github.com/python/cpython/issues/100982

gvanrossum commented 1 year ago

or get rid of these outright

Meaning get rid of the secret super-instructions? That seems problematic though (they exist for a reason). @Fidget-Spinner

To add instruction pointer effects to the DSL, we should have a default which behaves as the status quo. Maybe we could add keyword args to the DSL to make this and other options easier to add independently.

The main problem is that the generator tries to verify that all instructions in a family have the same stack and cache effects, and the secret super-instructions effectively violate the cache effect rule (since that's really the instruction pointer effect).

Maybe the solution is to have a "skip next instruction" flag that isn't considered part of the family effect.

markshannon commented 8 months ago

We've add the SKIP_OVER macro so that these skips are explicit and the INLINE_CACHE_ENTRIES_... entries are no longer used in bytecodes.c. So it should be easy to identify these "secret superiinstructions"