Fixes element instance for imported global func ref (#2141)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
This commit is contained in:
@@ -1065,8 +1065,15 @@ func Test2136(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test2137(t *testing.T) {
|
||||
r := wazero.NewRuntime(context.Background())
|
||||
_, err := r.CompileModule(ctx, getWasmBinary(t, "2137"))
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, r.Close(ctx))
|
||||
if !platform.CompilerSupported() {
|
||||
return
|
||||
}
|
||||
nodiff.RequireNoDiffT(t, getWasmBinary(t, "2137"), true, true)
|
||||
}
|
||||
|
||||
func Test2140(t *testing.T) {
|
||||
if !platform.CompilerSupported() {
|
||||
return
|
||||
}
|
||||
nodiff.RequireNoDiffT(t, getWasmBinary(t, "2140"), true, true)
|
||||
}
|
||||
|
||||
BIN
internal/integration_test/fuzzcases/testdata/2140.wasm
vendored
Normal file
BIN
internal/integration_test/fuzzcases/testdata/2140.wasm
vendored
Normal file
Binary file not shown.
4
internal/integration_test/fuzzcases/testdata/2140.wat
vendored
Normal file
4
internal/integration_test/fuzzcases/testdata/2140.wat
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
(module
|
||||
(import "hh" "" (global (;0;) funcref))
|
||||
(elem (;0;) funcref (ref.null func) (ref.null func) (ref.null func) (global.get 0) (ref.null func))
|
||||
)
|
||||
@@ -179,8 +179,13 @@ func (m *ModuleInstance) buildElementInstances(elements []ElementSegment) {
|
||||
inst := make([]Reference, len(inits))
|
||||
m.ElementInstances[i] = inst
|
||||
for j, idx := range inits {
|
||||
if idx != ElementInitNullReference {
|
||||
inst[j] = m.Engine.FunctionInstanceReference(idx)
|
||||
if index, ok := unwrapElementInitGlobalReference(idx); ok {
|
||||
global := m.Globals[index]
|
||||
inst[j] = Reference(global.Val)
|
||||
} else {
|
||||
if idx != ElementInitNullReference {
|
||||
inst[j] = m.Engine.FunctionInstanceReference(idx)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user