Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 0aa4c8c

Browse files
committed
Intepreter and test updates from @rossberg
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
1 parent ace0947 commit 0aa4c8c

22 files changed

+370
-362
lines changed

interpreter/binary/decode.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -281,19 +281,19 @@ let limits uN s =
281281
let flags = byte s in
282282
require (flags land 0xfa = 0) s (pos s - 1) "malformed limits flags";
283283
let has_max = (flags land 1 = 1) in
284-
let is64 = (flags land 4 = 4) in
284+
let at = if flags land 4 = 4 then I64AT else I32AT in
285285
let min = uN s in
286286
let max = opt uN has_max s in
287-
{min; max}, is64
287+
at, {min; max}
288288

289289
let table_type s =
290290
let t = ref_type s in
291-
let lim, is64 = limits u64 s in
292-
TableT (lim, (if is64 then I64AddrType else I32AddrType), t)
291+
let at, lim = limits u64 s in
292+
TableT (at, lim, t)
293293

294294
let memory_type s =
295-
let lim, is64 = limits u64 s in
296-
MemoryT (lim, if is64 then I64AddrType else I32AddrType)
295+
let at, lim = limits u64 s in
296+
MemoryT (at, lim)
297297

298298
let global_type s =
299299
let t = val_type s in

interpreter/binary/encode.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,15 @@ struct
194194
| RecT [st] -> sub_type st
195195
| RecT sts -> s7 (-0x32); vec sub_type sts
196196

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

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

204204
let memory_type = function
205-
| MemoryT (lim, at) -> limits u64 lim at
205+
| MemoryT (at, lim) -> limits at lim
206206

207207
let global_type = function
208208
| GlobalT (mut, t) -> val_type t; mutability mut

0 commit comments

Comments
 (0)