Removes unnecessary Engine.CreateElementInstance (#1134)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
@@ -588,20 +588,6 @@ func (e *moduleEngine) FunctionInstanceReference(funcIndex wasm.Index) wasm.Refe
|
||||
return uintptr(unsafe.Pointer(&e.functions[funcIndex]))
|
||||
}
|
||||
|
||||
// CreateFuncElementInstance implements the same method as documented on wasm.ModuleEngine.
|
||||
func (e *moduleEngine) CreateFuncElementInstance(indexes []*wasm.Index) *wasm.ElementInstance {
|
||||
refs := make([]wasm.Reference, len(indexes))
|
||||
for i, index := range indexes {
|
||||
if index != nil {
|
||||
refs[i] = uintptr(unsafe.Pointer(&e.functions[*index]))
|
||||
}
|
||||
}
|
||||
return &wasm.ElementInstance{
|
||||
References: refs,
|
||||
Type: wasm.RefTypeFuncref,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *moduleEngine) NewCallEngine(_ *wasm.CallContext, f *wasm.FunctionInstance) (ce wasm.CallEngine, err error) {
|
||||
// Note: The input parameters are pre-validated, so a compiled function is only absent on close. Updates to
|
||||
// code on close aren't locked, neither is this read.
|
||||
|
||||
@@ -737,20 +737,6 @@ func (e *moduleEngine) Name() string {
|
||||
return e.name
|
||||
}
|
||||
|
||||
// CreateFuncElementInstance implements the same method as documented on wasm.ModuleEngine.
|
||||
func (e *moduleEngine) CreateFuncElementInstance(indexes []*wasm.Index) *wasm.ElementInstance {
|
||||
refs := make([]wasm.Reference, len(indexes))
|
||||
for i, index := range indexes {
|
||||
if index != nil {
|
||||
refs[i] = uintptr(unsafe.Pointer(&e.functions[*index]))
|
||||
}
|
||||
}
|
||||
return &wasm.ElementInstance{
|
||||
References: refs,
|
||||
Type: wasm.RefTypeFuncref,
|
||||
}
|
||||
}
|
||||
|
||||
// FunctionInstanceReference implements the same method as documented on wasm.ModuleEngine.
|
||||
func (e *moduleEngine) FunctionInstanceReference(funcIndex wasm.Index) wasm.Reference {
|
||||
return uintptr(unsafe.Pointer(&e.functions[funcIndex]))
|
||||
|
||||
@@ -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