Address review feedback
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
(module
|
||||
(elem funcref (ref.null)))
|
||||
@@ -0,0 +1,7 @@
|
||||
(module
|
||||
(table 1 1 funcref)
|
||||
(elem (i32.const 0) funcref (ref.func 0))
|
||||
(func (export "elem.drop non-passive element")
|
||||
(elem.drop 0)))
|
||||
|
||||
(invoke "elem.drop non-passive element")
|
||||
@@ -0,0 +1,129 @@
|
||||
(module $foreign
|
||||
(memory (export "mem") 1 1)
|
||||
(data 0 (i32.const 1000) "hello")
|
||||
(data 0 (i32.const 2000) "olleh"))
|
||||
|
||||
(register "foreign" $foreign)
|
||||
|
||||
(module
|
||||
(memory (import "foreign" "mem") 1 1)
|
||||
|
||||
(func $is_char (param i32 i32) (result i32)
|
||||
local.get 0
|
||||
i32.load8_u
|
||||
local.get 1
|
||||
i32.eq)
|
||||
|
||||
(func (export "is hello?") (param i32) (result i32)
|
||||
local.get 0
|
||||
i32.const 104 ;; 'h'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 1
|
||||
i32.add
|
||||
i32.const 101 ;; 'e'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 2
|
||||
i32.add
|
||||
i32.const 108 ;; 'l'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 3
|
||||
i32.add
|
||||
i32.const 108 ;; 'l'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 4
|
||||
i32.add
|
||||
i32.const 111 ;; 'o'
|
||||
call $is_char
|
||||
|
||||
i32.and
|
||||
i32.and
|
||||
i32.and
|
||||
i32.and
|
||||
)
|
||||
|
||||
(func (export "is olleh?") (param i32) (result i32)
|
||||
local.get 0
|
||||
i32.const 111 ;; 'o'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 1
|
||||
i32.add
|
||||
i32.const 108 ;; 'l'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 2
|
||||
i32.add
|
||||
i32.const 108 ;; 'l'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 3
|
||||
i32.add
|
||||
i32.const 101 ;; 'e'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 4
|
||||
i32.add
|
||||
i32.const 104 ;; 'h'
|
||||
call $is_char
|
||||
|
||||
i32.and
|
||||
i32.and
|
||||
i32.and
|
||||
i32.and
|
||||
)
|
||||
|
||||
(func (export "memory.copy") (param i32 i32 i32)
|
||||
local.get 0
|
||||
local.get 1
|
||||
local.get 2
|
||||
memory.copy))
|
||||
|
||||
;; Our memory has our initial data in the right places.
|
||||
(assert_return
|
||||
(invoke "is hello?" (i32.const 1000))
|
||||
(i32.const 1))
|
||||
(assert_return
|
||||
(invoke "is olleh?" (i32.const 2000))
|
||||
(i32.const 1))
|
||||
|
||||
;; Non-overlapping memory copy with dst < src.
|
||||
(invoke "memory.copy" (i32.const 500) (i32.const 1000) (i32.const 5))
|
||||
(assert_return
|
||||
(invoke "is hello?" (i32.const 500))
|
||||
(i32.const 1))
|
||||
|
||||
;; Non-overlapping memory copy with dst > src.
|
||||
(invoke "memory.copy" (i32.const 1500) (i32.const 1000) (i32.const 5))
|
||||
(assert_return
|
||||
(invoke "is hello?" (i32.const 1500))
|
||||
(i32.const 1))
|
||||
|
||||
;; Overlapping memory copy with dst < src.
|
||||
(invoke "memory.copy" (i32.const 1998) (i32.const 2000) (i32.const 5))
|
||||
(assert_return
|
||||
(invoke "is olleh?" (i32.const 1998))
|
||||
(i32.const 1))
|
||||
|
||||
;; Overlapping memory copy with dst > src.
|
||||
(invoke "memory.copy" (i32.const 2000) (i32.const 1998) (i32.const 5))
|
||||
(assert_return
|
||||
(invoke "is olleh?" (i32.const 2000))
|
||||
(i32.const 1))
|
||||
|
||||
;; Overlapping memory copy with dst = src.
|
||||
(invoke "memory.copy" (i32.const 2000) (i32.const 2000) (i32.const 5))
|
||||
(assert_return
|
||||
(invoke "is olleh?" (i32.const 2000))
|
||||
(i32.const 1))
|
||||
124
tests/misc_testsuite/bulk-memory-operations/memory-copy.wast
Normal file
124
tests/misc_testsuite/bulk-memory-operations/memory-copy.wast
Normal file
@@ -0,0 +1,124 @@
|
||||
(module
|
||||
(memory 1 1)
|
||||
(data 0 (i32.const 1000) "hello")
|
||||
(data 0 (i32.const 2000) "olleh")
|
||||
|
||||
(func $is_char (param i32 i32) (result i32)
|
||||
local.get 0
|
||||
i32.load8_u
|
||||
local.get 1
|
||||
i32.eq)
|
||||
|
||||
(func (export "is hello?") (param i32) (result i32)
|
||||
local.get 0
|
||||
i32.const 104 ;; 'h'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 1
|
||||
i32.add
|
||||
i32.const 101 ;; 'e'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 2
|
||||
i32.add
|
||||
i32.const 108 ;; 'l'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 3
|
||||
i32.add
|
||||
i32.const 108 ;; 'l'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 4
|
||||
i32.add
|
||||
i32.const 111 ;; 'o'
|
||||
call $is_char
|
||||
|
||||
i32.and
|
||||
i32.and
|
||||
i32.and
|
||||
i32.and
|
||||
)
|
||||
|
||||
(func (export "is olleh?") (param i32) (result i32)
|
||||
local.get 0
|
||||
i32.const 111 ;; 'o'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 1
|
||||
i32.add
|
||||
i32.const 108 ;; 'l'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 2
|
||||
i32.add
|
||||
i32.const 108 ;; 'l'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 3
|
||||
i32.add
|
||||
i32.const 101 ;; 'e'
|
||||
call $is_char
|
||||
|
||||
local.get 0
|
||||
i32.const 4
|
||||
i32.add
|
||||
i32.const 104 ;; 'h'
|
||||
call $is_char
|
||||
|
||||
i32.and
|
||||
i32.and
|
||||
i32.and
|
||||
i32.and
|
||||
)
|
||||
|
||||
(func (export "memory.copy") (param i32 i32 i32)
|
||||
local.get 0
|
||||
local.get 1
|
||||
local.get 2
|
||||
memory.copy))
|
||||
|
||||
;; Our memory has our initial data in the right places.
|
||||
(assert_return
|
||||
(invoke "is hello?" (i32.const 1000))
|
||||
(i32.const 1))
|
||||
(assert_return
|
||||
(invoke "is olleh?" (i32.const 2000))
|
||||
(i32.const 1))
|
||||
|
||||
;; Non-overlapping memory copy with dst < src.
|
||||
(invoke "memory.copy" (i32.const 500) (i32.const 1000) (i32.const 5))
|
||||
(assert_return
|
||||
(invoke "is hello?" (i32.const 500))
|
||||
(i32.const 1))
|
||||
|
||||
;; Non-overlapping memory copy with dst > src.
|
||||
(invoke "memory.copy" (i32.const 1500) (i32.const 1000) (i32.const 5))
|
||||
(assert_return
|
||||
(invoke "is hello?" (i32.const 1500))
|
||||
(i32.const 1))
|
||||
|
||||
;; Overlapping memory copy with dst < src.
|
||||
(invoke "memory.copy" (i32.const 1998) (i32.const 2000) (i32.const 5))
|
||||
(assert_return
|
||||
(invoke "is olleh?" (i32.const 1998))
|
||||
(i32.const 1))
|
||||
|
||||
;; Overlapping memory copy with dst > src.
|
||||
(invoke "memory.copy" (i32.const 2000) (i32.const 1998) (i32.const 5))
|
||||
(assert_return
|
||||
(invoke "is olleh?" (i32.const 2000))
|
||||
(i32.const 1))
|
||||
|
||||
;; Overlapping memory copy with dst = src.
|
||||
(invoke "memory.copy" (i32.const 2000) (i32.const 2000) (i32.const 5))
|
||||
(assert_return
|
||||
(invoke "is olleh?" (i32.const 2000))
|
||||
(i32.const 1))
|
||||
63
tests/misc_testsuite/bulk-memory-operations/table_copy.wast
Normal file
63
tests/misc_testsuite/bulk-memory-operations/table_copy.wast
Normal file
@@ -0,0 +1,63 @@
|
||||
(module
|
||||
(func $f (param i32 i32 i32) (result i32) (local.get 0))
|
||||
(func $g (param i32 i32 i32) (result i32) (local.get 1))
|
||||
(func $h (param i32 i32 i32) (result i32) (local.get 2))
|
||||
|
||||
;; Indices: 0 1 2 3 4 5 6 7 8
|
||||
(table funcref (elem $f $g $h $f $g $h $f $g $h))
|
||||
;; After table.copy: $g $h $f
|
||||
|
||||
(func (export "copy") (param i32 i32 i32)
|
||||
local.get 0
|
||||
local.get 1
|
||||
local.get 2
|
||||
table.copy)
|
||||
|
||||
(func (export "call") (param i32 i32 i32 i32) (result i32)
|
||||
local.get 0
|
||||
local.get 1
|
||||
local.get 2
|
||||
local.get 3
|
||||
call_indirect (param i32 i32 i32) (result i32))
|
||||
)
|
||||
|
||||
;; Call $f at 0
|
||||
(assert_return
|
||||
(invoke "call" (i32.const 1) (i32.const 0) (i32.const 0) (i32.const 0))
|
||||
(i32.const 1))
|
||||
|
||||
;; Call $g at 1
|
||||
(assert_return
|
||||
(invoke "call" (i32.const 0) (i32.const 1) (i32.const 0) (i32.const 1))
|
||||
(i32.const 1))
|
||||
|
||||
;; Call $h at 2
|
||||
(assert_return
|
||||
(invoke "call" (i32.const 0) (i32.const 0) (i32.const 1) (i32.const 2))
|
||||
(i32.const 1))
|
||||
|
||||
;; Do a `table.copy` to rearrange the elements. Copy from 4..7 to 0..3.
|
||||
(invoke "copy" (i32.const 0) (i32.const 4) (i32.const 3))
|
||||
|
||||
;; Call $g at 0
|
||||
(assert_return
|
||||
(invoke "call" (i32.const 0) (i32.const 1) (i32.const 0) (i32.const 0))
|
||||
(i32.const 1))
|
||||
|
||||
;; Call $h at 1
|
||||
(assert_return
|
||||
(invoke "call" (i32.const 0) (i32.const 0) (i32.const 1) (i32.const 1))
|
||||
(i32.const 1))
|
||||
|
||||
;; Call $f at 2
|
||||
(assert_return
|
||||
(invoke "call" (i32.const 1) (i32.const 0) (i32.const 0) (i32.const 2))
|
||||
(i32.const 1))
|
||||
|
||||
;; Copying up to the end does not trap.
|
||||
(invoke "copy" (i32.const 7) (i32.const 0) (i32.const 2))
|
||||
|
||||
;; Copying past the end traps.
|
||||
(assert_trap
|
||||
(invoke "copy" (i32.const 7) (i32.const 0) (i32.const 3))
|
||||
"undefined element")
|
||||
Reference in New Issue
Block a user