Commit Graph

30 Commits

Author SHA1 Message Date
Bruce Mitchener
125270e2b0 Fix some typos. 2018-03-04 21:33:04 -08:00
Dan Gohman
81c126619b Ignore unknown custom wasm sections. 2018-02-26 15:24:25 -08:00
Jakob Stoklund Olesen
60c456c1ec Add a compilation pass timing facility.
Individual compilation passes call the corresponding timing::*()
function and hold on to their timing token while they run. This causes
nested per-pass timing information to be recorded in thread-local
storage.

The --time-passes command line option prints a pass timing report to
stdout.
2017-12-06 17:04:23 -08:00
Dan Gohman
ee0f061ee8 Rename "runtime" to "environment". 2017-10-18 16:55:32 -07:00
Dan Gohman
bd94a3b202 Move the 'data lifetime parameter to the ModuleEnvironment trait.
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.
2017-10-13 12:43:15 -07:00
Dan Gohman
733870aee4 Make FuncEnvironment independent from ModuleEnvironment (formerly WasmRuntime).
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.
2017-10-10 15:50:24 -07:00
Dan Gohman
d4c0c5babc Rename WasmRuntime's get_name to get_func_name. 2017-10-10 10:21:06 -07:00
Dan Gohman
653e8bb563 Declare exports via the WasmRuntime.
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.
2017-10-10 08:46:10 -07:00
Dan Gohman
2c9d03f9bd Let the runtime provide the number of imported functions.
This obviates the need to keep a separate running total of the number of
functions seen.
2017-10-09 17:29:39 -07:00
Dan Gohman
e74bc06380 Move start_index out of TranslationResult and into the WasmRuntime.
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.
2017-10-09 17:29:39 -07:00
Dan Gohman
ef5ad630c8 Use the WasmRuntime's global list rather than keeping a separate list. 2017-10-09 17:29:39 -07:00
Dan Gohman
3841552b7c Use the WasmRuntime's type list rather than keeping a separate list. 2017-10-09 17:29:39 -07:00
Dan Gohman
d1766f0ba4 Simplify code by removing unnecessary Options. 2017-10-06 15:59:30 -07:00
Dan Gohman
7410ddfe08 Use the WasmRuntime's signature list rather than keeping a separate list.
This way, if the runtime modifies the signature, such as to add special
arguments, they are reflected in the resulting function defintions.
2017-10-04 16:57:39 -07:00
Dan Gohman
de27abcb2b Change translate_module to use FuncTranslator. 2017-09-11 18:01:50 -07:00
Dan Gohman
7bf2747e1e Replace a match with a ?. 2017-09-11 08:47:41 -07:00
Dan Gohman
a2542ed71d Replace a match with a .unwrap_or_default(). 2017-09-11 08:47:38 -07:00
Jakob Stoklund Olesen
dc2bee9cef Add a FuncEnvironment::make_direct_func() callback.
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.
2017-09-06 12:36:19 -07:00
Jakob Stoklund Olesen
27e9e16077 Add a FuncEnvironment::make_indirect_sig() callback.
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.
2017-09-06 10:28:11 -07:00
Dan Gohman
bc528917fd Avoid redundant '@ _' in match patterns.
https://github.com/rust-lang-nursery/rust-clippy/wiki#redundant_pattern
2017-08-31 12:47:05 -07:00
Dan Gohman
a7d629c368 Use the Self keyword where applicable.
https://github.com/rust-lang-nursery/rust-clippy/wiki#use_self
2017-08-31 12:47:05 -07:00
Dan Gohman
da2c2151b1 Fix trivial_numeric_casts errors. 2017-08-31 12:47:05 -07:00
Dan Gohman
574031e4d2 Avoid unneeded passing by value.
https://github.com/rust-lang-nursery/rust-clippy/wiki#needless_pass_by_value
2017-08-31 12:47:05 -07:00
Dan Gohman
b6641ff443 Avoid clone() on a Copy type.
https://github.com/rust-lang-nursery/rust-clippy/wiki#clone_on_copy
2017-08-31 12:47:05 -07:00
Dan Gohman
acf4f1009b Eliminate redundant uses of format!.
https://github.com/rust-lang-nursery/rust-clippy/wiki#useless_format
2017-08-31 12:47:05 -07:00
Dan Gohman
2efdc0ed37 Update rustfmt to 0.9.0. 2017-08-31 10:44:59 -07:00
Dan Gohman
b2fcb1ad17 Change translate_module to use a slice rather than a borrowed Vec.
This makes it more convenient to call from a cargo-fuzz fuzzer.
2017-08-30 09:10:08 -07:00
Dan Gohman
5303e7708b Handle wasmparser errors gracefully. 2017-08-30 09:10:08 -07:00
Dan Gohman
f905dc914b Enable missing_docs errors in the wasm crate.
This adds `#![deny(missing_docs)]` to the wasm crate, and adds documentation
to several struct and enum fields, as needed.
2017-08-28 17:07:28 -07:00
Denis Merigoux
ee9989c4b9 Dumped code from the wasm2cretonne repo.
Integrated wasm test suite translation as cretonne test

Fixes #146.
Fixes #143.
2017-08-28 15:57:43 -07:00