Skip to content

Conversation

markshannon
Copy link
Member

Adds a de-sugaring pass that converts:

inst(LOAD_FAST, (-- value)) {
    value = GETLOCAL(oparg);
    assert(value != NULL);
    Py_INCREF(value);
}

into

op(_LOAD_FAST, (-- value)) {
    value = GETLOCAL(oparg);
    assert(value != NULL);
    Py_INCREF(value);
}
macro(LOAD_FAST) = _SAVE_CURRENT_IP + _LOAD_FAST

and converts occurrences of _SAVE_CURRENT_IP to SAVE_IP offset for the tier 2.

@markshannon
Copy link
Member Author

Fails with the error: AssertionError: Push or pop above current stack level: stack_pointer[0] when generating the code for LOAD_FAST_CHECK.

@gvanrossum
Copy link
Member

What problem are you trying to solve here? It would seem to be purely a problem of the structure of the code generator, because the "translation table" (_PyOpcode_opcode_metadata in pycore_opcode_metadata.h) already treats everything as a macro.

I don't quite follow what you're trying to do with _SAVE_CURRENT_IP.

@markshannon
Copy link
Member Author

I'm trying to make the semantics and behavior of each instruction completely explicit in the IR.

It keeps the back ends simpler, which is an overall improvement, as we have only one front-end, but many back ends.

We already have the following back-ends and we may get more:

  • Tier 1 interpreter generator
  • Ancillary table generator
  • Tier 2 interpreter generator
  • Abstract interpreter generator
  • Copy-and-patch stencil generator.

Each of these tools needs to understand the implicit conventions.
If nothing is implicit, they become much simpler.

@gvanrossum
Copy link
Member

gvanrossum commented Sep 11, 2023

Let me take this and try to make it work, without including the SAVE_CURRENT_IP at the start of the generated macros.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants