Open overlookmotel opened 2 months ago
We should probably store Semantic
in a separate arena from AST itself, so AST remains compact in memory.
oxc_allocator::Allocator
could contain both arenas:
struct Allocator {
ast_arena: bumpalo::Bump,
semantic_arena: bumpalo::Bump,
}
Semantic
's data structures seem like a good candidate for arena allocation - lots of small structures built in a short space of time and then dropped simultaneously (much like the AST itself).Semantic<'a>
already has a lifetime, so moving the data into arena would not affect ergonomics of API.The one downside of the arena allocator is that
Vec
s never grow in place, they always reallocate and are copied when they grow beyond capacity, because bumpalo packs data tightly and grows downwards.This problem could be largely ameliorated if:
ScopeTree
'sVec
s with required capacity at the start, so they never need to grow.Additional benefits: