Removes unnecessary Engine.CreateElementInstance (#1134)

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
Takeshi Yoneda
2023-02-17 01:20:09 -08:00
committed by GitHub
parent b7a7570d15
commit add6458c99
5 changed files with 10 additions and 38 deletions

View File

@@ -162,7 +162,16 @@ func (m *ModuleInstance) buildElementInstances(elements []*ElementSegment) {
if elm.Type == RefTypeFuncref && elm.Mode == ElementModePassive {
// Only passive elements can be access as element instances.
// See https://www.w3.org/TR/2022/WD-wasm-core-2-20220419/syntax/modules.html#element-segments
m.ElementInstances[i] = *m.Engine.CreateFuncElementInstance(elm.Init)
inits := elm.Init
elemInst := &m.ElementInstances[i]
elemInst.References = make([]Reference, len(inits))
elemInst.Type = RefTypeFuncref
for j, idxPtr := range inits {
if idxPtr != nil {
idx := *idxPtr
elemInst.References[j] = m.Engine.FunctionInstanceReference(idx)
}
}
}
}
}