Add support for non-nullable tables and init expressions#8405
Add support for non-nullable tables and init expressions#8405pufferfish101007 wants to merge 44 commits intoWebAssembly:mainfrom
Conversation
I don't see these changes in shared.py, can we add them? |
Uses American spelling and clarify that the breaking change is only in the C API Co-authored-by: Steven Fontanella <steven.fontanella@gmail.com>
This reverts commit a33eae8. Reason for revert: storing 0x40 as a uint32_t breaks comparison with the int32_t
Might not work... pushing so CI can check
Also update expected elem section output due to the module now having two tables.
|
Looks good from my side. I'll let @tlively have the final review. Thanks for the contribution! |
|
@stevenfontanella thank you for such a thorough review! |
|
Thanks for the additional comments! I've addressed the easy fixes and probably won't have time to address the others for a week or so (but I'll try to do so as soon as possible to keep momentum going). I will aim to add fuzzer support now, so that this doesn't come back to bite me later on. A question: |
|
The way the lit tests work is that you write the module (or modules) and the RUN lines at the top saying how the test should execute. The filecheck command in those run lines compares its input against the expected output in the CHECK comments in the file. (There may be other check prefixes as well.) After you write the RUN lines and the input, the script can generate the expected output in the CHECK lines. You can put multiple input modules in the same wast file if the RUN line uses the foreach tool. I recommend copying the RUN lines and general structure from other recent tests in the same directory. You can run specific new tests with bin/binaryen-lit -vv path/to/test.wast. |
…on-nullable-table
|
Fuzzer support has been added (with room for improvements still, but it's already thrown up a bug). That's caused a test to fail though, with |
…on-nullable-table
Yes and yes 👍 |
|
I've run the fuzzer 10159 times with no problems, so hopefully everything that needs to be updated has been. |
stevenfontanella
left a comment
There was a problem hiding this comment.
LGTM, will let Thomas have the last look!
|
|
||
| if (table->init) { | ||
| bool hasNonImported = false; | ||
| for ([[maybe_unused]] auto* get : FindAll<GlobalGet>(table->init).list) { |
There was a problem hiding this comment.
Looks like it is used and the [[maybe_unused]] attribute isn't needed
Resolves #5628
Adds support for non-nullable tables with init expressions. I'm not totally sure how I should go about adding new tests, but manual test cases are below. I have also unignored previously ignored spec tests
instance.wast,ref_is_null.wast,table.wast,i31.wast,global.wastwhich now all pass. I have also changed the reason for ignoringarray.wastas it does not (and has not in the past, AFAICT) rely on non-nullable table types.This introduces a breaking change in the C api, as it adds an extra argument to
addTable. Is this ok? Should a new method be added instead? (e.g.addTableWithInit?)Manual tests
click to expand
The validation ones might overlap with the spec tests. Unchecked boxes indicate tests that currently fail.Correctly fails with
[wasm-validator error in module] unexpected false: tables with non-nullable types require an initializer expression, on tableCorrectly fails with
[wasm-validator error in module] init expression must be a subtype of the table type, on (i32.const 0)Correctly fails with
[wasm-validator error in module] init expression must be a subtype of the table type, on (i32.const 0)wasm-optdoesn't remove init expr as dead codeTODO:
dummy PR for CI tests to run automatically: pufferfish101007#2