This repository was archived by the owner on Apr 25, 2025. It is now read-only.
array_init_elem on dropped element segment #577
Answered
by
rossberg
CharlieTap
asked this question in
Q&A
|
At the end of the wast script for array_init_elem there's these two tests, I'm unsure how the second test should pass if the first test drops the element it needs? ;; init_data/elem with dropped segments traps for non-zero length
(assert_return (invoke "drop_segs"))
(assert_return (invoke "array_init_elem" (i32.const 0) (i32.const 0) (i32.const 0))) |
Answered by
rossberg
Dec 21, 2024
Replies: 1 comment 1 reply
|
Semantically, dropping a segment shrinks its size to zero, so a zero-length bulk op at offset 0 still succeeds (modulo null references). In this case, see the execution rule, steps 20-21. This behaviour is inherited from prior bulk ops like table.init and memory.init, though I cannot find corresponding tests for those with a quick search. The original motivation for this semantics is that the drop check becomes subsumed by the bounds check this way, so that an extra runtime check is avoided. This PR links to some of the history of bulk op boundary conditions. |
1 reply
Answer selected by
CharlieTap
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Semantically, dropping a segment shrinks its size to zero, so a zero-length bulk op at offset 0 still succeeds (modulo null references). In this case, see the execution rule, steps 20-21.
This behaviour is inherited from prior bulk ops like table.init and memory.init, though I cannot find corresponding tests for those with a quick search.
The original motivation for this semantics is that the drop check becomes subsumed by the bounds check this way, so that an extra runtime check is avoided. This PR links to some of the history of bulk op boundary conditions.