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

Interpreter code generators need to be able to handle basic flow control #123391

Closed
Tracked by #120024
markshannon opened this issue Aug 27, 2024 · 0 comments · Fixed by #124392
Closed
Tracked by #120024

Interpreter code generators need to be able to handle basic flow control #123391

markshannon opened this issue Aug 27, 2024 · 0 comments · Fixed by #124392
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@markshannon
Copy link
Member

markshannon commented Aug 27, 2024

In order to be able to flush the stack efficiently around escaping calls, the interpreter code generators need to be able to handle simple-ish flow control.

For example, in this code:

  op(_CHECK_PERIODIC, (--)) {
      if (_Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) {
          int err = _Py_HandlePending(tstate);
          ERROR_IF(err != 0, error);
      }
  }

The general shape is:

    if (cond) {
        *escaping_call()*
    }

We want to be able to track the flow control so that we can spill around the call, but not on the fast path:

   if (cond) {
        SPILL_STACK();
        *escaping_call()*
        RELOAD_STACK();
    }

We cannot currently do this.

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants