Skip to content

Refactor initialisation of frame headers into a single function #100758

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

Closed
iritkatriel opened this issue Jan 4, 2023 · 0 comments · Fixed by #100759
Closed

Refactor initialisation of frame headers into a single function #100758

iritkatriel opened this issue Jan 4, 2023 · 0 comments · Fixed by #100759
Assignees
Labels
type-feature A feature request or enhancement

Comments

@iritkatriel
Copy link
Member

iritkatriel commented Jan 4, 2023

There are 3 places in the code where we prepare a frame for execution:

  1. _PyFrame_PushUnchecked in pycore_frame.h
  2. init_frame in frameobject.c
  3. _PyEvalFramePushAndInit in ceval.c

All of these call the function _PyFrame_InitializeSpecials to set values from the code object to various fields on the frame. Two of them (2 and 3 above) also NULL the localsplus array.

When we will change the frame layout for the register machine, currently we need to update those three places. But if we add NULLing the locals to _PyFrame_InitializeSpecials (and rename it to something clearer) then we can just make our changes there.

There isn't really a problem with NULLing the localsplus in _PyFrame_PushUnchecked - all the call sites follow up by setting some fields and NULLing the rest. So now we will NULL all fields and overwrite a few after returning from _PyFrame_InitializeSpecials. Will benchmark to make sure.

(Lesson learned from the register machine experiment).

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment