-
Notifications
You must be signed in to change notification settings - Fork 40
Generalize test generators for table.copy and table.init to multi-table #84
Conversation
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.
One question about element/table index order, but otherwise lgtm. (I also tested these with wabt and all the tests passed there too)
|
||
for ( let table of [0, 1] ) { | ||
// Passive init that overwrites all-null entries | ||
tab_test(`(table.init $t${table} 1 (i32.const 7) (i32.const 0) (i32.const 4))`, |
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.
We recently clarified in the binary format that elem index comes before table index. Seems like we'll want to do the same for the text format too? If so, we may want to do that before landing this change.
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 to keep this as an oddity of the binary format. For the human-readable text form (and the AST) it's nicer if init matches the dst-src parameter order of copy and the operands of other instructions.
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.
(Why was this switched in the first place?)
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.
My guess is that, since the table/memory index was always 0, it made sense to put it at the end (e.g. similar to call_indirect
)
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.
FWIW, I agree with @rossberg re the operand order in the text format.
One thing that annoys me about the text format though is that in the elem segment I must write (table $t)
while in call_indirect, table.copy, table.init, etc, I can only write $t. If the text format would admit disambiguating syntax it could also admit a more flexible operand order: (table.init (elem 1) (table $t) ...)
. Something for another day perhaps.
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.
Hm, that would be piggybacking on the wrong thing, since that syntax would only happen to work where the immediates are of different sort, e.g. not table.copy. Moreover, for various instructions, src and dst are denoted by a combination of immediates and stack operands, and their order is supposed to match.
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 agree that's true for the order of the table operands. It's still annoying that the syntax is non-uniform, but it's just a hobbyhorse - not a problem to solve here.
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.
Oops, sorry, missed this.
Thanks!
* Remove passive segment func ref shorthand * Drop passive keyword
Fixes #74.