-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
bpo-45256: Don't track the exact depth of each InterpreterFrame
#30372
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2713a36
Stop tracking the exact depth of each frame
brandtbucher 439a0c2
Clean up comment
brandtbucher 6037cba
Fix test for sizeof(frame)
brandtbucher 323da04
Fix test for sizeof(generator)
brandtbucher 1ab3a8f
Catch up with main
brandtbucher 98c58f3
Apply suggestions from code review
brandtbucher 369983b
Don't bother unsetting frame->is_entry
brandtbucher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
extern "C" { | ||
#endif | ||
|
||
#include <stdbool.h> | ||
|
||
|
||
/* runtime lifecycle */ | ||
|
||
|
@@ -44,7 +46,7 @@ typedef struct _interpreter_frame { | |
int f_lasti; /* Last instruction if called */ | ||
int stacktop; /* Offset of TOS from localsplus */ | ||
PyFrameState f_state; /* What state the frame is in */ | ||
int depth; /* Depth of the frame in a ceval loop */ | ||
bool own_cframe; // Whether this is the "root" frame for the current CFrame | ||
PyObject *localsplus[1]; | ||
} InterpreterFrame; | ||
|
||
|
@@ -101,7 +103,7 @@ _PyFrame_InitializeSpecials( | |
frame->generator = NULL; | ||
frame->f_lasti = -1; | ||
frame->f_state = FRAME_CREATED; | ||
frame->depth = 0; | ||
frame->own_cframe = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should default to |
||
} | ||
|
||
/* Gets the pointer to the locals array | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 entryInterpreterFrame
for_PyEval_EvalFrameDefault
.If you think ownership is a better mental model, then
owns_cframe
is fine.There was a problem hiding this comment.
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
orcframe_backed
instead?There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 opinionThere was a problem hiding this comment.
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...