Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update core spectests and wasmparser #2104

Merged
merged 4 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 47 additions & 4 deletions lib/compiler-cranelift/src/translator/code_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
// operands must match (hence the bitcast).
state.push1(builder.ins().bitselect(bitcast_c, bitcast_a, bitcast_b))
}
Operator::I8x16AnyTrue | Operator::I16x8AnyTrue | Operator::I32x4AnyTrue => {
Operator::V128AnyTrue => {
let a = pop1_with_bitcast(state, type_of(op), builder);
let bool_result = builder.ins().vany_true(a);
state.push1(builder.ins().bint(I32, bool_result))
Expand Down Expand Up @@ -1757,6 +1757,52 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
Operator::ReturnCall { .. } | Operator::ReturnCallIndirect { .. } => {
return Err(wasm_unsupported!("proposed tail-call operator {:?}", op));
}

Operator::I64x2Eq
| Operator::I64x2Ne
| Operator::I64x2AllTrue
| Operator::I64x2Bitmask
| Operator::I64x2WidenLowI32x4S
| Operator::I64x2WidenHighI32x4S
| Operator::I64x2WidenLowI32x4U
| Operator::I64x2WidenHighI32x4U
| Operator::I16x8ExtMulLowI8x16S
| Operator::I16x8ExtMulHighI8x16S
| Operator::I16x8ExtMulLowI8x16U
| Operator::I16x8ExtMulHighI8x16U
| Operator::I32x4ExtMulLowI16x8S
| Operator::I32x4ExtMulHighI16x8S
| Operator::I32x4ExtMulLowI16x8U
| Operator::I32x4ExtMulHighI16x8U
| Operator::I64x2ExtMulLowI32x4S
| Operator::I64x2ExtMulHighI32x4S
| Operator::I64x2ExtMulLowI32x4U
| Operator::I64x2ExtMulHighI32x4U
| Operator::V128Load8Lane { .. }
| Operator::V128Load16Lane { .. }
| Operator::V128Load32Lane { .. }
| Operator::V128Load64Lane { .. }
| Operator::V128Store8Lane { .. }
| Operator::V128Store16Lane { .. }
| Operator::V128Store32Lane { .. }
| Operator::V128Store64Lane { .. }
| Operator::I16x8Q15MulrSatS
| Operator::F32x4DemoteF64x2Zero
| Operator::F64x2PromoteLowF32x4
| Operator::F64x2ConvertLowI32x4S
| Operator::F64x2ConvertLowI32x4U
| Operator::I32x4TruncSatF64x2SZero
| Operator::I32x4TruncSatF64x2UZero => {
return Err(wasm_unsupported!("updated proposed simd operator {:?}", op));
}

Operator::Try { .. }
| Operator::Catch { .. }
| Operator::Throw { .. }
| Operator::Rethrow { .. }
| Operator::Unwind => {
return Err(wasm_unsupported!("proposed exception operator {:?}", op));
}
};
Ok(())
}
Expand Down Expand Up @@ -2395,7 +2441,6 @@ fn type_of(operator: &Operator) -> Type {
| Operator::I8x16GeU
| Operator::I8x16Neg
| Operator::I8x16Abs
| Operator::I8x16AnyTrue
| Operator::I8x16AllTrue
| Operator::I8x16Shl
| Operator::I8x16ShrS
Expand Down Expand Up @@ -2430,7 +2475,6 @@ fn type_of(operator: &Operator) -> Type {
| Operator::I16x8GeU
| Operator::I16x8Neg
| Operator::I16x8Abs
| Operator::I16x8AnyTrue
| Operator::I16x8AllTrue
| Operator::I16x8Shl
| Operator::I16x8ShrS
Expand Down Expand Up @@ -2465,7 +2509,6 @@ fn type_of(operator: &Operator) -> Type {
| Operator::I32x4GeU
| Operator::I32x4Neg
| Operator::I32x4Abs
| Operator::I32x4AnyTrue
| Operator::I32x4AllTrue
| Operator::I32x4Shl
| Operator::I32x4ShrS
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler-llvm/src/translator/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6722,7 +6722,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
let res = self.builder.build_not(v, "");
self.state.push1(res);
}
Operator::I8x16AnyTrue | Operator::I16x8AnyTrue | Operator::I32x4AnyTrue => {
Operator::V128AnyTrue => {
// | Operator::I64x2AnyTrue
// Skip canonicalization, it never changes non-zero values to zero or vice versa.
let v = self.state.pop1()?.into_int_value();
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edition = "2018"
[dependencies]
wasmer-vm = { path = "../vm", version = "1.0.2" }
wasmer-types = { path = "../wasmer-types", version = "1.0.2", default-features = false }
wasmparser = { version = "0.65", optional = true, default-features = false }
wasmparser = { version = "0.74", optional = true, default-features = false }
target-lexicon = { version = "0.11", default-features = false }
enumset = "1.0"
hashbrown = { version = "0.9", optional = true }
Expand Down
1 change: 1 addition & 0 deletions lib/compiler/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub trait Compiler: Send {
module_linking: features.module_linking,
multi_memory: features.multi_memory,
memory64: features.memory64,
exceptions: features.exceptions,
deterministic_only: false,
};
validator.wasm_features(wasm_features);
Expand Down
8 changes: 4 additions & 4 deletions lib/compiler/src/translator/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ pub fn translate_module<'data>(
environ.reserve_passive_data(count)?;
}

Payload::ModuleSection(_)
| Payload::InstanceSection(_)
Payload::InstanceSection(_)
| Payload::AliasSection(_)
| Payload::ModuleCodeSectionStart { .. }
| Payload::ModuleCodeSectionEntry { .. } => {
| Payload::EventSection(_)
| Payload::ModuleSectionStart { .. }
| Payload::ModuleSectionEntry { .. } => {
unimplemented!("module linking not implemented yet")
}

Expand Down
9 changes: 7 additions & 2 deletions lib/compiler/src/translator/sections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ pub fn parse_import_section<'data>(
field_name.unwrap_or_default(),
)?;
}
ImportSectionEntryType::Module(_sig) | ImportSectionEntryType::Instance(_sig) => {
ImportSectionEntryType::Module(_)
| ImportSectionEntryType::Instance(_)
| ImportSectionEntryType::Event(_) => {
unimplemented!("module linking not implemented yet")
}
ImportSectionEntryType::Memory(WPMemoryType::M32 {
Expand Down Expand Up @@ -292,7 +294,10 @@ pub fn parse_export_section<'data>(
ExternalKind::Global => {
environ.declare_global_export(GlobalIndex::new(index), field)?
}
ExternalKind::Type | ExternalKind::Module | ExternalKind::Instance => {
ExternalKind::Type
| ExternalKind::Module
| ExternalKind::Instance
| ExternalKind::Event => {
unimplemented!("module linking not implemented yet")
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/wasmer-types/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub struct Features {
pub multi_memory: bool,
/// 64-bit Memory proposal should be enabled
pub memory64: bool,
/// Wasm exceptions proposal should be enabled
pub exceptions: bool,
}

impl Features {
Expand All @@ -43,6 +45,7 @@ impl Features {
module_linking: false,
multi_memory: false,
memory64: false,
exceptions: false,
}
}

Expand Down Expand Up @@ -249,6 +252,7 @@ mod test_features {
module_linking: false,
multi_memory: false,
memory64: false,
exceptions: false,
}
);
}
Expand Down
10 changes: 10 additions & 0 deletions tests/ignores.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ cranelift::spec::simd::simd_i8x16_sat_arith on aarch64
cranelift::spec::simd::simd_lane on aarch64
cranelift::spec::skip_stack_guard_page on aarch64


# SIMD changes
# due to breaking changes in the SIMD proposal, we have to disable these spec tests
# note we've not pulled in the updated spec tests yet, so expect more breakage

cranelift::spec::simd::simd_boolean
cranelift::spec::simd::simd_lane
llvm::spec::simd::simd_boolean
llvm::spec::simd::simd_lane

# Frontends

## WASI
Expand Down
1 change: 1 addition & 0 deletions tests/lib/engine-dummy/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl Engine for DummyEngine {
module_linking: features.module_linking,
multi_memory: features.multi_memory,
memory64: features.memory64,
exceptions: features.exceptions,
deterministic_only: false,
};
validator.wasm_features(wasm_features);
Expand Down
7 changes: 6 additions & 1 deletion tests/lib/wast/src/wast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl Wast {
let instance = self
.instances
.get(module_name)
.ok_or_else(|| anyhow!("no module named `{}`", module_name))?;
.ok_or_else(|| anyhow!("constant expression required"))?;
imports.register(module_name, instance.exports.clone());
}

Expand Down Expand Up @@ -421,6 +421,11 @@ impl Wast {
// `elem.wast` and `proposals/bulk-memory-operations/elem.wast` disagree
// on the expected error message for the same error.
|| (expected.contains("out of bounds") && actual.contains("does not fit"))
// handle `unknown global $NUM` error messages that wasmparser doesn't return yet
|| (expected.contains("unknown global") && actual.contains("unknown global"))
// handle `unknown memory $NUM` error messages that wasmparser doesn't return yet
|| (expected.contains("unknown memory") && actual.contains("unknown memory"))
|| (expected.contains("unknown memory") && actual.contains("Data segment extends past end of the data section"))
}

// Checks if the `assert_trap` message matches the expected one
Expand Down
21 changes: 21 additions & 0 deletions tests/wast/spec/address.wast
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@
(assert_return (invoke "32_good4" (i32.const 65508)) (i32.const 0))
(assert_trap (invoke "32_good5" (i32.const 65508)) "out of bounds memory access")

(assert_trap (invoke "8u_good3" (i32.const -1)) "out of bounds memory access")
(assert_trap (invoke "8s_good3" (i32.const -1)) "out of bounds memory access")
(assert_trap (invoke "16u_good3" (i32.const -1)) "out of bounds memory access")
(assert_trap (invoke "16s_good3" (i32.const -1)) "out of bounds memory access")
(assert_trap (invoke "32_good3" (i32.const -1)) "out of bounds memory access")
(assert_trap (invoke "32_good3" (i32.const -1)) "out of bounds memory access")

(assert_trap (invoke "8u_bad" (i32.const 0)) "out of bounds memory access")
(assert_trap (invoke "8s_bad" (i32.const 0)) "out of bounds memory access")
(assert_trap (invoke "16u_bad" (i32.const 0)) "out of bounds memory access")
Expand Down Expand Up @@ -478,6 +485,14 @@
(assert_return (invoke "64_good4" (i32.const 65504)) (i64.const 0))
(assert_trap (invoke "64_good5" (i32.const 65504)) "out of bounds memory access")

(assert_trap (invoke "8u_good3" (i32.const -1)) "out of bounds memory access")
(assert_trap (invoke "8s_good3" (i32.const -1)) "out of bounds memory access")
(assert_trap (invoke "16u_good3" (i32.const -1)) "out of bounds memory access")
(assert_trap (invoke "16s_good3" (i32.const -1)) "out of bounds memory access")
(assert_trap (invoke "32u_good3" (i32.const -1)) "out of bounds memory access")
(assert_trap (invoke "32s_good3" (i32.const -1)) "out of bounds memory access")
(assert_trap (invoke "64_good3" (i32.const -1)) "out of bounds memory access")

(assert_trap (invoke "8u_bad" (i32.const 0)) "out of bounds memory access")
(assert_trap (invoke "8s_bad" (i32.const 0)) "out of bounds memory access")
(assert_trap (invoke "16u_bad" (i32.const 0)) "out of bounds memory access")
Expand Down Expand Up @@ -538,6 +553,9 @@
(assert_return (invoke "32_good4" (i32.const 65525)) (f32.const 0.0))
(assert_trap (invoke "32_good5" (i32.const 65525)) "out of bounds memory access")

(assert_trap (invoke "32_good3" (i32.const -1)) "out of bounds memory access")
(assert_trap (invoke "32_good3" (i32.const -1)) "out of bounds memory access")

(assert_trap (invoke "32_bad" (i32.const 0)) "out of bounds memory access")
(assert_trap (invoke "32_bad" (i32.const 1)) "out of bounds memory access")

Expand Down Expand Up @@ -585,5 +603,8 @@
(assert_return (invoke "64_good4" (i32.const 65511)) (f64.const 0.0))
(assert_trap (invoke "64_good5" (i32.const 65511)) "out of bounds memory access")

(assert_trap (invoke "64_good3" (i32.const -1)) "out of bounds memory access")
(assert_trap (invoke "64_good3" (i32.const -1)) "out of bounds memory access")

(assert_trap (invoke "64_bad" (i32.const 0)) "out of bounds memory access")
(assert_trap (invoke "64_bad" (i32.const 1)) "out of bounds memory access")
40 changes: 39 additions & 1 deletion tests/wast/spec/binary-leb128.wast
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@
"\41\00" ;; i32.const 0
"\41\03" ;; i32.const 3
"\36" ;; i32.store
"\03" ;; alignment 2
"\02" ;; alignment 2
"\82\80\80\80\10" ;; offset 2 with unused bits set
"\0b" ;; end
)
Expand Down Expand Up @@ -961,3 +961,41 @@
)
"integer too large"
)


(module binary
"\00asm" "\01\00\00\00"
"\01\04\01" ;; type section
"\60\00\00" ;; empty function type
"\03\02\01" ;; function section
"\00" ;; function 0, type 0
"\0a\1b\01\19" ;; code section
"\00" ;; no locals
"\00" ;; unreachable
"\fc\80\00" ;; i32_trunc_sat_f32_s with 2 bytes
"\00" ;; unreachable
"\fc\81\80\00" ;; i32_trunc_sat_f32_u with 3 bytes
"\00" ;; unreachable
"\fc\86\80\80\00" ;; i64_trunc_sat_f64_s with 4 bytes
"\00" ;; unreachable
"\fc\87\80\80\80\00" ;; i64_trunc_sat_f64_u with 5 bytes
"\00" ;; unreachable
"\0b" ;; end
)

(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01" ;; type section
"\60\00\00" ;; empty function type
"\03\02\01" ;; function section
"\00" ;; function 0, type 0
"\0a\0d\01\0b" ;; code section
"\00" ;; no locals
"\00" ;; unreachable
"\fc\87\80\80\80\80\00" ;; i64_trunc_sat_f64_u with 6 bytes
"\00" ;; unreachable
"\0b" ;; end
)
"integer representation too long"
)
Loading