Skip to content

Commit 3de9aa6

Browse files
committed
more WAST tweaks related to thread handles
While rebasing bytecodealliance/wasmtime#12379 onto Wasmtime's `main` branch, I found I needed to tweak the expected resource handle values and trap messages due to subtle changes to when Wasmtime allocates a thread handle. Once #600 lands and is implemented in Wasmtime, we should be able to clean all this up once and for all; for now we just muddle along.
1 parent e1fdcd1 commit 3de9aa6

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

test/async/passing-resources.wast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,4 @@
173173
(func (export "fail-accessing-res1") (alias export $producer "fail-accessing-res1"))
174174
)
175175
(assert_return (invoke "run") (u32.const 42))
176-
(assert_trap (invoke "fail-accessing-res1") "unknown handle index")
176+
(assert_trap (invoke "fail-accessing-res1") "index is not a resource")

test/wasmtime/resources.wast

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
(local $r i32)
1515
(local.set $r (call $new (i32.const 100)))
1616

17-
(if (i32.ne (local.get $r) (i32.const 1)) (then (unreachable)))
17+
(if (i32.ne (local.get $r) (i32.const 2)) (then (unreachable)))
1818
(if (i32.ne (call $rep (local.get $r)) (i32.const 100)) (then (unreachable)))
1919

2020
(call $drop (local.get $r))
@@ -95,13 +95,13 @@
9595

9696
;; resources assigned sequentially
9797
(local.set $r1 (call $new (i32.const 100)))
98-
(if (i32.ne (local.get $r1) (i32.const 1)) (then (unreachable)))
98+
(if (i32.ne (local.get $r1) (i32.const 2)) (then (unreachable)))
9999

100100
(local.set $r2 (call $new (i32.const 200)))
101-
(if (i32.ne (local.get $r2) (i32.const 2)) (then (unreachable)))
101+
(if (i32.ne (local.get $r2) (i32.const 3)) (then (unreachable)))
102102

103103
(local.set $r3 (call $new (i32.const 300)))
104-
(if (i32.ne (local.get $r3) (i32.const 3)) (then (unreachable)))
104+
(if (i32.ne (local.get $r3) (i32.const 4)) (then (unreachable)))
105105

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

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

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

137137
;; indices should be lifo
138-
(if (i32.ne (local.get $r1) (i32.const 3)) (then (unreachable)))
139-
(if (i32.ne (local.get $r2) (i32.const 2)) (then (unreachable)))
140-
(if (i32.ne (local.get $r3) (i32.const 1)) (then (unreachable)))
138+
(if (i32.ne (local.get $r1) (i32.const 4)) (then (unreachable)))
139+
(if (i32.ne (local.get $r2) (i32.const 3)) (then (unreachable)))
140+
(if (i32.ne (local.get $r3) (i32.const 2)) (then (unreachable)))
141141

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

146146
;; deallocate everything
147147
(call $drop (local.get $r1))
@@ -241,13 +241,13 @@
241241
(local.set $r2 (call $ctor (i32.const 200)))
242242

243243
;; assert r1/r2 are sequential
244-
(if (i32.ne (local.get $r1) (i32.const 1)) (then (unreachable)))
245-
(if (i32.ne (local.get $r2) (i32.const 2)) (then (unreachable)))
244+
(if (i32.ne (local.get $r1) (i32.const 2)) (then (unreachable)))
245+
(if (i32.ne (local.get $r2) (i32.const 3)) (then (unreachable)))
246246

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

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

445445
(func $start
446-
(if (i32.ne (call $ctor (i32.const 100)) (i32.const 1)) (then (unreachable)))
446+
(if (i32.ne (call $ctor (i32.const 100)) (i32.const 2)) (then (unreachable)))
447447
)
448448
(start $start)
449449
)
@@ -617,12 +617,12 @@
617617
(call $drop2 (call $new2 (i32.const 104)))
618618

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

623623
;; use different drops out of order
624-
(call $drop2 (i32.const 1))
625-
(call $drop1 (i32.const 2))
624+
(call $drop2 (i32.const 2))
625+
(call $drop1 (i32.const 3))
626626
)
627627

628628
(start $start)
@@ -700,10 +700,10 @@
700700
(local.set $r1 (call $new1 (i32.const 100)))
701701
(local.set $r2 (call $new2 (i32.const 200)))
702702

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

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

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

873873
(start $start)

0 commit comments

Comments
 (0)