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

Constructors

Properties

tempArgs: Disposable[] = []

List of temporay arguments that can be disposed during reset.

Methods

  • Allocate space for pointers.

    Parameters

    • count: number

      Number of pointers.

    Returns number

    The allocated pointer array.

  • Allocate space by number of bytes

    Note

    This function always allocate space that aligns to 64bit.

    Parameters

    • nbytes: number

      Number of bytes.

    Returns number

  • Allocate then set the argument location with a TVMByteArray. Allocate new temporary space for bytes.

    Parameters

    • offset: number

      The offset to set ot data pointer.

    • data: Uint8Array

      The string content.

    Returns 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: number

      The offset to set ot data pointer.

    • data: string

      The string content.

    Returns void

  • Commit all the cached data to WasmMemory. This function can only be called once. No further store function should be called.

    Parameters

    • nbytes: number = ...

      Number of bytes to be stored.

    Returns void

  • Dispose the internal resource This function can be called multiple times, only the first call will take effect.

    Returns void

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

    Parameters

    • offset: number

      The allocated offset.

    Returns number

  • Rest the call stack so that it can be reused again.

    Returns void

  • Parameters

    • offset: number
    • value: number

    Returns void

  • Parameters

    • offset: number
    • value: number

    Returns void

  • Parameters

    • offset: number
    • value: number

    Returns void

  • Parameters

    • offset: number
    • value: number

    Returns void

  • Parameters

    • offset: number
    • bytes: Uint8Array

    Returns void

  • Parameters

    • offset: number
    • value: number

    Returns void

  • Parameters

    • offset: number
    • value: number

    Returns void

Generated using TypeDoc