1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
// |jit-test| skip-if: !wasmGcEnabled()
// implicit null funcref value
{
const { t, get } = wasmEvalText(`(module
(table (export "t") 3 funcref)
(func (export "get") (param i32) (result funcref)
(table.get (local.get 0))
)
)`).exports;
assertEq(t.get(0), null);
assertEq(t.get(1), null);
assertEq(t.get(2), null);
assertEq(get(0), null);
assertEq(get(1), null);
assertEq(get(2), null);
}
// explicit null funcref value
{
const { t, get } = wasmEvalText(`(module
(table (export "t") 3 funcref (ref.null func))
(func (export "get") (param i32) (result funcref)
(table.get (local.get 0))
)
)`).exports;
assertEq(t.get(0), null);
assertEq(t.get(1), null);
assertEq(t.get(2), null);
assertEq(get(0), null);
assertEq(get(1), null);
assertEq(get(2), null);
}
// actual funcref value
{
const { t, get, foo } = wasmEvalText(`(module
(func $foo (export "foo"))
(table (export "t") 3 funcref (ref.func $foo))
(func (export "get") (param i32) (result funcref)
(table.get (local.get 0))
)
)`).exports;
assertEq(t.get(0), foo);
assertEq(t.get(1), foo);
assertEq(t.get(2), foo);
assertEq(get(0), foo);
assertEq(get(1), foo);
assertEq(get(2), foo);
}
// implicit null anyref value
{
const { t, get } = wasmEvalText(`(module
(table (export "t") 3 anyref)
(func (export "get") (param i32) (result anyref)
(table.get (local.get 0))
)
)`).exports;
assertEq(t.get(0), null);
assertEq(t.get(1), null);
assertEq(t.get(2), null);
assertEq(get(0), null);
assertEq(get(1), null);
assertEq(get(2), null);
}
// explicit null anyref value
{
const { t, get } = wasmEvalText(`(module
(table (export "t") 3 anyref (ref.null any))
(func (export "get") (param i32) (result anyref)
(table.get (local.get 0))
)
)`).exports;
assertEq(t.get(0), null);
assertEq(t.get(1), null);
assertEq(t.get(2), null);
assertEq(get(0), null);
assertEq(get(1), null);
assertEq(get(2), null);
}
// actual anyref value
{
const { t, get } = wasmEvalText(`(module
(type $s (struct))
(table (export "t") 3 anyref (struct.new $s))
(func (export "get") (param i32) (result anyref)
(table.get (local.get 0))
)
)`).exports;
assertEq(!!t.get(0), true);
assertEq(!!t.get(1), true);
assertEq(!!t.get(2), true);
assertEq(!!get(0), true);
assertEq(!!get(1), true);
assertEq(!!get(2), true);
}
// implicit null externref value
{
const { t, get } = wasmEvalText(`(module
(table (export "t") 3 externref)
(func (export "get") (param i32) (result externref)
(table.get (local.get 0))
)
)`).exports;
assertEq(t.get(0), null);
assertEq(t.get(1), null);
assertEq(t.get(2), null);
assertEq(get(0), null);
assertEq(get(1), null);
assertEq(get(2), null);
}
// explicit null externref value
{
const { t, get } = wasmEvalText(`(module
(table (export "t") 3 externref (ref.null extern))
(func (export "get") (param i32) (result externref)
(table.get (local.get 0))
)
)`).exports;
assertEq(t.get(0), null);
assertEq(t.get(1), null);
assertEq(t.get(2), null);
assertEq(get(0), null);
assertEq(get(1), null);
assertEq(get(2), null);
}
// actual externref value (from an imported global, which is visible to tables)
{
const foo = "wowzers";
const { t, get } = wasmEvalText(`(module
(global (import "" "foo") externref)
(table (export "t") 3 externref (global.get 0))
(func (export "get") (param i32) (result externref)
(table.get (local.get 0))
)
)`, { "": { "foo": foo } }).exports;
assertEq(t.get(0), foo);
assertEq(t.get(1), foo);
assertEq(t.get(2), foo);
assertEq(get(0), foo);
assertEq(get(1), foo);
assertEq(get(2), foo);
}
// non-imported globals come after tables and are therefore not visible
assertErrorMessage(() => wasmEvalText(`(module
(global anyref (ref.null any))
(table 3 anyref (global.get 0))
)`), WebAssembly.CompileError, /global.get index out of range/);
|