Fix trapping and dangling insts in memory packing#2540
Merged
aheejin merged 2 commits intoWebAssembly:masterfrom Dec 19, 2019
Merged
Fix trapping and dangling insts in memory packing#2540aheejin merged 2 commits intoWebAssembly:masterfrom
aheejin merged 2 commits intoWebAssembly:masterfrom
Conversation
This does two things: - Restore `visitDataDrop` handler deleted in WebAssembly#2529, but now we convert invalid `data.drop`s to not `unreachable` but `nop`. This conforms to the revised spec that `data.drop` on the active segment can be treated as a nop. - Now `visitMemoryInit` does the same thing; its handling was missing in WebAssembly#2529. It drops all its arguments. Fixes WebAssembly#2535.
tlively
reviewed
Dec 19, 2019
| builder.makeDrop(curr->offset), | ||
| builder.makeDrop(curr->size), | ||
| builder.makeUnreachable())); | ||
| builder.makeDrop(curr->size))); |
Member
There was a problem hiding this comment.
This still needs to trap if offset or size are not equal to 0 or if the dest address is out of bounds. I'm actively working on my MemoryPacking patch again, but in the interim changing this code to the following should make the code correct again.
// trap if (dest > memory.size | offset | size) != 0
replaceCurrent(builder.makeIf(
builder.makeBinary(
OrInt32,
builder.makeBinary(
GtUInt32, curr->dest, builder.makeHost(MemorySize, Name(), {})),
builder.makeBinary(OrInt32, curr->offset, curr->size)),
builder.makeUnreachable()));
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
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.
This does two things:
visitDataDrophandler deleted in Implement 0-len/drop spec changes in bulk memory #2529, but now we convertinvalid
data.drops to notunreachablebutnop. This conforms tothe revised spec that
data.dropon the active segment can be treatedas a nop.
visitMemoryInittrap if offset or size are not equal to 0 or ifthe dest address is out of bounds. Otherwise drop all its argument.
Fixes #2535.