MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime-go / Instantiate

Method Instantiate

linker.go:242–254  ·  view source on GitHub ↗

Instantiate instantiates a module with all imports defined in this linker. Returns an error if the instance's imports couldn't be satisfied, had the wrong types, or if a trap happened executing the start function.

(store Storelike, module *Module)

Source from the content-addressed store, hash-verified

240// Returns an error if the instance's imports couldn't be satisfied, had the
241// wrong types, or if a trap happened executing the start function.
242func (l *Linker) Instantiate(store Storelike, module *Module) (*Instance, error) {
243 var ret C.wasmtime_instance_t
244 err := enterWasm(store, func(trap **C.wasm_trap_t) *C.wasmtime_error_t {
245 return C.wasmtime_linker_instantiate(l.ptr(), store.Context(), module.ptr(), &ret, trap)
246 })
247 runtime.KeepAlive(l)
248 runtime.KeepAlive(module)
249 runtime.KeepAlive(store)
250 if err != nil {
251 return nil, err
252 }
253 return mkInstance(ret), nil
254}
255
256// GetDefault acquires the "default export" of the named module in this linker.
257//

Callers 12

TestLinkerFunction · 0.95
TestLinkerTrapFunction · 0.95
TestLinkerModuleFunction · 0.95
TestLinkerFuncsFunction · 0.95
ExampleLinkerFunction · 0.95
ExampleWasiConfigFunction · 0.95
Example_storedataFunction · 0.95

Calls 4

ptrMethod · 0.95
enterWasmFunction · 0.85
mkInstanceFunction · 0.85
ContextMethod · 0.65

Tested by 12

TestLinkerFunction · 0.76
TestLinkerTrapFunction · 0.76
TestLinkerModuleFunction · 0.76
TestLinkerFuncsFunction · 0.76
ExampleLinkerFunction · 0.76
ExampleWasiConfigFunction · 0.76
Example_storedataFunction · 0.76