Skip to content

Commit

Permalink
Merge branch 'master' into fix-runtime-c-api-1314
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan authored Mar 27, 2020
2 parents baeeea1 + 531ec45 commit 2276d16
Show file tree
Hide file tree
Showing 19 changed files with 1,340 additions and 1,348 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## **[Unreleased]**

- [#1335](https://github.com/wasmerio/wasmer/pull/1335) Change mutability of `memory` to `const` in `wasmer_memory_data_length` in the C API
- [#1329](https://github.com/wasmerio/wasmer/pull/1329) New numbers and strings instructions for WIT
- [#1332](https://github.com/wasmerio/wasmer/pull/1332) Add option to `CompilerConfig` to force compiler IR verification off even when `debug_assertions` are enabled. This can be used to make debug builds faster, which may be important if you're creating a library that wraps Wasmer and depend on the speed of debug builds.
- [#1320](https://github.com/wasmerio/wasmer/pull/1320) Change `custom_sections` field in `ModuleInfo` to be more standards compliant by allowing multiple custom sections with the same name. To get the old behavior with the new API, you can add `.last().unwrap()` to accesses. For example, `module_info.custom_sections["custom_section_name"].last().unwrap()`.
- [#1303](https://github.com/wasmerio/wasmer/pull/1303) NaN canonicalization for singlepass backend.
- [#1292](https://github.com/wasmerio/wasmer/pull/1292) Experimental Support for Android (x86_64 and AArch64)
Expand Down
19 changes: 14 additions & 5 deletions lib/clif-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,27 @@ fn get_isa(config: Option<&CompilerConfig>) -> Box<dyn isa::TargetIsa> {
builder.set("opt_level", "speed_and_size").unwrap();
builder.set("enable_jump_tables", "false").unwrap();

if cfg!(test) || cfg!(debug_assertions) {
builder.set("enable_verifier", "true").unwrap();
} else {
builder.set("enable_verifier", "false").unwrap();
}
let enable_verifier: bool;

if let Some(config) = config {
if config.nan_canonicalization {
builder.set("enable_nan_canonicalization", "true").unwrap();
}
enable_verifier = config.enable_verification;
} else {
// Set defaults if no config found.
// NOTE: cfg(test) probably does nothing when not running `cargo test`
// on this crate
enable_verifier = cfg!(test) || cfg!(debug_assertions);
}

builder
.set(
"enable_verifier",
if enable_verifier { "true" } else { "false" },
)
.unwrap();

let flags = settings::Flags::new(builder);
debug_assert_eq!(flags.opt_level(), settings::OptLevel::SpeedAndSize);
flags
Expand Down
16 changes: 8 additions & 8 deletions lib/clif-backend/src/trampoline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Trampolines {
let sig_index = module.func_assoc[*exported_func_index];
let func_sig = &module.signatures[sig_index];

let trampoline_func = generate_func(&func_sig);
let trampoline_func = generate_func(isa, &func_sig);

ctx.func = trampoline_func;

Expand Down Expand Up @@ -150,13 +150,13 @@ impl Trampolines {

/// This function generates a trampoline for the specific signature
/// passed into it.
fn generate_func(func_sig: &FuncSig) -> ir::Function {
let trampoline_sig = generate_trampoline_signature();
fn generate_func(isa: &dyn isa::TargetIsa, func_sig: &FuncSig) -> ir::Function {
let trampoline_sig = generate_trampoline_signature(isa);

let mut func =
ir::Function::with_name_signature(ir::ExternalName::testcase("trampln"), trampoline_sig);

let export_sig_ref = func.import_signature(generate_export_signature(func_sig));
let export_sig_ref = func.import_signature(generate_export_signature(isa, func_sig));

let entry_ebb = func.dfg.make_block();
let vmctx_ptr = func.dfg.append_block_param(entry_ebb, ir::types::I64);
Expand Down Expand Up @@ -211,8 +211,8 @@ fn wasm_ty_to_clif(ty: Type) -> ir::types::Type {
}
}

fn generate_trampoline_signature() -> ir::Signature {
let call_convention = super::get_isa(None).default_call_conv();
fn generate_trampoline_signature(isa: &dyn isa::TargetIsa) -> ir::Signature {
let call_convention = isa.default_call_conv();
let mut sig = ir::Signature::new(call_convention);

let ptr_param = ir::AbiParam {
Expand All @@ -227,8 +227,8 @@ fn generate_trampoline_signature() -> ir::Signature {
sig
}

fn generate_export_signature(func_sig: &FuncSig) -> ir::Signature {
let call_convention = super::get_isa(None).default_call_conv();
fn generate_export_signature(isa: &dyn isa::TargetIsa, func_sig: &FuncSig) -> ir::Signature {
let call_convention = isa.default_call_conv();
let mut export_clif_sig = ir::Signature::new(call_convention);

let func_sig_iter = func_sig.params().iter().map(|wasm_ty| ir::AbiParam {
Expand Down
97 changes: 46 additions & 51 deletions lib/interface-types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,57 +41,52 @@ binary.

## Instructions

Very basically, WebAssembly Interface Types defines a set of
instructions, used by adapters to transform the data between
WebAssembly core and the outside world ([learn
Very basically, WebAssembly Interface Types defines a [set of
instructions](https://github.com/WebAssembly/interface-types/blob/master/proposals/interface-types/working-notes/Instructions.md),
used by adapters to transform the data between WebAssembly core and
the outside world ([learn
mode](https://github.com/WebAssembly/interface-types/blob/master/proposals/interface-types/Explainer.md)).

Here is the instructions that are implemented:
Here is the instructions that are implemented by this crate:

| Instruction | WAT encoder | Binary encoder | WAT decoder | Binary decoder | Interpreter |
|-|-|-|-|-|-|
| `arg.get` ||||||
| `call-core` ||||||
| `memory-to-string` ||||||
| `string-to-memory` ||||||
| `call-adapter` ||||||
| `defer-call-core` ||||||
| `i32-to-s8` ||||||
| `i32-to-s8x` ||||||
| `i32-to-u8` ||||||
| `i32-to-s16` ||||||
| `i32-to-s16x` ||||||
| `i32-to-u16` ||||||
| `i32-to-s32` ||||||
| `i32-to-u32` ||||||
| `i32-to-s64` ||||||
| `i32-to-u64` ||||||
| `i64-to-s8` ||||||
| `i64-to-s8x` ||||||
| `i64-to-u8` ||||||
| `i64-to-s16` ||||||
| `i64-to-s16x` ||||||
| `i64-to-u16` ||||||
| `i64-to-s32` ||||||
| `i64-to-s32x` ||||||
| `i64-to-u32` ||||||
| `i64-to-s64` ||||||
| `i64-to-u64` ||||||
| `s8-to-i32` ||||||
| `u8-to-i32` ||||||
| `s16-to-i32` ||||||
| `u16-to-i32` ||||||
| `s32-to-i32` ||||||
| `u32-to-i32` ||||||
| `s64-to-i32` ||||||
| `s64-to-i32x` ||||||
| `u64-to-i32` ||||||
| `u64-to-i32x` ||||||
| `s8-to-i64` ||||||
| `u8-to-i64` ||||||
| `s16-to-i64` ||||||
| `u16-to-i64` ||||||
| `s32-to-i64` ||||||
| `u32-to-i64` ||||||
| `s64-to-i64` ||||||
| `u64-to-i64` ||||||
| Instruction | WAT encoder/decoder | Binary encoder/decoder | Interpreter | Comment |
|-|-|-|-|-|
| `arg.get` |||| |
| `call-core` |||| |
| `s8.from_i32` |||| |
| `s8.from_i64` |||| |
| `s16.from_i32` |||| |
| `s16.from_i64` |||| |
| `s32.from_i32` |||| |
| `s32.from_i64` |||| |
| `s64.from_i32` |||| |
| `s64.from_i64` |||| |
| `i32.from_s8` |||| |
| `i32.from_s16` |||| |
| `i32.from_s32` |||| |
| `i32.from_s64` |||| |
| `i64.from_s8` |||| |
| `i64.from_s16` |||| |
| `i64.from_s32` |||| |
| `i64.from_s64` |||| |
| `u8.from_i32` |||| |
| `u8.from_i64` |||| |
| `u16.from_i32` |||| |
| `u16.from_i64` |||| |
| `u32.from_i32` |||| |
| `u32.from_i64` |||| |
| `u64.from_i32` |||| |
| `u64.from_i64` |||| |
| `i32.from_u8` |||| |
| `i32.from_u16` |||| |
| `i32.from_u32` |||| |
| `i32.from_u64` |||| |
| `i64.from_u8` |||| |
| `i64.from_u16` |||| |
| `i64.from_u32` |||| |
| `i64.from_u64` |||| |
| `string.lift_memory` |||| `#memidx` is not supported; `#encoding` is not supported but UTF-8 is assumed |
| `string.lower_memory` |||| `#memidx` is not supported; `#encoding` is not supported but UTF-8 is assumed |
| `string.size` |||| `#encoding` is not supported but UTF-8 is assumed |
| `call-adapter` |||| |
| `defer-call-core` |||| |
Loading

0 comments on commit 2276d16

Please sign in to comment.