Skip to content

Commit

Permalink
Merge #2268
Browse files Browse the repository at this point in the history
2268: Update spectests r=MarkMcCaskey a=MarkMcCaskey

Updating spectests in Wasmer, we disable all the ones that are now failing. We shouldn't merge this until we investigate the breakages and fix some of them. It's likely that we're passing most of the statements in most of these files, but due to some new changes are not passing all of them, thus merging it in as-is will reduce our overall test coverage.

Additionally, when running the update script, some feature specific things failed to update like bulk memory. But now that bulk memory has landed as a stable feature of Wasm it should be included in the general `spec` tests.

Co-authored-by: Mark McCaskey <[email protected]>
Co-authored-by: Mark McCaskey <[email protected]>
  • Loading branch information
3 people authored May 5, 2021
2 parents e56c99e + 327cb64 commit b7321a5
Show file tree
Hide file tree
Showing 94 changed files with 52,364 additions and 3,040 deletions.
34 changes: 0 additions & 34 deletions lib/vm/src/instance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1026,8 +1026,6 @@ impl InstanceHandle {
data_initializers: &[DataInitializer<'_>],
) -> Result<(), Trap> {
let instance = self.instance().as_ref();
check_table_init_bounds(instance)?;
check_memory_init_bounds(instance, data_initializers)?;

// Apply the initializers.
initialize_tables(instance)?;
Expand Down Expand Up @@ -1300,21 +1298,6 @@ cfg_if::cfg_if! {
}
}

fn check_table_init_bounds(instance: &Instance) -> Result<(), Trap> {
let module = Arc::clone(&instance.module);
for init in &module.table_initializers {
let start = get_table_init_start(init, instance);
let table = instance.get_table(init.table_index);

let size = usize::try_from(table.size()).unwrap();
if size < start + init.elements.len() {
return Err(Trap::new_from_runtime(TrapCode::TableSetterOutOfBounds));
}
}

Ok(())
}

/// Compute the offset for a memory data initializer.
fn get_memory_init_start(init: &DataInitializer<'_>, instance: &Instance) -> usize {
let mut start = init.location.offset;
Expand Down Expand Up @@ -1351,23 +1334,6 @@ unsafe fn get_memory_slice<'instance>(
slice::from_raw_parts_mut(memory.base, memory.current_length.try_into().unwrap())
}

fn check_memory_init_bounds(
instance: &Instance,
data_initializers: &[DataInitializer<'_>],
) -> Result<(), Trap> {
for init in data_initializers {
let start = get_memory_init_start(init, instance);
unsafe {
let mem_slice = get_memory_slice(init, instance);
if mem_slice.get_mut(start..start + init.data.len()).is_none() {
return Err(Trap::new_from_runtime(TrapCode::HeapSetterOutOfBounds));
}
}
}

Ok(())
}

/// Compute the offset for a table element initializer.
fn get_table_init_start(init: &TableInitializer, instance: &Instance) -> usize {
let mut start = init.offset;
Expand Down
2 changes: 2 additions & 0 deletions lib/vm/src/trap/trapcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub enum TrapCode {
/// Memory data doesn't fit the memory size.
///
/// This only can happen during instantiation.
// TODO(bulk_memory): this is currently unused, if it's not used by the bulk
// memory spectests then we should remove it from Wasmer.
HeapSetterOutOfBounds = 1,

/// A `heap_addr` instruction detected an out-of-bounds error.
Expand Down
85 changes: 85 additions & 0 deletions tests/ignores.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,88 @@ wasitests::unstable::mapdir_with_leading_slash on windows
# This test is meant to only run on Unix
wasitests::unstable::unix_open_special_files on windows
wasitests::snapshot1::unix_open_special_files on windows

# Updated spectests

# bulk memory
cranelift::spec::bulk
# new simd
cranelift::spec::simd::simd_align
cranelift::spec::simd::simd_conversions
cranelift::spec::simd::simd_f32x4_pmin_pmax
cranelift::spec::simd::simd_f32x4_rounding
cranelift::spec::simd::simd_f64x2_pmin_pmax
cranelift::spec::simd::simd_f64x2_rounding
cranelift::spec::simd::simd_i16x8_extadd_pairwise_i8x16
cranelift::spec::simd::simd_i16x8_extmul_i8x16
cranelift::spec::simd::simd_i16x8_q15mulr_sat_s
cranelift::spec::simd::simd_i16x8_sat_arith
cranelift::spec::simd::simd_i32x4_dot_i16x8
cranelift::spec::simd::simd_i32x4_extadd_pairwise_i16x8
cranelift::spec::simd::simd_i32x4_extmul_i16x8
cranelift::spec::simd::simd_i32x4_trunc_sat_f64x2
cranelift::spec::simd::simd_i64x2_arith2
cranelift::spec::simd::simd_i64x2_cmp
cranelift::spec::simd::simd_i64x2_extmul_i32x4
cranelift::spec::simd::simd_i8x16_arith2
cranelift::spec::simd::simd_i8x16_sat_arith
cranelift::spec::simd::simd_int_to_int_extend
cranelift::spec::simd::simd_load
cranelift::spec::simd::simd_load16_lane
cranelift::spec::simd::simd_load32_lane
cranelift::spec::simd::simd_load64_lane
cranelift::spec::simd::simd_load8_lane
cranelift::spec::simd::simd_load_extend
cranelift::spec::simd::simd_load_splat
cranelift::spec::simd::simd_load_zero
cranelift::spec::simd::simd_splat
cranelift::spec::simd::simd_store16_lane
cranelift::spec::simd::simd_store32_lane
cranelift::spec::simd::simd_store64_lane
cranelift::spec::simd::simd_store8_lane

# bulk memory
llvm::spec::bulk
llvm::spec::memory_copy
llvm::spec::memory_fill
llvm::spec::memory_init
# new simd
llvm::spec::simd::simd_align
llvm::spec::simd::simd_conversions
llvm::spec::simd::simd_f32x4_pmin_pmax
llvm::spec::simd::simd_f32x4_rounding
llvm::spec::simd::simd_f64x2_pmin_pmax
llvm::spec::simd::simd_f64x2_rounding
llvm::spec::simd::simd_i16x8_extadd_pairwise_i8x16
llvm::spec::simd::simd_i16x8_extmul_i8x16
llvm::spec::simd::simd_i16x8_q15mulr_sat_s
llvm::spec::simd::simd_i16x8_sat_arith
llvm::spec::simd::simd_i32x4_dot_i16x8
llvm::spec::simd::simd_i32x4_extadd_pairwise_i16x8
llvm::spec::simd::simd_i32x4_extmul_i16x8
llvm::spec::simd::simd_i32x4_trunc_sat_f64x2
llvm::spec::simd::simd_i64x2_arith2
llvm::spec::simd::simd_i64x2_cmp
llvm::spec::simd::simd_i64x2_extmul_i32x4
llvm::spec::simd::simd_i8x16_arith2
llvm::spec::simd::simd_i8x16_sat_arith
llvm::spec::simd::simd_int_to_int_extend
llvm::spec::simd::simd_load
llvm::spec::simd::simd_load16_lane
llvm::spec::simd::simd_load32_lane
llvm::spec::simd::simd_load64_lane
llvm::spec::simd::simd_load8_lane
llvm::spec::simd::simd_load_extend
llvm::spec::simd::simd_load_splat
llvm::spec::simd::simd_load_zero
llvm::spec::simd::simd_splat
llvm::spec::simd::simd_store16_lane
llvm::spec::simd::simd_store32_lane
llvm::spec::simd::simd_store64_lane
llvm::spec::simd::simd_store8_lane

# bulk memory
singlepass::spec::bulk
singlepass::spec::memory_copy
singlepass::spec::memory_fill
singlepass::spec::memory_init
5 changes: 3 additions & 2 deletions tests/wast/spec/binary-leb128.wast
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
"\00asm" "\01\00\00\00"
"\04\04\01" ;; Table section with 1 entry
"\70\00\00" ;; no max, minimum 0, funcref
"\09\07\01" ;; Element section with 1 entry
"\09\09\01" ;; Element section with 1 entry
"\02" ;; Element with explicit table index
"\80\00" ;; Table index 0, encoded with 2 bytes
"\41\00\0b\00" ;; (i32.const 0) with no elements
"\41\00\0b\00\00" ;; (i32.const 0) with no elements
)
(module binary
"\00asm" "\01\00\00\00"
Expand Down
Loading

0 comments on commit b7321a5

Please sign in to comment.