|
14 | 14 | (local $r i32) |
15 | 15 | (local.set $r (call $new (i32.const 100))) |
16 | 16 |
|
17 | | - (if (i32.ne (local.get $r) (i32.const 1)) (then (unreachable))) |
| 17 | + (if (i32.ne (local.get $r) (i32.const 2)) (then (unreachable))) |
18 | 18 | (if (i32.ne (call $rep (local.get $r)) (i32.const 100)) (then (unreachable))) |
19 | 19 |
|
20 | 20 | (call $drop (local.get $r)) |
|
95 | 95 |
|
96 | 96 | ;; resources assigned sequentially |
97 | 97 | (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))) |
99 | 99 |
|
100 | 100 | (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))) |
102 | 102 |
|
103 | 103 | (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))) |
105 | 105 |
|
106 | 106 | ;; representations all look good |
107 | 107 | (if (i32.ne (call $rep (local.get $r1)) (i32.const 100)) (then (unreachable))) |
|
112 | 112 | (call $drop (local.get $r2)) |
113 | 113 | (local.set $r2 (call $new (i32.const 400))) |
114 | 114 |
|
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))) |
117 | 117 |
|
118 | 118 | ;; representations all look good |
119 | 119 | (if (i32.ne (call $rep (local.get $r1)) (i32.const 100)) (then (unreachable))) |
|
135 | 135 | (if (i32.ne (call $rep (local.get $r3)) (i32.const 700)) (then (unreachable))) |
136 | 136 |
|
137 | 137 | ;; 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))) |
141 | 141 |
|
142 | 142 | ;; bump one more time |
143 | 143 | (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))) |
145 | 145 |
|
146 | 146 | ;; deallocate everything |
147 | 147 | (call $drop (local.get $r1)) |
|
241 | 241 | (local.set $r2 (call $ctor (i32.const 200))) |
242 | 242 |
|
243 | 243 | ;; 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))) |
246 | 246 |
|
247 | 247 | ;; reallocate r1 and it should be reassigned the same index |
248 | 248 | (call $drop (local.get $r1)) |
249 | 249 | (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))) |
251 | 251 |
|
252 | 252 | ;; internal values should match |
253 | 253 | (call $assert (local.get $r1) (i32.const 300)) |
|
443 | 443 | (import "" "ctor" (func $ctor (param i32) (result i32))) |
444 | 444 |
|
445 | 445 | (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))) |
447 | 447 | ) |
448 | 448 | (start $start) |
449 | 449 | ) |
|
617 | 617 | (call $drop2 (call $new2 (i32.const 104))) |
618 | 618 |
|
619 | 619 | ;; 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))) |
622 | 622 |
|
623 | 623 | ;; 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)) |
626 | 626 | ) |
627 | 627 |
|
628 | 628 | (start $start) |
|
700 | 700 | (local.set $r1 (call $new1 (i32.const 100))) |
701 | 701 | (local.set $r2 (call $new2 (i32.const 200))) |
702 | 702 |
|
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 |
704 | 704 | ;; 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))) |
707 | 707 |
|
708 | 708 | ;; nothing should be dropped yet |
709 | 709 | (if (i32.ne (call $drops) (i32.const 0)) (then (unreachable))) |
|
866 | 866 | (call $drop (local.get $r2)) |
867 | 867 |
|
868 | 868 | ;; 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))) |
871 | 871 | ) |
872 | 872 |
|
873 | 873 | (start $start) |
|
0 commit comments