- Notifications
You must be signed in to change notification settings - Fork 818
Strings: Add some interpreter support #6304
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits Select commit Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer that we not change this method (and that we eventually remove it entirely). Code is written assuming that
isData
has a particular meaning, and if that meaning changes over time, those assumptions can be broken. It is much better for clients of the type API to be precise about what kinds of types they are querying.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a form of data, though, isn't it? It's a reference to data (with a notion of how to read the raw data as well).
Maybe I'm not seeing what you are proposing, though: What did you have in mind?
Note that this one-line change would become a many-line change if we need to find the many places that currently have
isData()
and turn them intoisData() || isStringView()
- I started down that path and quickly decided to change course. But maybe there is another option?With that said, I do see your point that it's better when code locations have a precise meaning to what they use. But I don't think this changes that. I see 'isData' is meaning "is a reference to data"; concretely, all isData things are implemented by using the
data
field inLiteral
, so this is not arbitrary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried about callers assuming that
isData()
is a convenient shorthand forisStruct() || isArray()
, but lgtm for now if the fuzzer is happy. I still think it would be good to eventually do the larger NFC refactoring to eliminateisData()
entirely to mitigate that kind of risk. Do you think that is a reasonable thing to do as a future cleanup?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we could find a more descriptive name for
isData
that gives it clear semantics beyondisStruct() || isArray()
. Historically,isData
had clear semantics because it corresponded to subtypes of heap typedata
, but when we removeddata
we did not removeisData()
.isHeapAllocated
might be a good candidate, if somewhat verbose.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do feel there is a shared concept here, though? Again, it is all the types that use
Literal::gcData
, all the references to data. It is useful in our codebase to have a concept of all those things, because we need to test on them in all the places that useLiteral::gcData
. Otherwise each of those places would have "is struct or is array or is string or is stringView" which seems worse.Is it the name
data
that meant "struct or array" in the spec that feels wrong to you?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Our last comments raced, sorry mine isn't in response to yours.)
isHeapAllocated
could be shortened toisHeapType
😆 But yeah, this is kind of "data that is heap allocated", but in the stronger sense of our internals. i31 is a heap type but does not store itself usingLiteral::gcData
, so it isn't "heap allocated using Literal::gcData"... I'm not sure what the best name is here, but ignoring the history of the term, we haveLiteral::gcData
now so something with data or gcData seems right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i31 is never heap allocated (or at least, it shouldn't be), so it makes sense that it would be excluded from
isHeapAllocated
. It's much less clear that it should be excluded fromisData
!isHeapData
could work as well and is slightly shorter thanisHeapAllocated
.I would prefer that we not name something in the wasm-type.h API based on internal details of the
Literal
API, though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Ok, let's keep thinking about this, I sort of understand where you are coming from now but I don't yet see how best to move forward with a naming change.
You're ok with landing this for now, though? (It just adds stringview alongside string, so it doesn't change the meaning of isData in a meaningful way.)