Commit Graph

288 Commits

Author SHA1 Message Date
Erin Power
5426e42a27 Revert "Remove FunctionBuilderContext from API, and change FunctionBuilder API"
This reverts commit 39e638af99dbe6537bc935bfb1a74669b62877b3.
2019-09-17 08:58:46 +02:00
Andrew Brown
f1363168a9 Translate the sign-extended and zero-extended versions of extract_lane 2019-09-10 10:45:12 -07:00
julian-seward1
63367d205c Fix #975 (Structure of cranelift-wasm/src/translation_utils.rs causes many pointless heap allocations) (#1010)
This patch restricts the `Err(..)` return from `blocktype_to_type` to be
`Err(..)` only in the case where it really is an error to continue.  The three
use points of `blocktype_to_type` are changed to check for an `Err(..)` rather
than silently ignoring it.  There are also cosmetic changes to `type_to_type`
and `tabletype_to_type`.

When compiling wasm_lua_binarytrees, this reduces the number of blocks
allocated by CL by 1.9%.  Instruction count falls by 0.1%.

Details:

* `type_to_type` and `tabletype_to_type`:

   - Added the function name in the failure message

   - No functional change for non-error cases

   - Push the `Ok(..)` to expression leaves, where it really applies.  This
     corrects the misleading impression that, in the case of an unsupported
     type, the function returns `Ok` wrapped around whatever
     `wasm_unsupported` returns.  It doesn't do that, but it certainly reads
     like that.  This assumes that the LLVM backend will do tail merging, so
     the generated code will be unchanged.

* `blocktype_to_type`:

  - Change return type from `WasmResult<ir::Type>` to `WasmResult<Option<ir::Type>>`

  - Manually inline the call to `type_to_type`, to make this function easier
    to read.

  - For the non-error case: map `TypeOrFuncType::Type(Type::EmptyBlockType)`
    to `Ok(None)` rather than `Err(..)`, since that's what all the call sites
    expect - For the error cases, add the function name in the failure
    messages

* cranelift-wasm/src/code_translator.rs

  - For the three uses of `blocktype_to_type`, use `?` to detect failures and
    drop out immediately, meaning that the code will no longer silently ignore
    errors.
2019-09-10 15:06:10 +02:00
data-pup
ac2ca6116b allow module environment to parse name section 2019-09-10 11:30:54 +02:00
Alex Crichton
705bfacf10 rustfmt 2019-09-07 16:20:23 -07:00
Alex Crichton
dfda794f55 Add a custom section hook to ModuleEnvironment
This commit adds a hook to the `ModuleEnvironment` trait to learn when a
custom section in a wasm file is read. This hook can in theory be used
to parse and handle custom sections as they appear in the wasm file
without having to re-iterate over the wasm file after cranelift has
already parsed the wasm file.

The `translate_module` function is now less strict in that it doesn't
require sections to be in a particular order, but it's figured that the
wasm file is already validated elsewhere to verify the section order.
2019-09-07 16:20:23 -07:00
Aaron Power
8fd1128990 Remove FunctionBuilderContext from API, and change FunctionBuilder API 2019-09-07 14:43:07 -07:00
Pat Hickey
89d741f8ae upgrade to target-lexicon 0.8.0
* the target-lexicon crate no longer has or needs the std feature
  in cargo, so we can delete all default-features=false, any mentions
  of its std feature, and the nostd configs in many lib.rs files
* the representation of arm architectures has changed, so some case
  statements needed refactoring
2019-09-04 15:12:17 -07:00
Andrew Brown
c595acfd0d Convert constants added by v128.const to the appropriate type before use
By default, constants added by SIMD's v128.const will be typed as I8x16 in CLIF. This type must be changed to the appropriate vector type before use to satisfy cranelift's type checking. To do this, we track what SSA values are created by v128.const and convert them with a raw_bitcast immediately before use in the currently implemented SIMD instructions.
2019-08-26 16:12:06 -07:00
Andrew Brown
cb041407c1 Translate existing WASM SIMD operations to CLIF 2019-08-26 16:12:06 -07:00
Dan Gohman
0c2c597852 Update to latest versions of term, capstone, wabt, goblin, wasmparser. 2019-08-20 14:18:14 -07:00
Joshua Nelson
bf77985e25 Fix broken links using rustdoc nightly
Uses cross-crate documentation links so that rustdoc does the hard work
of making relative links for us.

Requires nightly version of rustdoc in order to generate links based on
path names, see
https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md
for details.
2019-08-19 11:48:37 +02:00
Carmen Kwan
19257f80c1 Add reference types R32 and R64
-Add resumable_trap, safepoint, isnull, and null instructions
-Add Stackmap struct and StackmapSink trait

Co-authored-by: Mir Ahmed <mirahmed753@gmail.com>
Co-authored-by: Dan Gohman <sunfish@mozilla.com>
2019-08-16 11:35:16 -07:00
Adam C. Foltzer
73670aab43 Return a WasmResult from ModuleEnvironment methods (#886)
* [wasm] return a WasmResult from `declare_table_elements`

This method in particular needs to accommodate failure because any table index other than zero is
currently invalid.

* [wasm] additional failure handling improvements

- Adds `WasmResult<()>` as the return type for most of the `ModuleEnvironment` methods that
previously returned nothing.

- Replaces some panics with `WasmError::Unsupported` now that the methods can return a result.

- Adds a `wasm_unsupported!()` macro for early returns with a formatted unsupported message.
2019-08-07 13:23:32 -07:00
iximeow
3d42753535 add VisibleTranslationState for a public-friendly interface 2019-07-31 12:15:51 +02:00
Andy Wortman
b5cb8556f6 [wasm] Pass translation state along for before/after_translate_operator callbacks (#879) 2019-07-30 16:32:50 +02:00
laizy
5ca13a70a5 check no other sections after data section 2019-07-29 18:41:33 +02:00
Artur Jamro
09ec0d4149 Derive Hash for some types 2019-07-27 06:23:03 -05:00
Sean Stangl
be36cc6538 Generate basic blocks for wasm if..then..else. 2019-07-25 11:04:02 -06:00
Andy Wortman
b7a9d65458 cranelift-wasm hooks to instrument wasm operators (#861)
* cranelift-wasm hooks to instrument wasm operators
2019-07-25 09:36:17 -07:00
Sean Stangl
926e4c8bf8 Generate basic blocks for Wasm br_if. 2019-07-23 07:58:57 -06:00
Sean Stangl
ffa9d315e6 Add some comments to the frontend code. 2019-07-23 07:58:57 -06:00
Artur Jamro
9e884b4433 Add support for some serde serialization (#847)
* Add support for some serde serialization
2019-07-12 15:30:50 -07:00
Benjamin Bouvier
f6ac165ff6 [wasm] Don't panic when seeing unexpected types but properly fail instead; 2019-07-03 14:46:23 +02:00
Dan Gohman
f163050c9a Update to wasmparser 0.32.1. 2019-07-02 11:59:06 -07:00
Dan Gohman
ccd77c1d0b Update to wasmparser 0.31.0 and goblin 0.0.22. 2019-06-28 15:23:54 +02:00
data-pup
a08444c4c6 fix sections translator doc comment 2019-06-27 17:04:12 -07:00
Benjamin Bouvier
d7d48d5cc6 Add the dyn keyword before trait objects; 2019-06-24 11:42:26 +02:00
Dan Gohman
da1baf7481 Use try_from instead of the cast crate.
Now that `try_from` is in stable Rust, we can use it here.
2019-06-03 12:40:58 +02:00
Takanori Ishibashi
f427a2b923 Fix url in comments 2019-05-28 13:29:45 +02:00
Benjamin Bouvier
a0ddbf403c [wasm] Have the WasmError::User member be a String; 2019-05-14 18:34:16 +02:00
Yury Delendik
8f95c51730 Reconstruct locations of the original source variable 2019-05-09 00:35:44 -07:00
Benjamin Bouvier
443e48aee1 [wasm] Raise an error instead of panicking for unhandled function local types; 2019-04-30 13:58:18 +02:00
Benjamin Bouvier
3ce5d2057d [wasm] Add the ability to provide a user-defined error; 2019-04-30 13:58:18 +02:00
Benjamin Bouvier
02e114cf3d [wasm] Make FuncEnvironment functions fallible (fixes #752); 2019-04-30 13:58:18 +02:00
Dan Gohman
6b85df0168 Update to wasmparser 0.29.2. 2019-03-26 09:06:41 -07:00
Yury Delendik
27b0933a4a Preserve global wasm module offset in SourceLoc. 2019-03-05 14:51:40 +01:00
lazypassion
747ad3c4c5 moved crates in lib/ to src/, renamed crates, modified some files' text (#660)
moved crates in lib/ to src/, renamed crates, modified some files' text (#660)
2019-01-28 15:56:54 -08:00