Class PanamaGcRuntime

java.lang.Object
ai.tegmentum.wasmtime4j.panama.PanamaGcRuntime
All Implemented Interfaces:
ai.tegmentum.wasmtime4j.gc.GcRuntime

public final class PanamaGcRuntime extends Object implements ai.tegmentum.wasmtime4j.gc.GcRuntime
Panama FFI implementation of WebAssembly GC runtime operations.

This class provides actual WebAssembly GC functionality through Panama FFI bindings to the native Wasmtime GC implementation. It supports all GC operations including struct creation, array manipulation, reference type conversions, and heap management.

Since:
1.0.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    PanamaGcRuntime(long engineHandle)
    Creates a new Panama GC runtime with the specified engine handle.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    anyRefConvertExtern(long externRefData)
     
    long
    anyRefFromRaw(long raw)
     
    boolean
    anyRefMatchesTy(long objectId, int heapTypeOrdinal)
     
    long
    anyRefToRaw(long objectId)
     
    boolean
    arrayRefMatchesTy(long objectId, int heapTypeOrdinal)
     
    ai.tegmentum.wasmtime4j.gc.GcStats
     
    void
    copyArrayElements(ai.tegmentum.wasmtime4j.gc.ArrayInstance sourceArray, int sourceIndex, ai.tegmentum.wasmtime4j.gc.ArrayInstance destArray, int destIndex, int length)
     
    ai.tegmentum.wasmtime4j.gc.ArrayInstance
    createArray(ai.tegmentum.wasmtime4j.gc.ArrayType arrayType, int length)
     
    ai.tegmentum.wasmtime4j.gc.ArrayInstance
    createArray(ai.tegmentum.wasmtime4j.gc.ArrayType arrayType, List<ai.tegmentum.wasmtime4j.gc.GcValue> elements)
     
    ai.tegmentum.wasmtime4j.gc.ArrayInstance
    createArrayAsync(ai.tegmentum.wasmtime4j.gc.ArrayType arrayType, List<ai.tegmentum.wasmtime4j.gc.GcValue> elements)
     
    ai.tegmentum.wasmtime4j.gc.I31Instance
    createI31(int value)
     
    ai.tegmentum.wasmtime4j.gc.I31Instance
    createI31Unsigned(int value)
     
    ai.tegmentum.wasmtime4j.gc.I31Instance
    createI31Wrapping(int value)
     
    ai.tegmentum.wasmtime4j.gc.I31Instance
     
    ai.tegmentum.wasmtime4j.gc.StructInstance
    createStruct(ai.tegmentum.wasmtime4j.gc.StructType structType)
     
    ai.tegmentum.wasmtime4j.gc.StructInstance
    createStruct(ai.tegmentum.wasmtime4j.gc.StructType structType, List<ai.tegmentum.wasmtime4j.gc.GcValue> fieldValues)
     
    ai.tegmentum.wasmtime4j.gc.StructInstance
    createStructAsync(ai.tegmentum.wasmtime4j.gc.StructType structType, List<ai.tegmentum.wasmtime4j.gc.GcValue> fieldValues)
     
    void
    Disposes this GC runtime and releases native resources.
    boolean
    eqRefMatchesTy(long objectId, int heapTypeOrdinal)
     
    int
    eqRefTy(long objectId)
     
    long
    externRefConvertAny(long objectId)
     
    void
    fillArrayElements(ai.tegmentum.wasmtime4j.gc.ArrayInstance array, int startIndex, int length, ai.tegmentum.wasmtime4j.gc.GcValue value)
     
    ai.tegmentum.wasmtime4j.gc.GcValue
    getArrayElement(ai.tegmentum.wasmtime4j.gc.ArrayInstance array, int elementIndex)
     
    int
    getArrayLength(ai.tegmentum.wasmtime4j.gc.ArrayInstance array)
     
    ai.tegmentum.wasmtime4j.gc.GcStats
     
    ai.tegmentum.wasmtime4j.gc.GcReferenceType
    getRuntimeType(ai.tegmentum.wasmtime4j.gc.GcObject object)
     
    ai.tegmentum.wasmtime4j.gc.GcValue
    getStructField(ai.tegmentum.wasmtime4j.gc.StructInstance struct, int fieldIndex)
     
    boolean
    isNull(ai.tegmentum.wasmtime4j.gc.GcObject object)
     
    ai.tegmentum.wasmtime4j.gc.GcObject
    refCast(ai.tegmentum.wasmtime4j.gc.GcObject object, ai.tegmentum.wasmtime4j.gc.GcReferenceType targetType)
     
    ai.tegmentum.wasmtime4j.gc.ArrayInstance
    refCastArray(ai.tegmentum.wasmtime4j.gc.GcObject object, ai.tegmentum.wasmtime4j.gc.ArrayType targetArrayType)
     
    Optional<ai.tegmentum.wasmtime4j.gc.GcObject>
    refCastNullable(ai.tegmentum.wasmtime4j.gc.GcObject object, ai.tegmentum.wasmtime4j.gc.GcReferenceType targetType)
     
    ai.tegmentum.wasmtime4j.gc.StructInstance
    refCastStruct(ai.tegmentum.wasmtime4j.gc.GcObject object, ai.tegmentum.wasmtime4j.gc.StructType targetStructType)
     
    boolean
    refEquals(ai.tegmentum.wasmtime4j.gc.GcObject obj1, ai.tegmentum.wasmtime4j.gc.GcObject obj2)
     
    boolean
    refTest(ai.tegmentum.wasmtime4j.gc.GcObject object, ai.tegmentum.wasmtime4j.gc.GcReferenceType targetType)
     
    boolean
    refTestArray(ai.tegmentum.wasmtime4j.gc.GcObject object, ai.tegmentum.wasmtime4j.gc.ArrayType targetArrayType)
     
    boolean
    refTestStruct(ai.tegmentum.wasmtime4j.gc.GcObject object, ai.tegmentum.wasmtime4j.gc.StructType targetStructType)
     
    int
    registerArrayType(ai.tegmentum.wasmtime4j.gc.ArrayType arrayType)
     
    int
    registerStructType(ai.tegmentum.wasmtime4j.gc.StructType structType)
     
    boolean
    releaseObject(long objectId)
    void
    setArrayElement(ai.tegmentum.wasmtime4j.gc.ArrayInstance array, int elementIndex, ai.tegmentum.wasmtime4j.gc.GcValue value)
     
    void
    setStructField(ai.tegmentum.wasmtime4j.gc.StructInstance struct, int fieldIndex, ai.tegmentum.wasmtime4j.gc.GcValue value)
     
    boolean
    structRefMatchesTy(long objectId, int heapTypeOrdinal)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface ai.tegmentum.wasmtime4j.gc.GcRuntime

    createArrayFixed, createArrayFixedAsync
  • Constructor Details

    • PanamaGcRuntime

      public PanamaGcRuntime(long engineHandle) throws PanamaException
      Creates a new Panama GC runtime with the specified engine handle.
      Parameters:
      engineHandle - the native engine handle
      Throws:
      PanamaException - if runtime creation fails
  • Method Details

    • createStruct

      public ai.tegmentum.wasmtime4j.gc.StructInstance createStruct(ai.tegmentum.wasmtime4j.gc.StructType structType, List<ai.tegmentum.wasmtime4j.gc.GcValue> fieldValues) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      createStruct in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • createStruct

      public ai.tegmentum.wasmtime4j.gc.StructInstance createStruct(ai.tegmentum.wasmtime4j.gc.StructType structType) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      createStruct in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • createStructAsync

      public ai.tegmentum.wasmtime4j.gc.StructInstance createStructAsync(ai.tegmentum.wasmtime4j.gc.StructType structType, List<ai.tegmentum.wasmtime4j.gc.GcValue> fieldValues) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      createStructAsync in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • createArray

      public ai.tegmentum.wasmtime4j.gc.ArrayInstance createArray(ai.tegmentum.wasmtime4j.gc.ArrayType arrayType, List<ai.tegmentum.wasmtime4j.gc.GcValue> elements) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      createArray in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • createArray

      public ai.tegmentum.wasmtime4j.gc.ArrayInstance createArray(ai.tegmentum.wasmtime4j.gc.ArrayType arrayType, int length) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      createArray in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • createArrayAsync

      public ai.tegmentum.wasmtime4j.gc.ArrayInstance createArrayAsync(ai.tegmentum.wasmtime4j.gc.ArrayType arrayType, List<ai.tegmentum.wasmtime4j.gc.GcValue> elements) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      createArrayAsync in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • createI31

      public ai.tegmentum.wasmtime4j.gc.I31Instance createI31(int value) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      createI31 in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • createI31Unsigned

      public ai.tegmentum.wasmtime4j.gc.I31Instance createI31Unsigned(int value) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      createI31Unsigned in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • createI31Wrapping

      public ai.tegmentum.wasmtime4j.gc.I31Instance createI31Wrapping(int value) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      createI31Wrapping in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • createI31WrappingUnsigned

      public ai.tegmentum.wasmtime4j.gc.I31Instance createI31WrappingUnsigned(int value) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      createI31WrappingUnsigned in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • getStructField

      public ai.tegmentum.wasmtime4j.gc.GcValue getStructField(ai.tegmentum.wasmtime4j.gc.StructInstance struct, int fieldIndex) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      getStructField in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • setStructField

      public void setStructField(ai.tegmentum.wasmtime4j.gc.StructInstance struct, int fieldIndex, ai.tegmentum.wasmtime4j.gc.GcValue value) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      setStructField in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • getArrayElement

      public ai.tegmentum.wasmtime4j.gc.GcValue getArrayElement(ai.tegmentum.wasmtime4j.gc.ArrayInstance array, int elementIndex) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      getArrayElement in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • setArrayElement

      public void setArrayElement(ai.tegmentum.wasmtime4j.gc.ArrayInstance array, int elementIndex, ai.tegmentum.wasmtime4j.gc.GcValue value) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      setArrayElement in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • getArrayLength

      public int getArrayLength(ai.tegmentum.wasmtime4j.gc.ArrayInstance array)
      Specified by:
      getArrayLength in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
    • refCast

      public ai.tegmentum.wasmtime4j.gc.GcObject refCast(ai.tegmentum.wasmtime4j.gc.GcObject object, ai.tegmentum.wasmtime4j.gc.GcReferenceType targetType)
      Specified by:
      refCast in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
    • refTest

      public boolean refTest(ai.tegmentum.wasmtime4j.gc.GcObject object, ai.tegmentum.wasmtime4j.gc.GcReferenceType targetType)
      Specified by:
      refTest in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
    • refEquals

      public boolean refEquals(ai.tegmentum.wasmtime4j.gc.GcObject obj1, ai.tegmentum.wasmtime4j.gc.GcObject obj2)
      Specified by:
      refEquals in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
    • isNull

      public boolean isNull(ai.tegmentum.wasmtime4j.gc.GcObject object)
      Specified by:
      isNull in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
    • registerStructType

      public int registerStructType(ai.tegmentum.wasmtime4j.gc.StructType structType) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      registerStructType in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • registerArrayType

      public int registerArrayType(ai.tegmentum.wasmtime4j.gc.ArrayType arrayType) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      registerArrayType in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • releaseObject

      public boolean releaseObject(long objectId)
      Specified by:
      releaseObject in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
    • collectGarbage

      public ai.tegmentum.wasmtime4j.gc.GcStats collectGarbage()
      Specified by:
      collectGarbage in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
    • getGcStats

      public ai.tegmentum.wasmtime4j.gc.GcStats getGcStats()
      Specified by:
      getGcStats in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
    • dispose

      public void dispose()
      Disposes this GC runtime and releases native resources.
      Throws:
      PanamaException - if disposal fails
    • refCastStruct

      public ai.tegmentum.wasmtime4j.gc.StructInstance refCastStruct(ai.tegmentum.wasmtime4j.gc.GcObject object, ai.tegmentum.wasmtime4j.gc.StructType targetStructType)
      Specified by:
      refCastStruct in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
    • refCastArray

      public ai.tegmentum.wasmtime4j.gc.ArrayInstance refCastArray(ai.tegmentum.wasmtime4j.gc.GcObject object, ai.tegmentum.wasmtime4j.gc.ArrayType targetArrayType)
      Specified by:
      refCastArray in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
    • refTestStruct

      public boolean refTestStruct(ai.tegmentum.wasmtime4j.gc.GcObject object, ai.tegmentum.wasmtime4j.gc.StructType targetStructType)
      Specified by:
      refTestStruct in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
    • refTestArray

      public boolean refTestArray(ai.tegmentum.wasmtime4j.gc.GcObject object, ai.tegmentum.wasmtime4j.gc.ArrayType targetArrayType)
      Specified by:
      refTestArray in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
    • getRuntimeType

      public ai.tegmentum.wasmtime4j.gc.GcReferenceType getRuntimeType(ai.tegmentum.wasmtime4j.gc.GcObject object)
      Specified by:
      getRuntimeType in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
    • refCastNullable

      public Optional<ai.tegmentum.wasmtime4j.gc.GcObject> refCastNullable(ai.tegmentum.wasmtime4j.gc.GcObject object, ai.tegmentum.wasmtime4j.gc.GcReferenceType targetType)
      Specified by:
      refCastNullable in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
    • copyArrayElements

      public void copyArrayElements(ai.tegmentum.wasmtime4j.gc.ArrayInstance sourceArray, int sourceIndex, ai.tegmentum.wasmtime4j.gc.ArrayInstance destArray, int destIndex, int length) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      copyArrayElements in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • fillArrayElements

      public void fillArrayElements(ai.tegmentum.wasmtime4j.gc.ArrayInstance array, int startIndex, int length, ai.tegmentum.wasmtime4j.gc.GcValue value) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      fillArrayElements in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • anyRefToRaw

      public long anyRefToRaw(long objectId) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      anyRefToRaw in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • anyRefFromRaw

      public long anyRefFromRaw(long raw) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      anyRefFromRaw in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • anyRefMatchesTy

      public boolean anyRefMatchesTy(long objectId, int heapTypeOrdinal) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      anyRefMatchesTy in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • eqRefTy

      public int eqRefTy(long objectId) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      eqRefTy in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • eqRefMatchesTy

      public boolean eqRefMatchesTy(long objectId, int heapTypeOrdinal) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      eqRefMatchesTy in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • structRefMatchesTy

      public boolean structRefMatchesTy(long objectId, int heapTypeOrdinal) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      structRefMatchesTy in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • arrayRefMatchesTy

      public boolean arrayRefMatchesTy(long objectId, int heapTypeOrdinal) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      arrayRefMatchesTy in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • externRefConvertAny

      public long externRefConvertAny(long objectId) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      externRefConvertAny in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException
    • anyRefConvertExtern

      public long anyRefConvertExtern(long externRefData) throws ai.tegmentum.wasmtime4j.gc.GcException
      Specified by:
      anyRefConvertExtern in interface ai.tegmentum.wasmtime4j.gc.GcRuntime
      Throws:
      ai.tegmentum.wasmtime4j.gc.GcException