| 1 |
// White-box test for bug 1617908. The significance of this test is that the |
| 2 |
// type $S is too large to fit in an inline WasmGcObject, and the write barrier |
| 3 |
// logic must take this into account when storing the (ref $S2) into the last |
| 4 |
// field of the object. |
| 5 |
|
| 6 |
const wat = ` |
| 7 |
(module |
| 8 |
(type $S2 (sub (struct))) |
| 9 |
(type $S (sub $S2 |
| 10 |
(struct |
| 11 |
(field (mut i64)) |
| 12 |
(field (mut i64)) |
| 13 |
(field (mut i64)) |
| 14 |
(field (mut i64)) |
| 15 |
(field (mut i64)) |
| 16 |
(field (mut i64)) |
| 17 |
(field (mut i64)) |
| 18 |
(field (mut i64)) |
| 19 |
(field (mut i64)) |
| 20 |
(field (mut i64)) |
| 21 |
(field (mut i64)) |
| 22 |
(field (mut i64)) |
| 23 |
(field (mut i64)) |
| 24 |
(field (mut i64)) |
| 25 |
(field (mut i64)) |
| 26 |
(field (mut i64)) |
| 27 |
(field (mut i64)) |
| 28 |
(field (mut i64)) |
| 29 |
(field (mut eqref))))) |
| 30 |
|
| 31 |
(func $main |
| 32 |
(struct.set $S 18 |
| 33 |
(struct.new $S |
| 34 |
(i64.const 0) |
| 35 |
(i64.const 0) |
| 36 |
(i64.const 0) |
| 37 |
(i64.const 0) |
| 38 |
(i64.const 0) |
| 39 |
(i64.const 0) |
| 40 |
(i64.const 0) |
| 41 |
(i64.const 0) |
| 42 |
(i64.const 0) |
| 43 |
(i64.const 0) |
| 44 |
(i64.const 0) |
| 45 |
(i64.const 0) |
| 46 |
(i64.const 0) |
| 47 |
(i64.const 0) |
| 48 |
(i64.const 0) |
| 49 |
(i64.const 0) |
| 50 |
(i64.const 0) |
| 51 |
(i64.const 0) |
| 52 |
(ref.null eq)) |
| 53 |
(struct.new $S2))) |
| 54 |
(start $main)) |
| 55 |
` |
| 56 |
wasmEvalText(wat); |
| 57 |
|
| 58 |
// Test subtyping across outline/inline representations works |
| 59 |
|
| 60 |
wasmEvalText(` |
| 61 |
(module |
| 62 |
(type $inline |
| 63 |
(sub (struct |
| 64 |
(field (mut i64)) |
| 65 |
(field (mut i64)) |
| 66 |
(field (mut i64)) |
| 67 |
(field (mut i64)) |
| 68 |
(field (mut i64)) |
| 69 |
))) |
| 70 |
(type $outline (sub $inline |
| 71 |
(struct |
| 72 |
(field (mut i64)) |
| 73 |
(field (mut i64)) |
| 74 |
(field (mut i64)) |
| 75 |
(field (mut i64)) |
| 76 |
(field (mut i64)) |
| 77 |
(field (mut i64)) |
| 78 |
(field (mut i64)) |
| 79 |
(field (mut i64)) |
| 80 |
(field (mut i64)) |
| 81 |
(field (mut i64)) |
| 82 |
(field (mut i64)) |
| 83 |
(field (mut i64)) |
| 84 |
(field (mut i64)) |
| 85 |
(field (mut i64)) |
| 86 |
(field (mut i64)) |
| 87 |
(field (mut i64)) |
| 88 |
(field (mut i64)) |
| 89 |
(field (mut i64)) |
| 90 |
(field (mut i64))))) |
| 91 |
|
| 92 |
(func $main |
| 93 |
(local $outline (ref null $outline)) |
| 94 |
(local $inline (ref null $inline)) |
| 95 |
|
| 96 |
(; create an outline object and acquire multiple views to it ;) |
| 97 |
(struct.new $outline |
| 98 |
(i64.const 0xFF) |
| 99 |
(i64.const 0) |
| 100 |
(i64.const 0) |
| 101 |
(i64.const 0) |
| 102 |
(i64.const 0) |
| 103 |
(i64.const 0) |
| 104 |
(i64.const 0) |
| 105 |
(i64.const 0) |
| 106 |
(i64.const 0) |
| 107 |
(i64.const 0) |
| 108 |
(i64.const 0) |
| 109 |
(i64.const 0) |
| 110 |
(i64.const 0) |
| 111 |
(i64.const 0) |
| 112 |
(i64.const 0) |
| 113 |
(i64.const 0) |
| 114 |
(i64.const 0) |
| 115 |
(i64.const 0) |
| 116 |
(i64.const 0)) |
| 117 |
local.tee $outline |
| 118 |
local.set $inline |
| 119 |
|
| 120 |
(; clobber the object header ;) |
| 121 |
(struct.set $inline 0 |
| 122 |
local.get $inline |
| 123 |
i64.const 0 |
| 124 |
) |
| 125 |
(struct.set $inline 1 |
| 126 |
local.get $inline |
| 127 |
i64.const 0 |
| 128 |
) |
| 129 |
(struct.set $inline 2 |
| 130 |
local.get $inline |
| 131 |
i64.const 0 |
| 132 |
) |
| 133 |
(struct.set $inline 3 |
| 134 |
local.get $inline |
| 135 |
i64.const 0 |
| 136 |
) |
| 137 |
(struct.set $inline 4 |
| 138 |
local.get $inline |
| 139 |
i64.const 0 |
| 140 |
) |
| 141 |
|
| 142 |
(; try to read a field ;) |
| 143 |
(struct.get $outline 0 |
| 144 |
local.get $outline |
| 145 |
) |
| 146 |
drop |
| 147 |
) |
| 148 |
(start $main)) |
| 149 |
`); |