Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion interpreter/binary/decode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion interpreter/host/spectest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
6 changes: 2 additions & 4 deletions interpreter/runtime/memory.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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))
Expand Down
2 changes: 0 additions & 2 deletions interpreter/runtime/memory.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions interpreter/text/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -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} }
Expand Down Expand Up @@ -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],
[], [] }

Expand Down
2 changes: 1 addition & 1 deletion interpreter/valid/valid.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
()
Expand Down