-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-44032: Move data stack to thread from FrameObject. #26076
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
65349e5
Remove 'zombie' frames. We won't need them once we are allocating fix…
markshannon c1ac3ef
Add co_nlocalplus field to code object to avoid recomputing size of l…
markshannon 431e1cb
Move locals, cells and freevars out of frame object into separate mem…
markshannon 24a77d8
Use per-threadstate allocated memory chunks for local variables. Dumb…
markshannon 19ac31a
Make per-thread data-stack a contiguous block of memory.
markshannon 2d1a9db
Add comments about data stack sizes.
markshannon 73c49d5
Use chunked stack, allows larger stack when needed with reduced memor…
markshannon 8a9ae01
Delete obsolete comment and debug print statements
markshannon 5a4803c
Move globals and builtins from frame object to per-thread stack.
markshannon a555393
Move (slow) locals frame object to per-thread stack.
markshannon f238598
Add back comment.
markshannon 6cab045
Fix limit when popping block from data stack.
markshannon 89f9496
Tidy up frame creation a bit.
markshannon 0091341
Improve function name
markshannon 2c14939
Make sure datastack memory is freed after fork.
markshannon ed93a22
Fix compiler warnings.
markshannon 9204189
Add NEWS item
markshannon 4e60017
Move internal frame functions to internal header.
markshannon 7c53a6f
Fix compiler warning
markshannon 61c3753
Add missing comment.
markshannon c5ccb7d
Add comment about what _PyObject_VirtualAlloc does.
markshannon 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef Py_INTERNAL_FRAME_H | ||
#define Py_INTERNAL_FRAME_H | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
enum { | ||
FRAME_SPECIALS_GLOBALS_OFFSET = 0, | ||
FRAME_SPECIALS_BUILTINS_OFFSET = 1, | ||
FRAME_SPECIALS_LOCALS_OFFSET = 2, | ||
FRAME_SPECIALS_SIZE = 3 | ||
}; | ||
|
||
static inline PyObject ** | ||
_PyFrame_Specials(PyFrameObject *f) { | ||
return &f->f_valuestack[-FRAME_SPECIALS_SIZE]; | ||
} | ||
|
||
/* Returns a *borrowed* reference. */ | ||
static inline PyObject * | ||
_PyFrame_GetGlobals(PyFrameObject *f) | ||
{ | ||
return _PyFrame_Specials(f)[FRAME_SPECIALS_GLOBALS_OFFSET]; | ||
} | ||
|
||
/* Returns a *borrowed* reference. */ | ||
static inline PyObject * | ||
_PyFrame_GetBuiltins(PyFrameObject *f) | ||
{ | ||
return _PyFrame_Specials(f)[FRAME_SPECIALS_BUILTINS_OFFSET]; | ||
} | ||
|
||
int _PyFrame_TakeLocals(PyFrameObject *f); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* !Py_INTERNAL_FRAME_H */ |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Core and Builtins/2021-05-14-20-03-32.bpo-44032.OzT1ob.rst
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Move 'fast' locals and other variables from the frame object to a per-thread | ||
datastack. |
This file contains hidden or 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
Oops, something went wrong.
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.
FWIW, I've been calling this
co_nfastlocals
in my branches.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.
But it isn't all "fast" locals, as there are cells as well. Admittedly,
co_nlocalsplus
isn't a great name either.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.
"fastlocals" is what we already call them in ceval.c.