3 ms·
This is just a reflection from recent work on interpreter internals, but I figured it could be relevant to someone walking the same paths. Allocating registers
by sifoobar 8y ago
This is just a reflection from recent work on interpreter internals, but I figured it could be relevant to someone walking the same paths.
Allocating registers for all local vars statically means scopes have different sizes, which in turn complicates slab allocation and/or reuse. In return for being easier to reason about (except for the main scope issue) and saving space.
I opted for a fixed number of linearly assigned registers per scope in Snigl [0]; once the limit is reached, remaining variables are stored in a table. Which means I sort of get both, since additional scopes may be added using {} (it could make sense to add a scope: keyword to Python) if that becomes an issue.
It's all compromises, all the way down.
[0] https://gitlab.com/sifoo/snigl https://gitlab.com/sifoo/snigl