-
Notifications
You must be signed in to change notification settings - Fork 37
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
[WIP] Apply &on-heap
selectively
#1781
Draft
rsmmr
wants to merge
5
commits into
main
Choose a base branch
from
topic/robin/on-heap
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rsmmr
force-pushed
the
topic/robin/on-heap
branch
from
August 9, 2024 07:14
05f7749
to
7b9fbd4
Compare
The parser generator is creating temporaries at a few places that will then later receive parsed values. Currently, those temporaries are always simply of the type being parsed. Turns out that works for units/structs only because we're always wrapping them into `value_ref`, meaning we can create those temporaries as null values. However, in a subsequent commit, we will get rid of those wrappings in some cases, meaning the structs would need to be default initialized at the time they are created on the stack. That doesn't work for some struct types though: if a struct receives parameters, we would need to pass them at instantiation time, but for these temporaries we don't know parameters at that point. So to prepare for the upcoming change, this commit wraps such temporary struct values into `optional<>` iff they receive parameters. (I have been wondering if we should generally wrap all these parser temporaries into optionals, independent of their type. Semantically that would make sense, but I'm guessing the C++ compiler gets better optimization opportunties if we don't.)
Previously, we would attach `&on-heap` to any `struct` compiled from a Spicy `unit`. Now we only attach it only for specific cases that need it, moving state to the stack otherwise.
For efficiency and consistency.
rsmmr
force-pushed
the
topic/robin/on-heap
branch
from
August 9, 2024 13:57
7b9fbd4
to
1acdf78
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In our generated C++ parsing code, so far we generally moved all units
to the heap. This PR changes that to do so only for cases where we
actually need it (primarily: if we wrap the unit into a reference
somewhere, or if the unit type is cyclic). The assumption is that this
should improve both performance and memory usage.
&on-heap
selectively only where needed.set
to anunordered_set
.