-
Notifications
You must be signed in to change notification settings - Fork 2
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
Rearrange the handling of constant slices. #73
Merged
Merged
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
String slices and ordinary array slices are still special cases, but they're now handled like references: they contain a def_id that points to an allocation, which for constants is a static allocation holding the body. Previously they were handled like values and contained an inline copy of the actual data. This makes them come out in Crucible as global references rather than (magic) constant references; the latter do not support operations that are needed in practice. See saw-script #2064. The special cases for bstr are removed; they're no longer needed. It's probable that at least the body-data special cases for slices are no longer needed either, but one thing at a time.
RyanGlScott
reviewed
Aug 23, 2024
spernsteiner
approved these changes
Aug 23, 2024
Remove some entirely unused functions flagged by the compiler.
Use the "array" output kind. The code to generate slice bodies is still different from the general array case, though. None of this is true of _string_ slice bodies, whose elements fields are just lists of character values. That should probably stay that way to avoid bloating out large string constants.
(even though the logic is the same) Add a note to this effect.
- expand some comments - get a better name for make_static_ref - adjust some other names for clarity - assert if we hit a nonzero reference output (instead of silently emitting bad code)
(on the reference side, the bodies of strings are still special-cased) Advice from those much more familiar with things is that the representation of strings is not likely to diverge from [u8].
06351b5
to
ced2a9f
Compare
I force-pushed to squash the second silence-warnings commit into the first one, and to squash the leftover comment change into the commit that it should have been in. No actual change. |
RyanGlScott
approved these changes
Aug 26, 2024
This was referenced Aug 26, 2024
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.
The idea is to split the slice into a reference and a separate static allocation for the body the reference points to. This then allows downstream code to treat the references as normal references to memory, which in turn avoids problems in SAW that arise when it goes to try to enforce disjointness.
Requires accompanying changes in Crucible so that crucible-mir can read and process the new output. (These changes are in crucible #1243.)
See saw-script #2064 for background.