* Use a type to represent wasm table indices.
* Use a type to represent wasm global variable indices.
* Use a type to represent wasm memory indices.
* Use a type to represent wasm signature indices.
* Use PrimaryMap instead of Vec to protect against using wrong indices.
* Update to rustfmt-preview.
* Run "cargo fmt --all" with rustfmt 0.4.1.
rustfmt 0.4.1 is the latest release of rustfmt-preview available on the
stable channel.
* Fix a long line that rustfmt 0.4.1 can't handle.
* Remove unneeded commas left behind by rustfmt.
Define `WasmError` (and an accompanying `WasmResult`) to represent
errors translating WebAssembly functions. Make `translate_call` and
related functions return `WasmResult`s so that embedders have the
flexibility to reject features they don't support.
Move `InvalidInput` out of `CtonError` and into `WasmError`, where it's
now named `InvalidWebAssembly`, as it's a WebAssembly-specific error
condition. Also extend it to preserve the original error message and
bytecode offset.
Add a calling-convention setting to the `Flags` used as part of the
`TargetIsa`. This allows Cretonne code that generates calls to use the
correct convention, such as when emitting libcalls during legalization
or when the wasm frontend is decoding functions. This setting can be
overridden per-function.
This also adds "fast", "cold", and "fastcall" conventions, with "fast"
as the new default. Note that "fast" and "cold" are not intended to be
ABI-compatible across Cretonne versions.
This will also ensure Windows users will get an `unimplemented!` rather
than silent calling-convention mismatches, which reflects the fact that
Windows calling conventions are not yet implemented.
This also renames SpiderWASM, which isn't camel-case, to Baldrdash,
which is, and which is also a more relevant name.
To keep cross-compiling straightforward, Cretonne shouldn't have any
behavior that depends on the host. This renames the "Native" calling
convention to "SystemV", which has a defined meaning for each target,
so that it's clear that the calling convention doesn't change
depending on what host Cretonne is running on.
Merge the `use` parts of the `no_std` branch. This reduces the diffs
between master and the `no_std` branch, making it easier to maintain.
Most of these changes are derived from patches by @lachlansneff in
https://github.com/Cretonne/cretonne/tree/no_std.
Rename the ArgumentType type to AbiParam since it describes the ABI
characteristics of a parameter or return value, not just the value type.
In Signature, rename members argument_types and return_types to "params"
and "returns". Again, they are not just types.
Fix a couple lingering references to "EBB arguments".
This is needed to allow implementations to have 'data-lifetime
references if they choose to. The DummyEnvironment is an example of an
implementation that doesn't choose to.
This renames WasmRuntime to ModuleEnvironment, and makes several changes
to allow for more flexible compilation.
ModuleEnvironment no longer derives from FuncEnvironment, and no longer
has the `begin_translation` and `next_translation` functions, so that
independent `FuncEnvironment` instances can operate within the same
module.
Also, this obviates the rest of TranslationResult, as it moves processing
of function bodies into the environment. The DummyEnvironment implementation
gives an example of decoding the function bodies as they are parsed, however
other implementation strategies are now possible.
Also, redo how functions are named in the DummyRuntime. Use the FunctionName
field to just encode the wasm function index rather than trying to shoehorn
a printable name into it. And to make up for that, teach the wasm printer
to print export names as comments next to the function definitions.
This also makes the fields of DummyRuntime public, in preparation for
the DummyRuntime to have a more general-purpose debugging role, as well
as possibly to allow it to serve as a base for other implementations.
This makes it more consistent with how all the rest of the content of
a wasm module is handled. And, now TranslationResult just has a Vec
of translated functions, which will make it easier to refactor further.
wasmparser's API is changing in anticipation of streaming decoding, so
it will now hand large data section initializers back in chunks rather
than all at once.
This allows the environment to control the signatures used for direct
function calls. The signature and calling convention may depend on
whether the function is imported or local.
Also add WasmRuntime::declare_func_{import,type} to notify the runtime
about imported and local functions. This is necessary so the runtime
knows what function indexes are referring to .
Since imported and local functions are now declared to the runtime, it
is no longer necessary to return hashes mapping between WebAssembly
indexes and Cretonne entities.
Also stop return null entries for the imported functions in the
TranslationResult. Just return a vector of local functions.
The function environment is now expected to keep track of the function
signatures in the module, and it is asked to generate Cretonne
signatures to be used for indirect calls.
The combination of make_indirect_sig() and translate_call_indirect()
callbacks allow the runtime to insert additional function arguments for
indirect calls such as vmctx pointers and CFI-style signature identifiers.