Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
65349e5c1ac3ef431e1cb24a77d819ac31a2d1a9db73c49d58a9ae015a4803ca555393f2385986cab04589f949600913412c14939ed93a2292041894e600177c53a6f61c3753c5ccb7dFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -20,12 +20,9 @@ enum _framestate { | ||
| typedef signed char PyFrameState; | ||
| struct _frame { | ||
| PyObject_VAR_HEAD | ||
| PyObject_HEAD | ||
| struct _frame *f_back; /* previous frame, or NULL */ | ||
| PyCodeObject *f_code; /* code segment */ | ||
| PyObject *f_builtins; /* builtin symbol table (PyDictObject) */ | ||
| PyObject *f_globals; /* global symbol table (PyDictObject) */ | ||
| PyObject *f_locals; /* local symbol table (any mapping) */ | ||
| PyObject **f_valuestack; /* points after the last local */ | ||
| PyObject *f_trace; /* Trace function */ | ||
| /* Borrowed reference to a generator, or NULL */ | ||
| @@ -36,7 +33,8 @@ struct _frame { | ||
| PyFrameState f_state; /* What state the frame is in */ | ||
| char f_trace_lines; /* Emit per-line trace events? */ | ||
| char f_trace_opcodes; /* Emit per-opcode trace events? */ | ||
| PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ | ||
| char f_own_locals_memory; /* This frame owns the memory for the locals */ | ||
| PyObject **f_localsptr; /* Pointer to locals, cells, free */ | ||
ericsnowcurrently marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| }; | ||
| static inline int _PyFrame_IsRunnable(struct _frame *f) { | ||
| @@ -62,7 +60,7 @@ PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *, | ||
| /* only internal use */ | ||
| PyFrameObject* | ||
| _PyFrame_New_NoTrack(PyThreadState *, PyFrameConstructor *, PyObject *); | ||
| _PyFrame_New_NoTrack(PyThreadState *, PyFrameConstructor *, PyObject *, PyObject **); | ||
| /* The rest of the interface is specific for frame objects */ | ||
| 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 */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -94,6 +94,11 @@ struct _PyTraceMalloc_Config { | ||
| PyAPI_DATA(struct _PyTraceMalloc_Config) _Py_tracemalloc_config; | ||
| /* Allocate memory directly from the O/S virtual memory system, | ||
| * where supported. Otherwise fallback on malloc */ | ||
| void *_PyObject_VirtualAlloc(size_t size); | ||
| void _PyObject_VirtualFree(void *, size_t size); | ||
markshannon marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| #ifdef __cplusplus | ||
| } | ||
| 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. |
Uh oh!
There was an error while loading. Please reload this page.
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_nfastlocalsin 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_nlocalsplusisn'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.