Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial wast support for components (#529)
* Remove `ItemRef::Outer`. * Remove `ItemRef::exports`. * Remove pre-component-model nested-module and nested-instance support. * Parsing for the new component model spec. Remove tests/local/deep.wastfor now; that'll need to be adapted. * Add a testsuite. * Factor out code common to modules and components. * Change the modulearg/componentarg form of `import` to `with`. * Rename `ComponentType` to `ComponentTypeField`. * Rename `ComponentModuleType` to `ComponentType`. This more closely matches the AST documentation. * Parsing, encoding, and resolution for all intertypes. * Disable the parse-component.rs tests for now. * Delete `peek4`, which didn't end up being needed. * Make `expand_type_use` set `visited` to true. Previously, visited was getting set by the aliases pass. That's been removed, as it was primarily supporting the old module linking implementation. So now we need to set `visited` for types that have already been expanded. * Guard `visited` with `#[cfg(wast_check_exhaustive)]`. * Fix syntax. * Move parsing of the opening '(' out of several `parse` functions. * Revise the lookahead for `ModuleArg` and `ComponentArg`. This avoids needed to define an `RParen` that can be peeked for. * Reuse the existing `Namespace` rather than having a separate copy. * Implement `Encode` for `Component`. * Fix the type of `aliases`. * Set type uses' `visited` fields. It was previously being set by the aliases pass, but that's removed now. So now make sure it's set for all type uses. * Fully remove the process_imports_early mechanism. * Implement outer-name lookup. * Encoding for canon.lower and canon.lift. * Put components support behind a cargo feature. * Revert "Put components support behind a cargo feature." This reverts commit d446204. * wip * More resolution of merge conflicts * Fix more tests * Start running tests * Simplify the testing harness This commit aims to simplify the test harness as it has grown quite complicated over the years. The original intention was to simplify insertion of component handling into the wast test harness and it snowballed into some other improvements first that I wanted to get out of the way. Namely here the improvements are: * All `*.wasm` files are removed from the test suite. They're either translated to `*.wat` or `*.wast` files since the `module binary` form can encode any binary (with comments) as well. * The difference between `AssertMalformed` and `AssertInvalid` is removed and the same arm now handles both of these directives. Perhaps one day in the spec test suite these meant something different but nowadays the tests seem inconsistent enough that there's no clear distinction between the two (e.g. the error "must happen in this phase" vs another). In general I don't think precisely where an error pops up is too important and we already have a few cases of divergence, so as long as things are rejected with the right error message I figure it's ok. * The `match` for wast directives is now exhaustive to ensure handling of any new directives that are added. * The `WastDirective::QuoteModule` directive is merged directly into `WastDirective::Module`. Additionally `QuoteModule` now has a helper `encode` method to avoid the need to actually match on the module itself and delegate appropriately (e.g. the parsing is baked into the `wast` crate now. * Support for `*.txt` tests are removed since this is a vestige of wabt-based testing. * Support for tests with `invalid` in the name are removed now that they're all transitioned to `*.wast` tests and can use the normal testing harness. Overall I'm hoping that this will make it easier to replace the `module` argument of `assert_malformed` and `assert_invalid` with a `Wat` perhaps, and similarly replacing the `Module` directive with `Wat` or something like that too. That way the test harness here won't need any changes to update for components since by-and-large the testing simply takes an input, encodes it, and then tests the result or the error that pops out. * Represent modules in `*.wast` as `Wat` structures This will make it easier to slot in component support since `Wat` will have a variant that uses components. * Move some panics to TODO errors * More progress on getting very-nested.wast to pass * More work to getting bits and bobs implemented * Improve the `dump` implementation w.r.t. imports and printed names * More things going through resolution all the way * Expansion of inline imports/exports as well as type uses * A few `*.dump` tests being added testing expansion * Remove inner `id` fields from types Instead use the name of the type within the definition source, and manage the stack in the `TypeField` resolution * Get `a.wast` test passing * Get some of import.wast and string.wast passing * Reimplement outer aliases * Refactor the loop to avoid duplicate work in a few locations * Configure the `id` of the injected `Alias` so it's automatically registered with the name so multiple outer aliases to the same name only inject one outer alias. * Fix a bug where the index resolved was the outer component's index, not the index of the new alias in the current scope. * wasmparser: enforce effective type size limits for validation. This commit reintroduces the effective type size limit in the validator that existed with the prior module linking proposal. With the limit enforced, an upper bound is placed on how much work the validator will do when performing subtype checks. This also fixes type, import, and export limit enforcement in module, component, and instance types. Fixes #580. * Fix error message on very-nested * More tests working with the component model * Implement alias desugaring * Get some more tests passing * Get types.wast passing * Tweak parsing for the string test a bit * Fix some doc links * Fix benchmark for the component model * Get alias.wast test workign * Get intertype.wast working * "Fix" the module-link.wast test * Get start.wast working again I am not really certain what the syntax for the `(start)` function should be but this seems to be at least a reasonable-ish starting point * "Fix" virtualize.wast for now * Fix some features * Fix a missing expansion * Undo some changes in the `wat` crate * Remove the nascent `component-model` feature I don't think this will be necessary any more * Fix merge conflict * Uncomment a fixed test * Handle some miscellaneous items here and there * Add FIXME issues to all TODOs * Remove name support in the binary encoding for components to get re-added at a later date. * Remove `ComponentArg::Type` as there are no tests. I don't know what this is for and it can be re-added if necessary. * Change some `todo!` macros to `unreachable!` as they should legitimately never be hit. * Update tests for the fix of #586 * Remove some dead code * Review comments Co-authored-by: Alex Crichton <alex@alexcrichton.com> Co-authored-by: Peter Huene <phuene@fastly.com>
- Loading branch information