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

Method packedFunc

web/src/runtime.ts:2208–2230  ·  view source on GitHub ↗
(...args: any)

Source from the content-addressed store, hash-verified

2206 private makePackedFunc(handle: Pointer): PackedFunc {
2207 const cell = new PackedFuncCell(handle, this.lib, this.ctx);
2208 const packedFunc = (...args: any): any => {
2209 const stack = this.lib.getOrAllocCallStack();
2210 const argsOffset = stack.allocRawBytes(SizeOf.TVMFFIAny * args.length);
2211 this.setPackedArguments(stack, args, argsOffset);
2212 const retOffset = stack.allocRawBytes(SizeOf.TVMFFIAny);
2213 // pre-store the result to be null
2214 stack.storeI32(retOffset, TypeIndex.kTVMFFINone);
2215 // clear off the extra zero padding before ptr storage
2216 stack.storeI32(retOffset + SizeOf.I32, 0);
2217 stack.commitToWasmMemory();
2218 this.lib.checkCall(
2219 (this.exports.TVMFFIFunctionCall as ctypes.FTVMFFIFunctionCall)(
2220 cell.getHandle(),
2221 stack.ptrFromOffset(argsOffset),
2222 args.length,
2223 stack.ptrFromOffset(retOffset)
2224 )
2225 );
2226
2227 const ret = this.retValueToJS(stack.ptrFromOffset(retOffset), false);
2228 this.lib.recycleCallStack(stack);
2229 return ret;
2230 };
2231 // Attach attributes to the function type.
2232 // This is because javascript do not allow us to overload call.
2233 const ret: any = packedFunc;

Callers

nothing calls this directly

Calls 10

setPackedArgumentsMethod · 0.95
retValueToJSMethod · 0.95
getOrAllocCallStackMethod · 0.80
allocRawBytesMethod · 0.80
storeI32Method · 0.80
commitToWasmMemoryMethod · 0.80
getHandleMethod · 0.80
ptrFromOffsetMethod · 0.80
recycleCallStackMethod · 0.80
checkCallMethod · 0.45

Tested by

no test coverage detected