diff --git a/interpreter/binary/decode.ml b/interpreter/binary/decode.ml index c4b0947bd..9577ec35a 100644 --- a/interpreter/binary/decode.ml +++ b/interpreter/binary/decode.ml @@ -296,7 +296,7 @@ let globaltype s = let memorytype s = let at, lim = limits u64 s in - MemoryT (at, lim, PageT 0x10000) (* TODO(custom-page-sizes) *) + MemoryT (at, lim, PageT 16) (* TODO(custom-page-sizes) *) let tabletype s = let t = reftype s in diff --git a/interpreter/host/spectest.ml b/interpreter/host/spectest.ml index 82ee4be45..4d24c239a 100644 --- a/interpreter/host/spectest.ml +++ b/interpreter/host/spectest.ml @@ -28,7 +28,7 @@ let table64 = ExternTable (Table.alloc tt (NullRef FuncHT)) let memory = - let mt = MemoryT (I32AT, {min = 1L; max = Some 2L}, PageT 0x10000) in + let mt = MemoryT (I32AT, {min = 1L; max = Some 2L}, PageT 16) in ExternMemory (Memory.alloc mt) let func f ts1 ts2 = diff --git a/interpreter/runtime/memory.ml b/interpreter/runtime/memory.ml index 9e73d6d2a..79765b57a 100644 --- a/interpreter/runtime/memory.ml +++ b/interpreter/runtime/memory.ml @@ -17,8 +17,6 @@ exception SizeOverflow exception SizeLimit exception OutOfMemory -let page_size = 0x10000L (* 64 KiB *) - let valid_limits {min; max} = match max with | None -> true @@ -31,7 +29,7 @@ let valid_size at i = let create n (PageT ps) = try - let size = Int64.(mul n (Int64.of_int ps)) in + let size = Int64.(shift_left n ps) in let mem = Array1_64.create Int8_unsigned C_layout size in Array1.fill mem 0; mem @@ -47,7 +45,7 @@ let bound mem = Array1_64.dim mem.content let pagesize mem = - let MemoryT (_, _, PageT x) = mem.ty in Int64.of_int x + let MemoryT (_, _, PageT x) = mem.ty in (Int64.shift_left 1L x) let size mem = Int64.(div (bound mem) (pagesize mem)) diff --git a/interpreter/runtime/memory.mli b/interpreter/runtime/memory.mli index 5bbc8a77e..0dae66766 100644 --- a/interpreter/runtime/memory.mli +++ b/interpreter/runtime/memory.mli @@ -14,8 +14,6 @@ exception SizeOverflow exception SizeLimit exception OutOfMemory -val page_size : int64 - val alloc : memorytype -> memory (* raises Type, SizeOverflow, OutOfMemory *) val type_of : memory -> memorytype val addrtype_of : memory -> addrtype diff --git a/interpreter/text/parser.mly b/interpreter/text/parser.mly index 0ee8020c3..424e0ceb9 100644 --- a/interpreter/text/parser.mly +++ b/interpreter/text/parser.mly @@ -466,7 +466,7 @@ tabletype : | addrtype limits reftype { fun c -> TableT ($1, $2, $3 c) } memorytype : - | addrtype limits { fun c -> MemoryT ($1, $2, PageT 0x10000) } + | addrtype limits { fun c -> MemoryT ($1, $2, PageT 16) } limits : | NAT { {min = nat64 $1 $loc($1); max = None} } @@ -1130,7 +1130,7 @@ memory_fields : { fun c x loc -> let size = Int64.(div (add (of_int (String.length $4)) 65535L) 65536L) in let offset = [at_const $1 (0L @@ loc) @@ loc] @@ loc in - [Memory (MemoryT ($1, {min = size; max = Some size}, PageT 0x10000)) @@ loc], + [Memory (MemoryT ($1, {min = size; max = Some size}, PageT 16)) @@ loc], [Data ($4, Active (x, offset) @@ loc) @@ loc], [], [] } diff --git a/interpreter/valid/valid.ml b/interpreter/valid/valid.ml index c22a1d0cf..e7da0f809 100644 --- a/interpreter/valid/valid.ml +++ b/interpreter/valid/valid.ml @@ -105,7 +105,7 @@ let check_limits {min; max} range at msg = "size minimum must not be greater than maximum" let check_pagetype (PageT ps) at = - require (ps = 0x10000 || ps = 1) at "page size must be 1 or 64KiB" + require (ps = 16 || ps = 0) at "page size must be 1 or 64KiB" let check_numtype (c : context) (t : numtype) at = ()