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
5 changes: 5 additions & 0 deletions proposals/custom-page-sizes/custom-page-sizes-invalid.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"invalid custom page size"
)

(assert_malformed
(module quote "(memory 0 (pagesize 0))")
"invalid custom page size"
)

;; Power-of-two page sizes that are not 1 or 64KiB.
(assert_invalid
(module (memory 0 (pagesize 2)))
Expand Down
30 changes: 30 additions & 0 deletions proposals/custom-page-sizes/custom-page-sizes.wast
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,33 @@
(module
(memory (import "m" "large-pages-memory") 0 (pagesize 65536))
)

;; Inline data segments

;; pagesize 0
(assert_malformed (module quote "(memory (pagesize 0) (data))") "invalid custom page size")

;; pagesize 1
(module
(memory (pagesize 1) (data "xyz"))
(func (export "size") (result i32)
memory.size)
(func (export "grow") (param i32) (result i32)
(memory.grow (local.get 0)))
(func (export "load") (param i32) (result i32)
(i32.load8_u (local.get 0))))

(assert_return (invoke "size") (i32.const 3))
(assert_return (invoke "load" (i32.const 0)) (i32.const 120))
(assert_return (invoke "load" (i32.const 1)) (i32.const 121))
(assert_return (invoke "load" (i32.const 2)) (i32.const 122))
(assert_trap (invoke "load" (i32.const 3)) "out of bounds")
(assert_return (invoke "grow" (i32.const 1)) (i32.const -1))

;; pagesize 65536
(module
(memory (pagesize 65536) (data "xyz"))
(func (export "size") (result i32)
memory.size))

(assert_return (invoke "size") (i32.const 1))
64 changes: 64 additions & 0 deletions proposals/custom-page-sizes/memory_max.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
;; Maximum memory sizes.
;;
;; These modules are valid, but instantiating them is unnecessary
;; and would only allocate very large memories and slow down running
;; the spec tests. Therefore, add a missing import so that it cannot
;; be instantiated and use `assert_unlinkable`. This approach
;; enforces that the module itself is still valid, but that its
;; instantiation fails early (hopefully before any memories are
;; actually allocated).

;; i32 (pagesize 1)
(assert_unlinkable
(module
(import "test" "unknown" (func))
(memory 0xFFFF_FFFF (pagesize 1)))
"unknown import")

;; i64 (pagesize 1)
(assert_unlinkable
(module
(import "test" "import" (func))
(memory i64 0xFFFF_FFFF_FFFF_FFFF (pagesize 1)))
"unknown import")

;; i32 (default pagesize)
(assert_unlinkable
(module
(import "test" "unknown" (func))
(memory 65536 (pagesize 65536)))
"unknown import")

;; i64 (default pagesize)
(assert_unlinkable
(module
(import "test" "unknown" (func))
(memory i64 0x1_0000_0000_0000 (pagesize 65536)))
"unknown import")

;; Memory size just over the maximum.
;;
;; These are malformed (for pagesize 1)
;; or invalid (for other pagesizes).

;; i32 (pagesize 1)
(assert_malformed
(module quote "(memory 0x1_0000_0000 (pagesize 1))")
"constant out of range")

;; i64 (pagesize 1)
(assert_malformed
(module quote "(memory i64 0x1_0000_0000_0000_0000 (pagesize 1))")
"constant out of range")

;; i32 (default pagesize)
(assert_invalid
(module
(memory 65537 (pagesize 65536)))
"memory size must be at most")

;; i64 (default pagesize)
(assert_invalid
(module
(memory i64 0x1_0000_0000_0001 (pagesize 65536)))
"memory size must be at most")
38 changes: 26 additions & 12 deletions proposals/memory64/memory.wast
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
(module (memory 0 0))
(module (memory 0 1))
(module (memory 1 256))
(module definition (memory 65536))
(module (memory 0 65536))

(module (memory (data)) (func (export "memsize") (result i32) (memory.size)))
Expand Down Expand Up @@ -50,40 +51,53 @@
)
(assert_invalid
(module (memory 65537))
"memory size must be at most 65536 pages (4GiB)"
"memory size"
)
(assert_invalid
(module (memory 2147483648))
"memory size must be at most 65536 pages (4GiB)"
"memory size"
)
(assert_invalid
(module (memory 4294967295))
"memory size must be at most 65536 pages (4GiB)"
"memory size"
)
(assert_invalid
(module (memory 0 65537))
"memory size must be at most 65536 pages (4GiB)"
"memory size"
)
(assert_invalid
(module (memory 0 2147483648))
"memory size must be at most 65536 pages (4GiB)"
"memory size"
)
(assert_invalid
(module (memory 0 4294967295))
"memory size must be at most 65536 pages (4GiB)"
"memory size"
)

(assert_invalid
(module quote "(memory 0x1_0000_0000)")
"memory size must be at most 65536 pages (4GiB)"
(module (memory 0x1_0000_0000))
"memory size"
)
(assert_invalid
(module quote "(memory 0x1_0000_0000 0x1_0000_0000)")
"memory size must be at most 65536 pages (4GiB)"
(module (memory 0x1_0000_0000 0x1_0000_0000))
"memory size"
)
(assert_invalid
(module quote "(memory 0 0x1_0000_0000)")
"memory size must be at most 65536 pages (4GiB)"
(module (memory 0 0x1_0000_0000))
"memory size"
)

(assert_invalid
(module (memory (import "M" "m") 0x1_0000_0000))
"memory size"
)
(assert_invalid
(module (memory (import "M" "m") 0x1_0000_0000 0x1_0000_0000))
"memory size"
)
(assert_invalid
(module (memory (import "M" "m") 0 0x1_0000_0000))
"memory size"
)

(module
Expand Down
20 changes: 20 additions & 0 deletions proposals/memory64/memory64.wast
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
(module (memory i64 0 1))
(module (memory i64 1 256))
(module (memory i64 0 65536))
(module definition (memory i64 0x1_0000_0000_0000))
(module (memory i64 0 0x1_0000_0000_0000))

(module (memory i64 (data)) (func (export "memsize") (result i64) (memory.size)))
(assert_return (invoke "memsize") (i64.const 0))
Expand Down Expand Up @@ -48,6 +50,24 @@
"size minimum must not be greater than maximum"
)

(assert_invalid
(module (memory i64 0x1_0000_0000_0001))
"memory size"
)
(assert_invalid
(module (memory i64 0 0x1_0000_0000_0001))
"memory size"
)

(assert_invalid
(module (memory (import "M" "m") i64 0x1_0000_0000_0001))
"memory size"
)
(assert_invalid
(module (memory (import "M" "m") i64 0 0x1_0000_0000_0001))
"memory size"
)

(module
(memory i64 1)
(data (i64.const 0) "ABC\a7D") (data (i64.const 20) "WASM")
Expand Down
10 changes: 7 additions & 3 deletions proposals/memory64/table.wast
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
(module (table 0 1 funcref))
(module (table 1 256 funcref))
(module (table 0 65536 funcref))
(module definition (table 0xffff_ffff funcref))
(module (table 0 0xffff_ffff funcref))

(module (table 1 (ref null func)))
Expand Down Expand Up @@ -33,15 +34,15 @@

(assert_invalid
(module quote "(table 0x1_0000_0000 funcref)")
"table size must be at most 2^32-1"
"table size"
)
(assert_invalid
(module quote "(table 0x1_0000_0000 0x1_0000_0000 funcref)")
"table size must be at most 2^32-1"
"table size"
)
(assert_invalid
(module quote "(table 0 0x1_0000_0000 funcref)")
"table size must be at most 2^32-1"
"table size"
)

;; Same as above but with i64 address types
Expand All @@ -53,6 +54,9 @@
(module (table i64 1 256 funcref))
(module (table i64 0 65536 funcref))
(module (table i64 0 0xffff_ffff funcref))
(module (table i64 0 0x1_0000_0000 funcref))
(module definition (table i64 0xffff_ffff_ffff_ffff funcref))
(module (table i64 0 0xffff_ffff_ffff_ffff funcref))

(module (table i64 0 funcref) (table i64 0 funcref))
(module (table (import "spectest" "table64") i64 0 funcref) (table i64 0 funcref))
Expand Down
File renamed without changes.
Loading