Class PanamaEngine

java.lang.Object
ai.tegmentum.wasmtime4j.panama.PanamaEngine
All Implemented Interfaces:
ai.tegmentum.wasmtime4j.Engine, Closeable, AutoCloseable

public final class PanamaEngine extends Object implements ai.tegmentum.wasmtime4j.Engine
Panama FFI implementation of WebAssembly Engine.
Since:
1.0.0
  • Constructor Details

    • PanamaEngine

      public PanamaEngine() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Creates a new Panama engine with default configuration.

      This constructor is intended for unit tests. Production code should use PanamaEngine(EngineConfig, WasmRuntime).

      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException - if engine creation fails
    • PanamaEngine

      public PanamaEngine(ai.tegmentum.wasmtime4j.config.EngineConfig config) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Creates a new Panama engine with specified configuration.

      This constructor is intended for unit tests. Production code should use PanamaEngine(EngineConfig, WasmRuntime).

      Parameters:
      config - the engine configuration
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException - if engine creation fails
    • PanamaEngine

      public PanamaEngine(ai.tegmentum.wasmtime4j.config.EngineConfig config, ai.tegmentum.wasmtime4j.WasmRuntime runtime) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Creates a new Panama engine with specified configuration and runtime reference.
      Parameters:
      config - the engine configuration
      runtime - the runtime that owns this engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException - if engine creation fails
  • Method Details

    • createStore

      public ai.tegmentum.wasmtime4j.Store createStore() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      createStore in interface ai.tegmentum.wasmtime4j.Engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • createStore

      public ai.tegmentum.wasmtime4j.Store createStore(Object data) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      createStore in interface ai.tegmentum.wasmtime4j.Engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • getRuntime

      public ai.tegmentum.wasmtime4j.WasmRuntime getRuntime()
      Specified by:
      getRuntime in interface ai.tegmentum.wasmtime4j.Engine
    • compileModule

      public ai.tegmentum.wasmtime4j.Module compileModule(byte[] wasmBytes) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      compileModule in interface ai.tegmentum.wasmtime4j.Engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • compileModuleWithDwarf

      public ai.tegmentum.wasmtime4j.Module compileModuleWithDwarf(byte[] wasmBytes, byte[] dwarfPackage) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      compileModuleWithDwarf in interface ai.tegmentum.wasmtime4j.Engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • compileWat

      public ai.tegmentum.wasmtime4j.Module compileWat(String wat) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      compileWat in interface ai.tegmentum.wasmtime4j.Engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • precompileModule

      public byte[] precompileModule(byte[] wasmBytes) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      precompileModule in interface ai.tegmentum.wasmtime4j.Engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • codeBuilder

      public ai.tegmentum.wasmtime4j.CodeBuilder codeBuilder() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      codeBuilder in interface ai.tegmentum.wasmtime4j.Engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • precompileComponent

      public byte[] precompileComponent(byte[] wasmBytes) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      precompileComponent in interface ai.tegmentum.wasmtime4j.Engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • getPoolingAllocatorMetrics

      public ai.tegmentum.wasmtime4j.pool.PoolStatistics getPoolingAllocatorMetrics()
      Specified by:
      getPoolingAllocatorMetrics in interface ai.tegmentum.wasmtime4j.Engine
    • compileFromStream

      public ai.tegmentum.wasmtime4j.Module compileFromStream(InputStream stream) throws ai.tegmentum.wasmtime4j.exception.WasmException, IOException
      Specified by:
      compileFromStream in interface ai.tegmentum.wasmtime4j.Engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
      IOException
    • compileFromFile

      public ai.tegmentum.wasmtime4j.Module compileFromFile(Path path) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      compileFromFile in interface ai.tegmentum.wasmtime4j.Engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • getConfig

      public ai.tegmentum.wasmtime4j.config.EngineConfig getConfig()
      Specified by:
      getConfig in interface ai.tegmentum.wasmtime4j.Engine
    • isValid

      public boolean isValid()
      Specified by:
      isValid in interface ai.tegmentum.wasmtime4j.Engine
    • supportsFeature

      public boolean supportsFeature(ai.tegmentum.wasmtime4j.WasmFeature feature)
      Specified by:
      supportsFeature in interface ai.tegmentum.wasmtime4j.Engine
    • detectHostFeature

      public Optional<Boolean> detectHostFeature(String feature)
      Specified by:
      detectHostFeature in interface ai.tegmentum.wasmtime4j.Engine
    • getStackSizeLimit

      public long getStackSizeLimit()
      Specified by:
      getStackSizeLimit in interface ai.tegmentum.wasmtime4j.Engine
    • isFuelEnabled

      public boolean isFuelEnabled()
      Specified by:
      isFuelEnabled in interface ai.tegmentum.wasmtime4j.Engine
    • isEpochInterruptionEnabled

      public boolean isEpochInterruptionEnabled()
      Specified by:
      isEpochInterruptionEnabled in interface ai.tegmentum.wasmtime4j.Engine
    • isCoredumpOnTrapEnabled

      public boolean isCoredumpOnTrapEnabled()
      Specified by:
      isCoredumpOnTrapEnabled in interface ai.tegmentum.wasmtime4j.Engine
    • incrementEpoch

      public void incrementEpoch()
      Specified by:
      incrementEpoch in interface ai.tegmentum.wasmtime4j.Engine
    • unloadProcessHandlers

      public void unloadProcessHandlers() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      unloadProcessHandlers in interface ai.tegmentum.wasmtime4j.Engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface ai.tegmentum.wasmtime4j.Engine
    • getNativeEngine

      public MemorySegment getNativeEngine()
      Gets the native engine pointer.
      Returns:
      native engine memory segment
      Throws:
      IllegalStateException - if the engine has been closed
    • getId

      public long getId()
      Gets the unique identifier for this engine.
      Returns:
      the engine ID
    • isPulley

      public boolean isPulley()
      Specified by:
      isPulley in interface ai.tegmentum.wasmtime4j.Engine
    • precompileCompatibilityHash

      public byte[] precompileCompatibilityHash()
      Specified by:
      precompileCompatibilityHash in interface ai.tegmentum.wasmtime4j.Engine
    • detectPrecompiled

      public ai.tegmentum.wasmtime4j.Precompiled detectPrecompiled(byte[] bytes)
      Specified by:
      detectPrecompiled in interface ai.tegmentum.wasmtime4j.Engine
    • same

      public boolean same(ai.tegmentum.wasmtime4j.Engine other)
      Specified by:
      same in interface ai.tegmentum.wasmtime4j.Engine
    • isAsync

      public boolean isAsync()
      Specified by:
      isAsync in interface ai.tegmentum.wasmtime4j.Engine
    • isRecording

      public boolean isRecording()
      Specified by:
      isRecording in interface ai.tegmentum.wasmtime4j.Engine
    • isReplaying

      public boolean isReplaying()
      Specified by:
      isReplaying in interface ai.tegmentum.wasmtime4j.Engine
    • createSharedMemory

      public ai.tegmentum.wasmtime4j.WasmMemory createSharedMemory(int initialPages, int maxPages) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      createSharedMemory in interface ai.tegmentum.wasmtime4j.Engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • createGuestProfiler

      public ai.tegmentum.wasmtime4j.debug.GuestProfiler createGuestProfiler(String moduleName, Duration interval, Map<String,ai.tegmentum.wasmtime4j.Module> modules) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      createGuestProfiler in interface ai.tegmentum.wasmtime4j.Engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • createComponentGuestProfiler

      public ai.tegmentum.wasmtime4j.debug.GuestProfiler createComponentGuestProfiler(String componentName, Duration interval, ai.tegmentum.wasmtime4j.component.Component component, Map<String,ai.tegmentum.wasmtime4j.Module> extraModules) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      createComponentGuestProfiler in interface ai.tegmentum.wasmtime4j.Engine
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • weak

      public ai.tegmentum.wasmtime4j.WeakEngine weak()
      Specified by:
      weak in interface ai.tegmentum.wasmtime4j.Engine