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

Delay function body parsing. #905

Merged
merged 1 commit into from
Oct 7, 2023
Merged

Delay function body parsing. #905

merged 1 commit into from
Oct 7, 2023

Conversation

dvander
Copy link
Member

@dvander dvander commented Oct 5, 2023

This patch skips parsing function bodies, instead caching tokens and attaching the token stream to the AST. After the AST is built, functions are parsed using cached tokens. This is fairly easy to do thanks to the recent Lexer/SourceManager refactoring.

This is a critical step toward collapsing the binding and semantic passes together, without re-introducing a dreaded reparse phase.

A quick estimate shows that memory use on this is pretty small. For funcommands.sp (the biggest plugin in the test suite), it's about 200KB. This is again thanks to the recent refactoring. Tokens are now 24 bytes instead of 96 bytes.

Duplicating the AST would use about 3MB since the AST is so unoptimized, and culling that down is a big project.

This patch skips parsing function bodies, instead caching tokens and
attaching the token stream to the AST. After the AST is built, functions
are parsed using cached tokens. This is fairly easy to do thanks to the
recent Lexer/SourceManager refactoring.

This is a critical step toward collapsing the binding and semantic
passes together, without re-introducing a dreaded reparse phase.

A quick estimate shows that memory use on this is pretty small. For
funcommands.sp (the biggest plugin in the test suite), it's about 200KB.
This is again thanks to the recent refactoring. Tokens are now 24 bytes
instead of 96 bytes.

Duplicating the AST would use about 3MB since the AST is so unoptimized,
and culling that down is a big project.
@dvander dvander merged commit f139c13 into master Oct 7, 2023
31 checks passed
@dvander dvander deleted the sema2 branch October 7, 2023 03:52
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