Skip to content

Commit

Permalink
[spec/interpreter/test] Land bulk instructions & reference types prop…
Browse files Browse the repository at this point in the history
…osals (WebAssembly#1287)
  • Loading branch information
gumb0 committed Apr 14, 2021
1 parent 5ed9d56 commit 6407be7
Show file tree
Hide file tree
Showing 8 changed files with 967 additions and 181 deletions.
708 changes: 697 additions & 11 deletions test/core/binary.wast

Large diffs are not rendered by default.

115 changes: 69 additions & 46 deletions test/core/data.wast
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,26 @@
(data (i32.const 1) "a" "" "bcd")
(data (offset (i32.const 0)))
(data (offset (i32.const 0)) "" "a" "bc" "")
(data 0 (i32.const 0))
(data 0x0 (i32.const 1) "a" "" "bcd")
(data 0x000 (offset (i32.const 0)))
(data 0 (offset (i32.const 0)) "" "a" "bc" "")
(data $m (i32.const 0))
(data $m (i32.const 1) "a" "" "bcd")
(data $m (offset (i32.const 0)))
(data $m (offset (i32.const 0)) "" "a" "bc" "")
(data (memory 0) (i32.const 0))
(data (memory 0x0) (i32.const 1) "a" "" "bcd")
(data (memory 0x000) (offset (i32.const 0)))
(data (memory 0) (offset (i32.const 0)) "" "a" "bc" "")
(data (memory $m) (i32.const 0))
(data (memory $m) (i32.const 1) "a" "" "bcd")
(data (memory $m) (offset (i32.const 0)))
(data (memory $m) (offset (i32.const 0)) "" "a" "bc" "")
(data $d1 (i32.const 0))
(data $d2 (i32.const 1) "a" "" "bcd")
(data $d3 (offset (i32.const 0)))
(data $d4 (offset (i32.const 0)) "" "a" "bc" "")
(data $d5 (memory 0) (i32.const 0))
(data $d6 (memory 0x0) (i32.const 1) "a" "" "bcd")
(data $d7 (memory 0x000) (offset (i32.const 0)))
(data $d8 (memory 0) (offset (i32.const 0)) "" "a" "bc" "")
(data $d9 (memory $m) (i32.const 0))
(data $d10 (memory $m) (i32.const 1) "a" "" "bcd")
(data $d11 (memory $m) (offset (i32.const 0)))
(data $d12 (memory $m) (offset (i32.const 0)) "" "a" "bc" "")
)

;; Basic use
Expand Down Expand Up @@ -158,44 +170,42 @@

;; Invalid bounds for data

(assert_unlinkable
(assert_trap
(module
(memory 0)
(data (i32.const 0) "a")
)
"data segment does not fit"
"out of bounds memory access"
)

(assert_unlinkable
(assert_trap
(module
(memory 0 0)
(data (i32.const 0) "a")
)
"data segment does not fit"
"out of bounds memory access"
)

(assert_unlinkable
(assert_trap
(module
(memory 0 1)
(data (i32.const 0) "a")
)
"data segment does not fit"
"out of bounds memory access"
)

(assert_unlinkable
(assert_trap
(module
(memory 0)
(data (i32.const 1))
)
"data segment does not fit"
"out of bounds memory access"
)

(assert_unlinkable
(assert_trap
(module
(memory 0 1)
(data (i32.const 1))
)
"data segment does not fit"
"out of bounds memory access"
)

;; This seems to cause a time-out on Travis.
Expand All @@ -204,77 +214,77 @@
(memory 0x10000)
(data (i32.const 0xffffffff) "ab")
)
"" ;; either out of memory or segment does not fit
"" ;; either out of memory or out of bounds
;)

(assert_unlinkable
(assert_trap
(module
(global (import "spectest" "global_i32") i32)
(memory 0)
(data (global.get 0) "a")
)
"data segment does not fit"
"out of bounds memory access"
)

(assert_unlinkable
(assert_trap
(module
(memory 1 2)
(data (i32.const 0x1_0000) "a")
)
"data segment does not fit"
"out of bounds memory access"
)
(assert_unlinkable
(assert_trap
(module
(import "spectest" "memory" (memory 1))
(data (i32.const 0x1_0000) "a")
)
"data segment does not fit"
"out of bounds memory access"
)

(assert_unlinkable
(assert_trap
(module
(memory 2)
(data (i32.const 0x2_0000) "a")
)
"data segment does not fit"
"out of bounds memory access"
)

(assert_unlinkable
(assert_trap
(module
(memory 2 3)
(data (i32.const 0x2_0000) "a")
)
"data segment does not fit"
"out of bounds memory access"
)

(assert_unlinkable
(assert_trap
(module
(memory 1)
(data (i32.const -1) "a")
)
"data segment does not fit"
"out of bounds memory access"
)
(assert_unlinkable
(assert_trap
(module
(import "spectest" "memory" (memory 1))
(data (i32.const -1) "a")
)
"data segment does not fit"
"out of bounds memory access"
)

(assert_unlinkable
(assert_trap
(module
(memory 2)
(data (i32.const -100) "a")
)
"data segment does not fit"
"out of bounds memory access"
)
(assert_unlinkable
(assert_trap
(module
(import "spectest" "memory" (memory 1))
(data (i32.const -100) "a")
)
"data segment does not fit"
"out of bounds memory access"
)

;; Data without memory
Expand All @@ -292,19 +302,30 @@
"\00asm" "\01\00\00\00"
"\05\03\01" ;; memory section
"\00\00" ;; memory 0
"\0b\06\01" ;; data section
"\01\41\00\0b" ;; data segment 0 for memory 1
"\0b\07\01" ;; data section
"\02\01\41\00\0b" ;; active data segment 0 for memory 1
"\00" ;; empty vec(byte)
)
"unknown memory 1"
)

;; Data segment with memory index 1 (no memory section)
;; Data segment with memory index 0 (no memory section)
(assert_invalid
(module binary
"\00asm" "\01\00\00\00"
"\0b\06\01" ;; data section
"\01\41\00\0b" ;; data segment 0 for memory 1
"\00\41\00\0b" ;; active data segment 0 for memory 0
"\00" ;; empty vec(byte)
)
"unknown memory 0"
)

;; Data segment with memory index 1 (no memory section)
(assert_invalid
(module binary
"\00asm" "\01\00\00\00"
"\0b\07\01" ;; data section
"\02\01\41\00\0b" ;; active data segment 0 for memory 1
"\00" ;; empty vec(byte)
)
"unknown memory 1"
Expand All @@ -317,7 +338,8 @@
"\00asm" "\01\00\00\00"
"\05\03\01" ;; memory section
"\00\00" ;; memory 0
"\0b\44\01" ;; data section
"\0b\45\01" ;; data section
"\02" ;; active segment
"\01" ;; memory index
"\41\00\0b" ;; offset constant expression
"\3e" ;; vec(byte) length
Expand All @@ -336,7 +358,8 @@
(assert_invalid
(module binary
"\00asm" "\01\00\00\00"
"\0b\44\01" ;; data section
"\0b\45\01" ;; data section
"\02" ;; active segment
"\01" ;; memory index
"\41\00\0b" ;; offset constant expression
"\3e" ;; vec(byte) length
Expand Down Expand Up @@ -455,4 +478,4 @@
(data (global.get 0))
)
"constant expression required"
)
)
49 changes: 24 additions & 25 deletions test/core/elem.wast
Original file line number Diff line number Diff line change
Expand Up @@ -139,107 +139,106 @@

;; Invalid bounds for elements

(assert_unlinkable
(assert_trap
(module
(table 0 funcref)
(func $f)
(elem (i32.const 0) $f)
)
"elements segment does not fit"
"out of bounds table access"
)

(assert_unlinkable
(assert_trap
(module
(table 0 0 funcref)
(func $f)
(elem (i32.const 0) $f)
)
"elements segment does not fit"
"out of bounds table access"
)

(assert_unlinkable
(assert_trap
(module
(table 0 1 funcref)
(func $f)
(elem (i32.const 0) $f)
)
"elements segment does not fit"
"out of bounds table access"
)

(assert_unlinkable
(assert_trap
(module
(table 0 funcref)
(elem (i32.const 1))
)
"elements segment does not fit"
"out of bounds table access"
)

(assert_unlinkable
(assert_trap
(module
(table 10 funcref)
(func $f)
(elem (i32.const 10) $f)
)
"elements segment does not fit"
"out of bounds table access"
)
(assert_unlinkable
(assert_trap
(module
(import "spectest" "table" (table 10 funcref))
(func $f)
(elem (i32.const 10) $f)
)
"elements segment does not fit"
"out of bounds table access"
)

(assert_unlinkable
(assert_trap
(module
(table 10 20 funcref)
(func $f)
(elem (i32.const 10) $f)
)
"elements segment does not fit"
"out of bounds table access"
)
(assert_unlinkable
(assert_trap
(module
(import "spectest" "table" (table 10 funcref))
(func $f)
(elem (i32.const 10) $f)
)
"elements segment does not fit"
"out of bounds table access"
)

(assert_unlinkable
(assert_trap
(module
(table 10 funcref)
(func $f)
(elem (i32.const -1) $f)
)
"elements segment does not fit"
"out of bounds table access"
)
(assert_unlinkable
(assert_trap
(module
(import "spectest" "table" (table 10 funcref))
(func $f)
(elem (i32.const -1) $f)
)
"elements segment does not fit"
"out of bounds table access"
)

(assert_unlinkable
(assert_trap
(module
(table 10 funcref)
(func $f)
(elem (i32.const -10) $f)
)
"elements segment does not fit"
"out of bounds table access"
)
(assert_unlinkable
(assert_trap
(module
(import "spectest" "table" (table 10 funcref))
(func $f)
(elem (i32.const -10) $f)
)
"elements segment does not fit"
"out of bounds table access"
)

;; Element without table
Expand Down
9 changes: 9 additions & 0 deletions test/core/global.wast
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@

(assert_return (invoke "set-x" (i32.const 6)))
(assert_return (invoke "set-y" (i64.const 7)))

(assert_return (invoke "set-7" (f32.const 8)))
(assert_return (invoke "set-8" (f64.const 9)))

(assert_return (invoke "get-x") (i32.const 6))
(assert_return (invoke "get-y") (i64.const 7))
(assert_return (invoke "get-7") (f32.const 8))
(assert_return (invoke "get-8") (f64.const 9))

(assert_return (invoke "set-7" (f32.const 8)))
(assert_return (invoke "set-8" (f64.const 9)))

Expand Down
Loading

0 comments on commit 6407be7

Please sign in to comment.