Commit Graph

328 Commits

Author SHA1 Message Date
Dan Gohman
9eba81a8d9 Update clippy settings and fix a few clippy warnings. 2019-01-07 14:48:02 -08:00
Dan Gohman
a7aee246e9 Pass declare_signature's argument by value.
`parse_type_section` doesn't need the value after passing it, and this
allows callees to avoid cloning if they need their own copy.
2019-01-07 13:42:00 -08:00
Dan Gohman
13138b65f7 Call the new ModuleEnvironment reserve functions. 2019-01-07 13:42:00 -08:00
Dan Gohman
6ec0b3c6bf Add a comment. 2019-01-07 13:42:00 -08:00
Dan Gohman
7120633363 Change the elems parameter of declare_table_elements to a boxed slice.
Implementations that want a full `Vec` can use `into_vec` to convert it
back.
2019-01-07 13:42:00 -08:00
Dan Gohman
054e6fcf07 Add functions to ModuleEnvironment to support reserving buffers up front.
These default to doing nothing, but implementations can override them to
preallocate buffers.

Also, reorder the functions in `ModuleEnvironment` to more closely
reflect the sequence from the WebAssembly module layout.
2019-01-07 13:42:00 -08:00
Dan Gohman
7f250e340c Simplify ModuleEnvironment.
Remove some unneeded functions, and remove the `GlobalInit` special case
for data and elem initializer offsets; implementations that want that
information can provide it for themselves.
2019-01-07 13:42:00 -08:00
Benjamin Bouvier
c78a9a4a7c Bump log and file-per-thread-logger; 2019-01-03 12:14:39 -08:00
Dan Gohman
cd4f96c066 Use Vec::with_capacity when we know the eventual size of the Vec. 2019-01-02 11:59:57 -08:00
Muhammad Mominul Huque
effe6c04e4 Update to Rust 2018 edition (#632)
* initial cargo fix run

* Upgrade cranelift-entity crate

* Upgrade bforest crate

* Upgrade the codegen crate

* Upgrade the faerie crate

* Upgrade the filetests crate

* Upgrade the codegen-meta crate

* Upgrade the frontend crate

* Upgrade the cranelift-module crate

* Upgrade the cranelift-native crate

* Upgrade the cranelift-preopt crate

* Upgrade the cranelift-reader crate

* Upgrade the cranelift-serde crate

* Upgrade the cranelift-simplejit crate

* Upgrade the cranelift or cranelift-umbrella crate

* Upgrade the cranelift-wasm crate

* Upgrade cranelift-tools crate

* Use new import style on remaining files

* run format-all.sh

* run test-all.sh, update Readme and travis ci configuration
fixed an AssertionError also

* Remove deprecated functions
2018-12-26 09:49:05 -08:00
Bruce Mitchener
4f8753fa11 Fix typos. 2018-12-24 10:03:22 -08:00
Bruce Mitchener
4224a95f0d Update wasmparser to 0.23. 2018-12-24 09:49:06 -08:00
Dan Gohman
998a7d2b6d Mention Wasmtime as a complete implementation of the Environment traits. 2018-12-24 09:32:20 -08:00
Dan Gohman
bee4ee4b6e Clarify that cranelift-wasm is just one component.
For a complete WebAssembly implementation, see Wasmtime.
2018-12-13 06:03:28 -08:00
Dan Gohman
c8e457e834 Bump version to 0.26.0 2018-12-11 12:54:23 -08:00
Dan Gohman
bc18085ad1 Use EntityRef::from_u32 to reduce casting. 2018-12-11 15:40:24 -05:00
Dan Gohman
a55c933f19 Factor out a MemFlags constructor for trusted notrap/aligned accesses. 2018-12-11 15:40:24 -05:00
Dan Gohman
7b51195f49 Add an offset to cranelift-wasm's GlobalVariable. 2018-12-11 15:40:24 -05:00
Dan Gohman
30a0890319 Rename GlobalInit::GlobalRef to GlobalInit::GetGlobal.
"Ref" is an increasingly overloaded term.
2018-12-11 15:40:24 -05:00
Dan Gohman
38d1d58e06 Change GlobalInit::Import() to GlobalInit::Import. 2018-12-11 15:40:24 -05:00
Dan Gohman
6e17bebf44 Publish TableElementType for library users. 2018-12-11 15:40:24 -05:00
Dan Gohman
f0dbba0ec8 Change TableElementType::Func() to TableElementType::Func. 2018-12-11 15:40:24 -05:00
Dan Gohman
91477d21c8 Add an as_u32() member to entity_impl types.
This allows us to avoid a lot of casting indices back to u32.
2018-12-11 15:40:24 -05:00
Dan Gohman
954573440d Remove ModuleEnvironment::get_func_name, which is unused. 2018-12-11 15:40:24 -05:00
Dan Gohman
a20c852148 Support heaps with no offset-guard pages.
Also, say "guard-offset pages" rather than just "guard pages" to describe the
region of a heap which is never accessible and which exists to support
optimizations for heap accesses with offsets.

And, introduce a `Uimm64` immediate type, and make all heap fields use
`Uimm64` instead of `Imm64` since they really are unsigned.
2018-12-11 15:40:24 -05:00
Dan Gohman
5d7ece3d15 Fix clippy warning namespaces. 2018-12-06 20:50:38 -05:00
Dan Gohman
5adab629f2 Update to the rustfmt in rust 1.31, which is now stable. 2018-12-06 16:15:48 -05:00
Dan Gohman
416f8c094d Name Table and Memory's initial field minimum and make it u32.
The spec has switched to calling the "initial" field the "minimum" field
because when linear memory is imported, it may initially be greater than
the "initial" value.

Making it u32 instead of usize will help avoid accidental host-specific
behavior.
2018-11-29 15:03:49 +01:00
Dan Gohman
30654a6a7d Bump version to 0.25.0 2018-11-26 22:31:07 -08:00
Dan Gohman
09e5b33916 Update to wasmparser 0.22. 2018-11-26 22:18:36 -08:00
Dan Gohman
f6a6ce3199 Make ModuleEnvironment's target_config() return by value.
This makes it more consistent with the other target_config() functions
which were all changed to return by value.
2018-11-26 22:18:36 -08:00
Dan Gohman
c17579e7ec Bump version to 0.24.0 2018-11-26 22:18:36 -08:00
Syrus Akbary
737fde04a8 Improved imports (#612)
* Impoved support for wasm global imports

* Refactored parse_import_section improving readability

* Improved support for wasm table imports

* Improved support for wasm memory imports

* Improved formatting

* Added DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex structs
2018-11-25 05:10:58 -08:00
Dan Gohman
14dfc0d1b6 Bump version to 0.23.0. 2018-11-07 16:18:04 -08:00
Dan Gohman
38e8667f97 Adjust whitespace to match the upstream exception text.
This is a whitespace-only change.
2018-11-07 16:07:51 -08:00
Dan Gohman
b476f823d4 Update to target_lexicon 0.2.0. 2018-11-07 16:01:15 -08:00
Dan Gohman
5ea6c57b95 Update to the new wasmparser and port to the new readers API.
The new wasmparser API provides dedicated reader types for each section
type, which significantly simplifies the code.

This also changes WasmError::from_binary_reader_error into a From
trait so that we don't have to do .map_err(from_binary_reader_error)
throughout the code.
2018-11-06 15:54:17 -08:00
Dan Gohman
9e084dbadc Update to wabt 0.7.0. 2018-11-06 13:24:45 -08:00
Dan Gohman
3ff8867e57 Split the default edge of a br_table.
When splitting critical edges for a br_table to handle arguments being
passed, split the default edge along with the normal table edges.
2018-11-06 15:53:05 +01:00
Dan Gohman
d4f8eb7453 Introduce a TargetFrontendConfig type. (#570)
* Introduce a `TargetFrontendConfig` type.

`TargetFrontendConfig` is information specific to the target which is
provided to frontends to allow them to produce Cranelift IR for the
target. Currently this includes the pointer size and the default calling
convention.

The default calling convention is now inferred from the target, rather
than being a setting. cranelift-native is now just a provider of target
information, rather than also being a provider of settings, which gives
it a clearer role.

And instead of having cranelift-frontend routines require the whole
`TargetIsa`, just require the `TargetFrontendConfig`, and add a way to
get the `TargetFrontendConfig` from a `Module`.

Fixes #529.
Fixes #555.
2018-11-02 13:51:42 -07:00
Dan Gohman
2de5542139 Make FuncEnvironment::return_mode() default to NormalReturns.
`NormalReturns` is what we expect most users will normally want.
2018-10-29 15:37:08 +01:00
Dan Gohman
bf569b70dc Make cranelift-wasm's type_to_type easier to optimize. 2018-10-26 11:24:43 -07:00
Boris-Chengbiao Zhou
b288c6001a Fix all clippy warnings (#564)
* Fix all clippy warnings

* Revert usage of inclusive ranges

* Remove redundant function argument

* Revert use of unavailable pointer methods

* Introduce ContiguousCaseRange
2018-10-22 21:52:35 -07:00
Lachlan Sneff
586a8835e9 Add a readonly flag for loads (#562)
* Add readonly MemFlag

* Add readonly flag verifier check

* Make global loads readonly

* Fix gvn to consider readonly loads
2018-10-22 21:50:09 -07:00
Dan Gohman
8cd1b87917 Rename parse_elements_section.
In WebAssembly documentation, it's the "element" section.
2018-10-19 10:59:32 -07:00
oooooba
709eed21c1 Use types to represent wasm global/table/memory/signature indices (#560)
* 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.
2018-10-19 10:49:41 -07:00
Dan Gohman
7f90414ae1 Update no_std support. 2018-10-05 17:18:40 -07:00
Dan Gohman
bf041e3ae2 Move return_at_end out of Settings and into the wasm FuncEnvironment. (#547)
* Move `return_at_end` out of Settings and into the wasm FuncEnvironment.

The `return_at_end` flag supports users that want to append a custom
epilogue to Cranelift-produced functions. It arranges for functions to
always return via a single return statement at the end, and users are
expected to remove this return to append their code.

This patch makes two changes:
 - First, introduce a `fallthrough_return` instruction and use that
   instead of adding a `return` at the end. That's simpler than having
   users remove the `return` themselves.

 - Second, move this setting out of the Settings and into the wasm
   FuncEnvironment. This flag isn't something the code generator uses,
   it's something that the wasm translator uses. The code generator
   needs to preserve the property, however we can give the
   `fallthrough_return` instruction properties to ensure this as needed,
   such as marking it non-cloneable.
2018-10-05 06:43:22 -07:00
Dan Gohman
ddf8fd23b5 Remove obsolete TODO comments. 2018-10-03 13:09:44 -07:00
Tyler McMullen
79cea5e18b Implement jump tables (#453)
* Add 'jump_table_entry' and 'indirect_jump' instructions.

* Update CodeSink to keep track of code size. Pretty up clif-util's disassembly output.

* Only disassemble the machine portion of output. Pretty print the read-only data after it.

* Update switch frontend code to use new br_table instruction w/ default.
2018-10-03 10:04:21 -07:00