Skip to content

Flat closure - #69

Merged
bksaiki merged 13 commits into
mainfrom
flat-closure
May 2, 2024
Merged

bksaiki merged 13 commits into
mainfrom
flat-closure

Conversation

@bksaiki

@bksaiki bksaiki commented May 2, 2024

Copy link
Copy Markdown
Owner

This PR switches closures to a "flat" representation rather than "shared" representation. Every closure now contains all references to the free variables (all variables except arguments) required to complete the computation. The advantage is we need not represent the dynamic environment as a linked list of environment objects in exchange for having larger closure objects. When calling a closure, a new environment is allocated, the free variables are copied into the first slots, the arguments into the next, and any local variable is bound within remaining slots.

Future optimizations includes identifying variables that are temporally disjoint (they can share slots) and closure analysis to eliminate as many closure allocations as possible.

@bksaiki
bksaiki merged commit 357646a into main May 2, 2024
@bksaiki
bksaiki deleted the flat-closure branch May 2, 2024 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant