Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate allocating all nodes on the Arena #15

Open
matklad opened this issue Apr 9, 2019 · 0 comments
Open

Investigate allocating all nodes on the Arena #15

matklad opened this issue Apr 9, 2019 · 0 comments

Comments

@matklad
Copy link
Member

matklad commented Apr 9, 2019

Currently, each green node is allocated on the heap, which helps to be incremental. However, the bulk of files are parsed only once, so it should be cool to have a non-incremental mode as well, where the whole tree is allocated in a bump-allocator.

SyntaxNode/GreenNode setup allows us to do just that! We can have a setup like this

SyntaxRoot {
    green: GreenNode | Vec<GreenData>
}

struct SyntaxNode {
    green: *const GreenData
}

type GreenNode = Arc<GreenData>;

The details need to be figured out: ideally, green nodes should always be clone, SyntaxNodes should not do any mode checks when getting green node, and there should only be a single "flag" for incremental mode in the root of the tree.

My gut feeling is that we'll need some kind of shared_from_this unsafe setup here, such that we arena-allocate GreenNodeData, store pointers to GreenNodeData in SyntaxNodes, store pointers to GreenNodeData in the children array in GreenNodeData, but, in case of green node, we know that pointer actually is to Arc<GreenNodeData>.

We should use https://github.com/fitzgen/bumpalo for arena of GreenData

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant