Skip to content

Store Semantic data in arena #31

@overlookmotel

Description

@overlookmotel

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 Vecs 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:

  • Parser counts number of scopes, symbols and references during parsing.
  • Initialize ScopeTree's Vecs with required capacity at the start, so they never need to grow.

Additional benefits:

  • Storing semantic data in arena makes it available in JS via AST transfer (for building e.g. linter rules / transform plugins in JS).
  • Ditto for Deserializable ast nodes oxc#3079 (if we want to do that)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions