-
Notifications
You must be signed in to change notification settings - Fork 699
Description
I have been thinking a lot on how to add testing to the Branch Hinting proposal,
and in general to annotations and custom section based proposals (like the Annotations proposal
and the Instrument and Tracing Technology proposal), and to a feature present in
the MVP itself but not currently tested: the name section.
The main issue with testing these features is that an implementation is allowed to
ignore annotations and custom sections, even if malformed, and they cannot affect the
semantics of the module.
By discussing about it in various CG meetings and in private, I believe that we need
to achieve the following:
-
The reference interpreter should have a special mode that enables the parsing
and validation of known annotations and custom sections, and should be able to round trip
them between text and binary format. -
a separate set of tests is run in this special mode, allowing the testing of these features
-
We don't expect engines, or even most implementations to add such special mode,
so passing these tests is optional. The test cases themseslves can still be useful to
understand what is allowed and what not, and to be integrated in the engine/tool test
suite in a manual way. -
Given the above, the test runner should have itself a command line option to
enable/disable these tests (not sure what the default should be, but the CI should
run them)
I have a proof of concept that satisfies the above requirements and adds support
in the interpreter and tests for the @custom annotation specified in the Annotations proposal.
If the CG likes the approach I can similarly implement branch hinting (I started with
@custom because validation is simpler).
The proof of concept is in this branch of the branch hinting repo, but I will rebase it
on top of the annotations repo and make a PR there if people like this approach.
I am very interested in feedback about this, and eager to adapt the PoC to additional
requirements.
I also welcome feedback on the OCaml code. This is the first time I use it and
the code is probably not idiomatic.
Features added to the interpreter:
- new command line switch
-cthat enables annotations and custom sections handling - text parsing and text output of
@customannotations - binary encoding and decoding of custom sections
- proper roundtrip of custom sections when converting to text and back, via custom annotations
- same but starting from custom annotations in text
Features added to tests/core/run.py:
- new command line switch
--customthat adds tests in thecustomdirectory
to the list of tests to run - logic to pass the
-cflag to the interpreter for tests inside thecustomdirectory
Related past issues: WebAssembly/annotations#15 , WebAssembly/branch-hinting#13 , #1424 , WebAssembly/spec#1341