[multibyte] Support all array element types in the interpreter - #9115
brendandahl wants to merge 1 commit into
Conversation
Since primitive GC arrays are stored as raw byte buffers (WebAssembly#9051) the interpreter now only needs to be updated to handle calculating the effective address with the offset. Also fix a printing bug that only showed up once arrays of wider element types were executed: an unreachable access was printed as i32.load/i32.store regardless of its alignment, e.g. "i32.load align=8", which fails validation. Print a type that is valid for the alignment, as we do for loads from memory. Add execution tests for all the valid element types (i8, i16, i32, i64, f32, f64, v128): a new lit exec test that runs them in the interpreter before and after optimization, new spec test modules that perform the same accesses on arrays of each element type and cover the offset and align immediates, and a ctor-eval test that evaluates multibyte stores and serializes the results back as elements. Also expand the validation test with immutable non-i8 arrays, non-numeric element types, alignment and offset limits, and the feature requirement.
| (i64.store (type $i32_array) (global.get $i32) (i32.const 4) | ||
| (i64.const 0x1122334455667788) | ||
| ) | ||
| ;; An unaligned i32 store covers parts of two i16 elements. |
There was a problem hiding this comment.
| ;; An unaligned i32 store covers parts of two i16 elements. | |
| ;; An unaligned i32 store covers parts of three i16 elements. |
| (func $i8-array (export "i8-array") (result i32) | ||
| (local $a (ref $i8)) | ||
| (local.set $a (call $new-i8)) | ||
| (i32.store (type $i8) (local.get $a) (i32.const 4) (i32.const 0x12345678)) |
There was a problem hiding this comment.
It would be good to use decimal numbers in the input to make it easier to verify that it matches the output.
| ;; Loads of every width and sign, on an array whose elements are wider than | ||
| ;; the access. | ||
| ;; CHECK: [fuzz-exec] export load-widths-i32 | ||
| ;; CHECK-NEXT: [fuzz-exec] note result: load-widths-i32 => 65284 |
There was a problem hiding this comment.
It would be nice if these results were easier to verify, too.
There was a problem hiding this comment.
Do we need this in addition to the spec test?
There was a problem hiding this comment.
I was meaning to ask about this... Is this folder just for tests that aren't covered by spec tests?
There was a problem hiding this comment.
Yeah, it's a little unclear. Generally we should prefer (upstream!) spec tests, but sometimes there are tests that are very specific to the interpreter or otherwise don't make sense as spec tests. I think we should probably prefer spec tests more than we have historically.
Since primitive GC arrays are stored as raw byte buffers (#9051) the interpreter now only needs to be updated to handle calculating the effective address with the offset.
Also fix a printing bug that only showed up once arrays of wider element types were executed: an unreachable access was printed as i32.load/i32.store regardless of its alignment, e.g. "i32.load align=8", which fails validation. Print a type that is valid for the alignment, as we do for loads from memory.
Add execution tests for all the valid element types (i8, i16, i32, i64, f32, f64, v128): a new lit exec test that runs them in the interpreter before and after optimization, new spec test modules that perform the same accesses on arrays of each element type and cover the offset and align immediates, and a ctor-eval test that evaluates multibyte stores and serializes the results back as elements. Also expand the validation test with immutable non-i8 arrays, non-numeric element types, alignment and offset limits, and the feature requirement.