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 test/async/passing-resources.wast
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@
(func (export "fail-accessing-res1") (alias export $producer "fail-accessing-res1"))
)
(assert_return (invoke "run") (u32.const 42))
(assert_trap (invoke "fail-accessing-res1") "unknown handle index")
(assert_trap (invoke "fail-accessing-res1") "index is not a resource")
46 changes: 23 additions & 23 deletions test/wasmtime/resources.wast
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(local $r i32)
(local.set $r (call $new (i32.const 100)))

(if (i32.ne (local.get $r) (i32.const 1)) (then (unreachable)))
(if (i32.ne (local.get $r) (i32.const 2)) (then (unreachable)))
(if (i32.ne (call $rep (local.get $r)) (i32.const 100)) (then (unreachable)))

(call $drop (local.get $r))
Expand Down Expand Up @@ -95,13 +95,13 @@

;; resources assigned sequentially
(local.set $r1 (call $new (i32.const 100)))
(if (i32.ne (local.get $r1) (i32.const 1)) (then (unreachable)))
(if (i32.ne (local.get $r1) (i32.const 2)) (then (unreachable)))

(local.set $r2 (call $new (i32.const 200)))
(if (i32.ne (local.get $r2) (i32.const 2)) (then (unreachable)))
(if (i32.ne (local.get $r2) (i32.const 3)) (then (unreachable)))

(local.set $r3 (call $new (i32.const 300)))
(if (i32.ne (local.get $r3) (i32.const 3)) (then (unreachable)))
(if (i32.ne (local.get $r3) (i32.const 4)) (then (unreachable)))

;; representations all look good
(if (i32.ne (call $rep (local.get $r1)) (i32.const 100)) (then (unreachable)))
Expand All @@ -112,8 +112,8 @@
(call $drop (local.get $r2))
(local.set $r2 (call $new (i32.const 400)))

;; should have reused index 1
(if (i32.ne (local.get $r2) (i32.const 2)) (then (unreachable)))
;; should have reused index 3
(if (i32.ne (local.get $r2) (i32.const 3)) (then (unreachable)))

;; representations all look good
(if (i32.ne (call $rep (local.get $r1)) (i32.const 100)) (then (unreachable)))
Expand All @@ -135,13 +135,13 @@
(if (i32.ne (call $rep (local.get $r3)) (i32.const 700)) (then (unreachable)))

;; indices should be lifo
(if (i32.ne (local.get $r1) (i32.const 3)) (then (unreachable)))
(if (i32.ne (local.get $r2) (i32.const 2)) (then (unreachable)))
(if (i32.ne (local.get $r3) (i32.const 1)) (then (unreachable)))
(if (i32.ne (local.get $r1) (i32.const 4)) (then (unreachable)))
(if (i32.ne (local.get $r2) (i32.const 3)) (then (unreachable)))
(if (i32.ne (local.get $r3) (i32.const 2)) (then (unreachable)))

;; bump one more time
(local.set $r4 (call $new (i32.const 800)))
(if (i32.ne (local.get $r4) (i32.const 4)) (then (unreachable)))
(if (i32.ne (local.get $r4) (i32.const 5)) (then (unreachable)))

;; deallocate everything
(call $drop (local.get $r1))
Expand Down Expand Up @@ -241,13 +241,13 @@
(local.set $r2 (call $ctor (i32.const 200)))

;; assert r1/r2 are sequential
(if (i32.ne (local.get $r1) (i32.const 1)) (then (unreachable)))
(if (i32.ne (local.get $r2) (i32.const 2)) (then (unreachable)))
(if (i32.ne (local.get $r1) (i32.const 2)) (then (unreachable)))
(if (i32.ne (local.get $r2) (i32.const 3)) (then (unreachable)))

;; reallocate r1 and it should be reassigned the same index
(call $drop (local.get $r1))
(local.set $r1 (call $ctor (i32.const 300)))
(if (i32.ne (local.get $r1) (i32.const 1)) (then (unreachable)))
(if (i32.ne (local.get $r1) (i32.const 2)) (then (unreachable)))

;; internal values should match
(call $assert (local.get $r1) (i32.const 300))
Expand Down Expand Up @@ -443,7 +443,7 @@
(import "" "ctor" (func $ctor (param i32) (result i32)))

(func $start
(if (i32.ne (call $ctor (i32.const 100)) (i32.const 1)) (then (unreachable)))
(if (i32.ne (call $ctor (i32.const 100)) (i32.const 2)) (then (unreachable)))
)
(start $start)
)
Expand Down Expand Up @@ -617,12 +617,12 @@
(call $drop2 (call $new2 (i32.const 104)))

;; should be referencing the same namespace
(if (i32.ne (call $new1 (i32.const 105)) (i32.const 1)) (then (unreachable)))
(if (i32.ne (call $new2 (i32.const 105)) (i32.const 2)) (then (unreachable)))
(if (i32.ne (call $new1 (i32.const 105)) (i32.const 2)) (then (unreachable)))
(if (i32.ne (call $new2 (i32.const 105)) (i32.const 3)) (then (unreachable)))

;; use different drops out of order
(call $drop2 (i32.const 1))
(call $drop1 (i32.const 2))
(call $drop2 (i32.const 2))
(call $drop1 (i32.const 3))
)

(start $start)
Expand Down Expand Up @@ -700,10 +700,10 @@
(local.set $r1 (call $new1 (i32.const 100)))
(local.set $r2 (call $new2 (i32.const 200)))

;; indexes start at 1 and while they have distinct types they should be
;; indexes start at 2 and while they have distinct types they should be
;; within the same table.
(if (i32.ne (local.get $r1) (i32.const 1)) (then (unreachable)))
(if (i32.ne (local.get $r2) (i32.const 2)) (then (unreachable)))
(if (i32.ne (local.get $r1) (i32.const 2)) (then (unreachable)))
(if (i32.ne (local.get $r2) (i32.const 3)) (then (unreachable)))

;; nothing should be dropped yet
(if (i32.ne (call $drops) (i32.const 0)) (then (unreachable)))
Expand Down Expand Up @@ -866,8 +866,8 @@
(call $drop (local.get $r2))

;; table should be empty at this point, so a fresh allocation should get
;; index 0
(if (i32.ne (call $ctor (i32.const 600)) (i32.const 1)) (then (unreachable)))
;; index 2
(if (i32.ne (call $ctor (i32.const 600)) (i32.const 2)) (then (unreachable)))
)

(start $start)
Expand Down