Skip to content

Conversation

@brandtbucher
Copy link
Member

@brandtbucherbrandtbucher commented Jan 3, 2022

We only really care whether or not an exiting frame is the "root" of the current CFrame, which a boolean value can track more efficiently.

(In fact, the current code is buggy, and doesn't even maintain frame->depth correctly... it's only ever set to 0 or 1 anyways!)

https://bugs.python.org/issue45256

Copy link
Member

@pablogsalpablogsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

intstacktop; /* Offset of TOS from localsplus */
PyFrameStatef_state; /* What state the frame is in */
intdepth; /* Depth of the frame in a ceval loop */
boolown_cframe; // Whether this is the "root" frame for the current CFrame
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this name.

I don't think the frame really owns the C frame. Also, be wary of using CFrame, as CFrame is a struct name.
If I were to suggest a name, it would be is_entry as this is the entry InterpreterFrame for _PyEval_EvalFrameDefault.
If you think ownership is a better mental model, then owns_cframe is fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markshannon Can it be named backed_by_cframe or cframe_backed instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has nothing to do with how the data is stored.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Mark, I think it should be called entry_frame or something similar. Reasoning about ownership is a bit more obscure in my opinion

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping somebody would suggest a better name! is_entry it is...

frame->f_lasti=-1;
frame->f_state=FRAME_CREATED;
frame->depth=0;
frame->own_cframe=true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should default to false. Then it only need be set at the start of _PyEval_EvalFrameDefault, not for every internal call.

Copy link
Member

@markshannonmarkshannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of minor issues, but sound in general.

@bedevere-bot
Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@brandtbucher@bedevere-bot@arhadthedev@markshannon@pablogsal@the-knights-who-say-ni