Removes unnecessary Engine.CreateElementInstance (#1134)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
@@ -45,10 +45,6 @@ type ModuleEngine interface {
|
||||
// LookupFunction returns the index of the function in the function table.
|
||||
LookupFunction(t *TableInstance, typeId FunctionTypeID, tableOffset Index) (Index, error)
|
||||
|
||||
// CreateFuncElementInstance creates an ElementInstance whose references are engine-specific function pointers
|
||||
// corresponding to the given `indexes`.
|
||||
CreateFuncElementInstance(indexes []*Index) *ElementInstance
|
||||
|
||||
// FunctionInstanceReference returns Reference for the given Index for a FunctionInstance. The returned values are used by
|
||||
// the initialization via ElementSegment.
|
||||
FunctionInstanceReference(funcIndex Index) Reference
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,11 +445,6 @@ func (e *mockModuleEngine) NewCallEngine(callCtx *CallContext, f *FunctionInstan
|
||||
return &mockCallEngine{f: f, callFailIndex: e.callFailIndex}, nil
|
||||
}
|
||||
|
||||
// CreateFuncElementInstance implements the same method as documented on wasm.ModuleEngine.
|
||||
func (e *mockModuleEngine) CreateFuncElementInstance([]*Index) *ElementInstance {
|
||||
return nil
|
||||
}
|
||||
|
||||
// InitializeFuncrefGlobals implements the same method as documented on wasm.ModuleEngine.
|
||||
func (e *mockModuleEngine) InitializeFuncrefGlobals(globals []*GlobalInstance) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user