MCPcopy Index your code
hub / github.com/apache/tvm / constructor

Method constructor

web/src/runtime.ts:889–922  ·  view source on GitHub ↗

* Constructor * * importObject can also be a LibraryProvider object, * a WASI object, or an object containing wasmLibraryProvider field. * * @param wasmModule The input module or instance. * @param importObject The imports to initialize the wasmInstance if it is not provide

(
    wasmModule: WebAssembly.Module,
    importObject: Record<string, any> = {},
    wasmInstance?: WebAssembly.Instance,
    env?: Environment
  )

Source from the content-addressed store, hash-verified

887 * @see Please use the async version {@link instantiate} when targeting browsers.
888 */
889 constructor(
890 wasmModule: WebAssembly.Module,
891 importObject: Record<string, any> = {},
892 wasmInstance?: WebAssembly.Instance,
893 env?: Environment
894 ) {
895 if (wasmInstance instanceof WebAssembly.Instance) {
896 assert(
897 env instanceof Environment,
898 "env must be provided when passing in instance"
899 );
900 } else {
901 assert(env === undefined);
902 env = new Environment(importObject);
903 wasmInstance = new WebAssembly.Instance(wasmModule, env.imports);
904 }
905 env.start(wasmInstance);
906 this.env = env;
907 this.lib = new FFILibrary(wasmInstance, env.imports);
908 this.memory = this.lib.memory;
909 this.exports = this.lib.exports;
910 this.asyncifyHandler = new AsyncifyHandler(this.exports, this.memory.memory);
911 this.objFactory = new Map<number, ObjectConstructor>();
912 this.ctx = new RuntimeContext(
913 (name: string) => {
914 const autoAttachToScope = false;
915 // runtime context function do not auto-release.
916 return this.getGlobalFuncInternal(name, autoAttachToScope);
917 }
918 );
919 this.registerEnvGlobalPackedFuncs();
920 this.registerObjectFactoryFuncs();
921 this.rng = new LinearCongruentialGenerator();
922 }
923
924 /**
925 * Benchmark stable execution of the run function.

Callers

nothing calls this directly

Calls 5

getGlobalFuncInternalMethod · 0.95
assertFunction · 0.90
startMethod · 0.45

Tested by

no test coverage detected