Skip to content

Commit

Permalink
Merge #1218
Browse files Browse the repository at this point in the history
1218: Enable clif verifier in debug mode, fix issue with verifier r=MarkMcCaskey a=MarkMcCaskey

Ensures we're using I32s to index into things that are indexed by I32s

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Mark McCaskey <mark@wasmer.io>
  • Loading branch information
bors[bot] and Mark McCaskey authored Feb 14, 2020
2 parents 8faac62 + 23275d0 commit 32991e6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## **[Unreleased]**

- [#1218](https://github.com/wasmerio/wasmer/pull/1218) Enable Cranelift verifier in debug mode. Fix bug with table indices being the wrong type.
- [#787](https://github.com/wasmerio/wasmer/pull/787) New crate `wasmer-interface-types` to implement WebAssembly Interface Types.
- [#1213](https://github.com/wasmerio/wasmer/pull/1213) Fixed WASI `fdstat` to detect `isatty` properly.
- [#1192](https://github.com/wasmerio/wasmer/pull/1192) Use `ExceptionCode` for error representation.
Expand Down
7 changes: 4 additions & 3 deletions lib/clif-backend/src/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ impl FuncEnvironment for FunctionEnvironment {
let local_memory_bound = func.create_global_value(ir::GlobalValueData::Load {
base: local_memory_ptr,
offset: (vm::LocalMemory::offset_bound() as i32).into(),
global_type: ptr_type,
global_type: ir::types::I32,
readonly: false,
});

Expand Down Expand Up @@ -551,7 +551,7 @@ impl FuncEnvironment for FunctionEnvironment {
let table_count = func.create_global_value(ir::GlobalValueData::Load {
base: table_struct_ptr,
offset: (vm::LocalTable::offset_count() as i32).into(),
global_type: ptr_type,
global_type: ir::types::I32,
// The table length can change, so it can't be readonly.
readonly: false,
});
Expand Down Expand Up @@ -673,7 +673,8 @@ impl FuncEnvironment for FunctionEnvironment {
colocated: false,
});

pos.ins().symbol_value(ir::types::I64, sig_index_global)
let val = pos.ins().symbol_value(ir::types::I64, sig_index_global);
pos.ins().ireduce(ir::types::I32, val)

// let dynamic_sigindices_array_ptr = pos.ins().load(
// ptr_type,
Expand Down
4 changes: 3 additions & 1 deletion lib/clif-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ fn get_isa() -> Box<dyn isa::TargetIsa> {
builder.set("opt_level", "speed_and_size").unwrap();
builder.set("jump_tables_enabled", "false").unwrap();

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

Expand Down
9 changes: 7 additions & 2 deletions lib/clif-backend/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
use byteorder::{ByteOrder, LittleEndian};
use cranelift_codegen::{
binemit::{Stackmap, StackmapSink},
ir, isa, Context,
ir, isa, CodegenError, Context,
};
use rayon::prelude::*;
use std::{
Expand Down Expand Up @@ -124,7 +124,12 @@ impl FuncResolverBuilder {
&mut local_trap_sink,
&mut stackmap_sink,
)
.map_err(|e| CompileError::InternalError { msg: e.to_string() })?;
.map_err(|e| match e {
CodegenError::Verifier(v) => CompileError::InternalError {
msg: format!("Verifier error: {}", v),
},
_ => CompileError::InternalError { msg: e.to_string() },
})?;
ctx.clear();
Ok((code_buf, (reloc_sink, local_trap_sink)))
},
Expand Down

0 comments on commit 32991e6

Please sign in to comment.