Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CachedCallStack

Auxiliary call stack for the FFI calls.

Lifecyle of a call stack.

  • Calls into allocXX to allocate space, mixed with storeXXX to store data.
  • Calls into ptrFromOffset, no further allocation(as ptrFromOffset can change), can still call into storeXX
  • Calls into commitToWasmMemory once.
  • reset.

Hierarchy

  • CachedCallStack

Implements

Index

Constructors

constructor

  • new CachedCallStack(memory: Memory, allocSpace: ctypes.FTVMWasmAllocSpace, freeSpace: ctypes.FTVMWasmFreeSpace): CachedCallStack

Properties

tempArgs

tempArgs: Array<Disposable> = []

List of temporay arguments that can be disposed during reset.

Methods

allocPtrArray

  • Allocate space for pointers.

    Parameters

    • count: number

      Number of pointers.

    Returns PtrOffset

    The allocated pointer array.

allocRawBytes

  • Allocate space by number of bytes

    note

    This function always allocate space that aligns to 64bit.

    Parameters

    • nbytes: number

      Number of bytes.

    Returns PtrOffset

allocThenSetArgBytes

  • allocThenSetArgBytes(offset: PtrOffset, data: Uint8Array): void
  • Allocate then set the argument location with a TVMByteArray. Allocate new temporary space for bytes.

    Parameters

    • offset: PtrOffset

      The offset to set ot data pointer.

    • data: Uint8Array

      The string content.

    Returns void

allocThenSetArgString

  • allocThenSetArgString(offset: PtrOffset, data: string): void
  • Allocate then set C-String pointer to the offset. This function will call into allocBytes to allocate necessary data. The address won't be set immediately(because the possible change of basePtr) and will be filled when we commit the data.

    Parameters

    • offset: PtrOffset

      The offset to set ot data pointer.

    • data: string

      The string content.

    Returns void

commitToWasmMemory

  • commitToWasmMemory(nbytes?: number): void
  • Commit all the cached data to WasmMemory. This function can only be called once. No further store function should be called.

    Parameters

    • Default value nbytes: number = this.stackTop

      Number of bytes to be stored.

    Returns void

dispose

  • dispose(): void

ptrFromOffset

  • Get the real pointer from offset values. Note that the returned value becomes obsolete if alloc is called on the stack.

    Parameters

    Returns Pointer

reset

  • reset(): void
  • Rest the call stack so that it can be reused again.

    Returns void

storeF64

  • storeF64(offset: PtrOffset, value: number): void

storeI32

  • storeI32(offset: PtrOffset, value: number): void

storeI64

  • storeI64(offset: PtrOffset, value: number): void

storePtr

storeRawBytes

  • storeRawBytes(offset: PtrOffset, bytes: Uint8Array): void

storeU32

  • storeU32(offset: PtrOffset, value: number): void

storeUSize

Generated using TypeDoc