mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
bpo-46409: Make generators in bytecode (GH-30633)
* Add RETURN_GENERATOR and JUMP_NO_INTERRUPT opcodes. * Trim frame and generator by word each. * Minor refactor of frame.c * Update test.test_sys to account for smaller frames. * Treat generator functions as normal functions when evaluating and specializing.
This commit is contained in:
parent
d05a66339b
commit
b04dfbbe4b
18 changed files with 236 additions and 205 deletions
|
@ -41,12 +41,12 @@ typedef struct _interpreter_frame {
|
|||
PyObject *f_locals; /* Strong reference, may be NULL */
|
||||
PyCodeObject *f_code; /* Strong reference */
|
||||
PyFrameObject *frame_obj; /* Strong reference, may be NULL */
|
||||
PyObject *generator; /* Borrowed reference, may be NULL */
|
||||
struct _interpreter_frame *previous;
|
||||
int f_lasti; /* Last instruction if called */
|
||||
int stacktop; /* Offset of TOS from localsplus */
|
||||
PyFrameState f_state; /* What state the frame is in */
|
||||
bool is_entry; // Whether this is the "root" frame for the current CFrame.
|
||||
bool is_generator;
|
||||
PyObject *localsplus[1];
|
||||
} InterpreterFrame;
|
||||
|
||||
|
@ -100,10 +100,10 @@ _PyFrame_InitializeSpecials(
|
|||
frame->f_locals = Py_XNewRef(locals);
|
||||
frame->stacktop = nlocalsplus;
|
||||
frame->frame_obj = NULL;
|
||||
frame->generator = NULL;
|
||||
frame->f_lasti = -1;
|
||||
frame->f_state = FRAME_CREATED;
|
||||
frame->is_entry = false;
|
||||
frame->is_generator = false;
|
||||
}
|
||||
|
||||
/* Gets the pointer to the locals array
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue