Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
review comments
  • Loading branch information
iritkatriel committed Jun 26, 2024
commit 56c223d0bd266919aea0395415ba3af48b83cd9f
17 changes: 2 additions & 15 deletions InternalDocs/frames.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ of reference, most frames are allocated contiguously in a per-thread stack
(see ``_PyThreadState_PushFrame`` in
[Python/pystate.c](https://github.com/python/cpython/blob/main/Python/pystate.c)).

Frames of generators and coroutines are allocated on the heap, embedded in the
generator and coroutine objects. See ``PyGenObject`` in
Frames of generators and coroutines are embedded in the generator and coroutine
objects, so are not allocated in the per-thread stack. See ``PyGenObject`` in
[Include/internal/pycore_genobject.h](https://github.com/python/cpython/blob/main/Include/internal/pycore_genobject.h).

## Layout
Expand Down Expand Up @@ -50,19 +50,6 @@ as the arguments on the stack are (usually) already in the correct
location for the parameters. However, it requires the VM to maintain
an extra pointer for the locals, which can hurt performance.

A variant that only needs two pointers is to reverse the numbering
of the locals, so that the last one is numbered `0`, and the first in memory
is numbered `N-1`.
This allows the locals, specials and linkage to accessed from the frame pointer.
We may implement this in the future.

#### Note:

> In a contiguous stack, we would need to save one fewer registers, as the
> top of the caller's activation record would be the same as the base of the
> callee's. However, since some activation records are kept on the heap we
> cannot do this.

### Generators and Coroutines

Generators and coroutines contain a `_PyInterpreterFrame`
Expand Down