Skip to content

Commit

Permalink
Intepreter and test updates from @rossberg
Browse files Browse the repository at this point in the history
Interpreter:

- Fixed evaluation of v128 load/store instructions to work with i64
- Reworked bulk operation execution to still reduce to well-typed instructions for i32
- Added missing size check to table allocation
- Various minor refactorings and clean-ups

Tests:

- Added tests for size check in i64 table and memory type limits

Split out from WebAssembly/spec#1839
  • Loading branch information
sbc100 committed Nov 6, 2024
1 parent 1795669 commit 5c3940b
Show file tree
Hide file tree
Showing 22 changed files with 370 additions and 362 deletions.
12 changes: 6 additions & 6 deletions interpreter/binary/decode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,19 @@ let limits uN s =
let flags = byte s in
require (flags land 0xfa = 0) s (pos s - 1) "malformed limits flags";
let has_max = (flags land 1 = 1) in
let is64 = (flags land 4 = 4) in
let at = if flags land 4 = 4 then I64AT else I32AT in
let min = uN s in
let max = opt uN has_max s in
{min; max}, is64
at, {min; max}

let table_type s =
let t = ref_type s in
let lim, is64 = limits u64 s in
TableT (lim, (if is64 then I64AddrType else I32AddrType), t)
let at, lim = limits u64 s in
TableT (at, lim, t)

let memory_type s =
let lim, is64 = limits u64 s in
MemoryT (lim, if is64 then I64AddrType else I32AddrType)
let at, lim = limits u64 s in
MemoryT (at, lim)

let global_type s =
let t = val_type s in
Expand Down
10 changes: 5 additions & 5 deletions interpreter/binary/encode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ struct
| RecT [st] -> sub_type st
| RecT sts -> s7 (-0x32); vec sub_type sts

let limits vu {min; max} at =
let flags = flag (max <> None) 0 + flag (at = I64AddrType) 2 in
byte flags; vu min; opt vu max
let limits at {min; max} =
let flags = flag (max <> None) 0 + flag (at = I64AT) 2 in
byte flags; u64 min; opt u64 max

let table_type = function
| TableT (lim, at, t) -> ref_type t; limits u64 lim at
| TableT (at, lim, t) -> ref_type t; limits at lim

let memory_type = function
| MemoryT (lim, at) -> limits u64 lim at
| MemoryT (at, lim) -> limits at lim

let global_type = function
| GlobalT (mut, t) -> val_type t; mutability mut
Expand Down
Loading

0 comments on commit 5c3940b

Please sign in to comment.