Class PanamaStore
java.lang.Object
ai.tegmentum.wasmtime4j.panama.PanamaStore
- All Implemented Interfaces:
ai.tegmentum.wasmtime4j.Store,Closeable,AutoCloseable
Panama FFI implementation of WebAssembly Store.
A Store represents an execution context for WebAssembly instances.
- Since:
- 1.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface ai.tegmentum.wasmtime4j.Store
ai.tegmentum.wasmtime4j.Store.AsyncCallHookHandler, ai.tegmentum.wasmtime4j.Store.EpochDeadlineAction, ai.tegmentum.wasmtime4j.Store.EpochDeadlineCallback -
Constructor Summary
ConstructorsConstructorDescriptionPanamaStore(PanamaEngine engine) Creates a new Panama store.PanamaStore(PanamaEngine engine, ai.tegmentum.wasmtime4j.config.StoreLimits limits) Creates a new Panama store with resource limits. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFuel(long fuel) ai.tegmentum.wasmtime4j.debug.WasmBacktracevoidvoidclose()longconsumeFuel(long fuel) ai.tegmentum.wasmtime4j.func.FunctionReferencecreateFunctionReference(ai.tegmentum.wasmtime4j.func.HostFunction implementation, ai.tegmentum.wasmtime4j.type.FunctionType functionType) ai.tegmentum.wasmtime4j.func.FunctionReferencecreateFunctionReference(ai.tegmentum.wasmtime4j.WasmFunction function) ai.tegmentum.wasmtime4j.WasmGlobalcreateGlobal(ai.tegmentum.wasmtime4j.WasmValueType valueType, boolean isMutable, ai.tegmentum.wasmtime4j.WasmValue initialValue) ai.tegmentum.wasmtime4j.WasmFunctioncreateHostFunction(String name, ai.tegmentum.wasmtime4j.type.FunctionType functionType, ai.tegmentum.wasmtime4j.func.HostFunction implementation) ai.tegmentum.wasmtime4j.WasmFunctioncreateHostFunctionUnchecked(String name, ai.tegmentum.wasmtime4j.type.FunctionType functionType, ai.tegmentum.wasmtime4j.func.HostFunction implementation) ai.tegmentum.wasmtime4j.InstancecreateInstance(ai.tegmentum.wasmtime4j.Module module) ai.tegmentum.wasmtime4j.InstancecreateInstance(ai.tegmentum.wasmtime4j.Module module, ai.tegmentum.wasmtime4j.Extern[] imports) CompletableFuture<ai.tegmentum.wasmtime4j.Instance> createInstanceAsync(ai.tegmentum.wasmtime4j.Module module) ai.tegmentum.wasmtime4j.WasmMemorycreateMemory(int initialPages, int maxPages) ai.tegmentum.wasmtime4j.WasmMemorycreateMemory(ai.tegmentum.wasmtime4j.type.MemoryType memoryType) CompletableFuture<ai.tegmentum.wasmtime4j.WasmMemory> createMemoryAsync(ai.tegmentum.wasmtime4j.type.MemoryType memoryType) ai.tegmentum.wasmtime4j.WasmMemorycreateSharedMemory(int initialPages, int maxPages) ai.tegmentum.wasmtime4j.WasmTablecreateTable(ai.tegmentum.wasmtime4j.type.TableType tableType) ai.tegmentum.wasmtime4j.WasmTablecreateTable(ai.tegmentum.wasmtime4j.type.TableType tableType, ai.tegmentum.wasmtime4j.WasmValue initValue) ai.tegmentum.wasmtime4j.WasmTablecreateTable(ai.tegmentum.wasmtime4j.WasmValueType elementType, int initialSize, int maxSize) ai.tegmentum.wasmtime4j.WasmTablecreateTable(ai.tegmentum.wasmtime4j.WasmValueType elementType, int initialSize, int maxSize, ai.tegmentum.wasmtime4j.WasmValue initValue) CompletableFuture<ai.tegmentum.wasmtime4j.WasmTable> createTableAsync(ai.tegmentum.wasmtime4j.type.TableType tableType) List<ai.tegmentum.wasmtime4j.debug.FrameHandle> intintOptional<ai.tegmentum.wasmtime4j.debug.BreakpointEditor> voidepochDeadlineAsyncYieldAndUpdate(long deltaTicks) voidepochDeadlineCallback(ai.tegmentum.wasmtime4j.Store.EpochDeadlineCallback callback) voidai.tegmentum.wasmtime4j.debug.WasmBacktracestatic PanamaStoreforModule(ai.tegmentum.wasmtime4j.Module module) Creates a new store that is compatible with the given module.voidgc()gcAsync()ai.tegmentum.wasmtime4j.func.CallbackRegistrygetData()ai.tegmentum.wasmtime4j.EnginelonggetFuel()longGets the native store pointer.Gets the resource manager for this store.Optional<ai.tegmentum.wasmtime4j.wasi.WasiContext> booleanlongbooleanisAsync()booleanbooleanisValid()voidvoidsetCallHook(ai.tegmentum.wasmtime4j.func.CallHookHandler handler) voidsetCallHookAsync(ai.tegmentum.wasmtime4j.Store.AsyncCallHookHandler handler) voidvoidsetDebugHandler(ai.tegmentum.wasmtime4j.debug.DebugHandler handler) voidsetEpochDeadline(long ticks) voidsetFuel(long fuel) voidsetFuelAsyncYieldInterval(long interval) voidsetHostcallFuel(long fuel) voidsetResourceLimiter(ai.tegmentum.wasmtime4j.config.ResourceLimiter limiter) voidsetResourceLimiterAsync(ai.tegmentum.wasmtime4j.config.ResourceLimiterAsync limiter) ai.tegmentum.wasmtime4j.ExnRef<R> RthrowException(ai.tegmentum.wasmtime4j.ExnRef exceptionRef) Deprecated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ai.tegmentum.wasmtime4j.Store
createImmutableGlobal, createMutableGlobal, runConcurrent, spawn, submitTask
-
Constructor Details
-
PanamaStore
Creates a new Panama store.- Parameters:
engine- the engine that owns this store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException- if store creation fails
-
PanamaStore
public PanamaStore(PanamaEngine engine, ai.tegmentum.wasmtime4j.config.StoreLimits limits) throws ai.tegmentum.wasmtime4j.exception.WasmException Creates a new Panama store with resource limits.- Parameters:
engine- the engine that owns this storelimits- the resource limits to apply- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException- if store creation fails
-
-
Method Details
-
forModule
public static PanamaStore forModule(ai.tegmentum.wasmtime4j.Module module) throws ai.tegmentum.wasmtime4j.exception.WasmException Creates a new store that is compatible with the given module.CRITICAL: This method creates a Store that shares the exact same Engine Arc as the module. This is required because Wasmtime's Instance::new() uses Arc::ptr_eq() to verify that the Store and Module were created from the same Engine. Using
PanamaEngine.createStore()will create a Store with a different Arc clone, causing "cross-Engine instantiation is not currently supported" errors.Usage Example:
try (PanamaEngine engine = new PanamaEngine()) { PanamaModule module = (PanamaModule) engine.compileModule(wasmBytes); // CORRECT: Use forModule to create a compatible store try (PanamaStore store = PanamaStore.forModule(module)) { PanamaInstance instance = (PanamaInstance) module.instantiate(store); // Instance created successfully } }- Parameters:
module- the module to create a compatible store for- Returns:
- a new store that shares the same Engine Arc as the module
- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException- if store creation failsIllegalArgumentException- if module is null or not a PanamaModule
-
getEngine
public ai.tegmentum.wasmtime4j.Engine getEngine()- Specified by:
getEnginein interfaceai.tegmentum.wasmtime4j.Store
-
getData
- Specified by:
getDatain interfaceai.tegmentum.wasmtime4j.Store
-
setData
- Specified by:
setDatain interfaceai.tegmentum.wasmtime4j.Store
-
setResourceLimiter
public void setResourceLimiter(ai.tegmentum.wasmtime4j.config.ResourceLimiter limiter) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
setResourceLimiterin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
setResourceLimiterAsync
public void setResourceLimiterAsync(ai.tegmentum.wasmtime4j.config.ResourceLimiterAsync limiter) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
setResourceLimiterAsyncin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
setFuel
public void setFuel(long fuel) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
setFuelin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
getFuel
public long getFuel() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
getFuelin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
addFuel
public void addFuel(long fuel) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
addFuelin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
setEpochDeadline
public void setEpochDeadline(long ticks) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
setEpochDeadlinein interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
consumeFuel
public long consumeFuel(long fuel) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
consumeFuelin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
hostcallFuel
public long hostcallFuel() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
hostcallFuelin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
setHostcallFuel
public void setHostcallFuel(long fuel) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
setHostcallFuelin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
createHostFunction
public ai.tegmentum.wasmtime4j.WasmFunction createHostFunction(String name, ai.tegmentum.wasmtime4j.type.FunctionType functionType, ai.tegmentum.wasmtime4j.func.HostFunction implementation) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
createHostFunctionin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
createHostFunctionUnchecked
public ai.tegmentum.wasmtime4j.WasmFunction createHostFunctionUnchecked(String name, ai.tegmentum.wasmtime4j.type.FunctionType functionType, ai.tegmentum.wasmtime4j.func.HostFunction implementation) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
createHostFunctionUncheckedin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
getWasiContext
- Specified by:
getWasiContextin interfaceai.tegmentum.wasmtime4j.Store
-
reapplyWasiContext
public void reapplyWasiContext() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
reapplyWasiContextin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
createGlobal
public ai.tegmentum.wasmtime4j.WasmGlobal createGlobal(ai.tegmentum.wasmtime4j.WasmValueType valueType, boolean isMutable, ai.tegmentum.wasmtime4j.WasmValue initialValue) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
createGlobalin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
createTable
public ai.tegmentum.wasmtime4j.WasmTable createTable(ai.tegmentum.wasmtime4j.WasmValueType elementType, int initialSize, int maxSize) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
createTablein interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
createTable
public ai.tegmentum.wasmtime4j.WasmTable createTable(ai.tegmentum.wasmtime4j.WasmValueType elementType, int initialSize, int maxSize, ai.tegmentum.wasmtime4j.WasmValue initValue) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
createTablein interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
createTable
public ai.tegmentum.wasmtime4j.WasmTable createTable(ai.tegmentum.wasmtime4j.type.TableType tableType) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
createTablein interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
createTable
public ai.tegmentum.wasmtime4j.WasmTable createTable(ai.tegmentum.wasmtime4j.type.TableType tableType, ai.tegmentum.wasmtime4j.WasmValue initValue) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
createTablein interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
createMemory
public ai.tegmentum.wasmtime4j.WasmMemory createMemory(int initialPages, int maxPages) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
createMemoryin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
createMemory
public ai.tegmentum.wasmtime4j.WasmMemory createMemory(ai.tegmentum.wasmtime4j.type.MemoryType memoryType) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
createMemoryin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
createFunctionReference
public ai.tegmentum.wasmtime4j.func.FunctionReference createFunctionReference(ai.tegmentum.wasmtime4j.func.HostFunction implementation, ai.tegmentum.wasmtime4j.type.FunctionType functionType) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
createFunctionReferencein interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
createFunctionReference
public ai.tegmentum.wasmtime4j.func.FunctionReference createFunctionReference(ai.tegmentum.wasmtime4j.WasmFunction function) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
createFunctionReferencein interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
getCallbackRegistry
public ai.tegmentum.wasmtime4j.func.CallbackRegistry getCallbackRegistry()- Specified by:
getCallbackRegistryin interfaceai.tegmentum.wasmtime4j.Store
-
createInstance
public ai.tegmentum.wasmtime4j.Instance createInstance(ai.tegmentum.wasmtime4j.Module module) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
createInstancein interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
createInstance
public ai.tegmentum.wasmtime4j.Instance createInstance(ai.tegmentum.wasmtime4j.Module module, ai.tegmentum.wasmtime4j.Extern[] imports) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
createInstancein interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
isValid
public boolean isValid()- Specified by:
isValidin interfaceai.tegmentum.wasmtime4j.Store
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceai.tegmentum.wasmtime4j.Store
-
getNativeStore
Gets the native store pointer.- Returns:
- native store memory segment
-
getResourceManager
Gets the resource manager for this store.- Returns:
- the arena resource manager
-
gc
public void gc() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
gcin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
throwException
@Deprecated public <R> R throwException(ai.tegmentum.wasmtime4j.ExnRef exceptionRef) throws ai.tegmentum.wasmtime4j.exception.WasmException Deprecated.- Specified by:
throwExceptionin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
takePendingException
public ai.tegmentum.wasmtime4j.ExnRef takePendingException() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
takePendingExceptionin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
hasPendingException
public boolean hasPendingException()- Specified by:
hasPendingExceptionin interfaceai.tegmentum.wasmtime4j.Store
-
epochDeadlineAsyncYieldAndUpdate
public void epochDeadlineAsyncYieldAndUpdate(long deltaTicks) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
epochDeadlineAsyncYieldAndUpdatein interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
epochDeadlineTrap
public void epochDeadlineTrap() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
epochDeadlineTrapin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
epochDeadlineCallback
public void epochDeadlineCallback(ai.tegmentum.wasmtime4j.Store.EpochDeadlineCallback callback) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
epochDeadlineCallbackin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
setDebugHandler
public void setDebugHandler(ai.tegmentum.wasmtime4j.debug.DebugHandler handler) - Specified by:
setDebugHandlerin interfaceai.tegmentum.wasmtime4j.Store
-
clearDebugHandler
public void clearDebugHandler()- Specified by:
clearDebugHandlerin interfaceai.tegmentum.wasmtime4j.Store
-
setCallHook
public void setCallHook(ai.tegmentum.wasmtime4j.func.CallHookHandler handler) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
setCallHookin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
setCallHookAsync
public void setCallHookAsync(ai.tegmentum.wasmtime4j.Store.AsyncCallHookHandler handler) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
setCallHookAsyncin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
setFuelAsyncYieldInterval
public void setFuelAsyncYieldInterval(long interval) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
setFuelAsyncYieldIntervalin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
getFuelAsyncYieldInterval
public long getFuelAsyncYieldInterval()- Specified by:
getFuelAsyncYieldIntervalin interfaceai.tegmentum.wasmtime4j.Store
-
captureBacktrace
public ai.tegmentum.wasmtime4j.debug.WasmBacktrace captureBacktrace() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
captureBacktracein interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
forceCaptureBacktrace
public ai.tegmentum.wasmtime4j.debug.WasmBacktrace forceCaptureBacktrace() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
forceCaptureBacktracein interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
debugInstanceCount
public int debugInstanceCount() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
debugInstanceCountin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
debugModuleCount
public int debugModuleCount() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
debugModuleCountin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
isSingleStep
public boolean isSingleStep()- Specified by:
isSingleStepin interfaceai.tegmentum.wasmtime4j.Store
-
debugExitFrames
public List<ai.tegmentum.wasmtime4j.debug.FrameHandle> debugExitFrames() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
debugExitFramesin interfaceai.tegmentum.wasmtime4j.Store- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
isAsync
public boolean isAsync()- Specified by:
isAsyncin interfaceai.tegmentum.wasmtime4j.Store
-
breakpoints
-
editBreakpoints
- Specified by:
editBreakpointsin interfaceai.tegmentum.wasmtime4j.Store
-
gcAsync
- Specified by:
gcAsyncin interfaceai.tegmentum.wasmtime4j.Store
-
createInstanceAsync
public CompletableFuture<ai.tegmentum.wasmtime4j.Instance> createInstanceAsync(ai.tegmentum.wasmtime4j.Module module) - Specified by:
createInstanceAsyncin interfaceai.tegmentum.wasmtime4j.Store
-
createMemoryAsync
public CompletableFuture<ai.tegmentum.wasmtime4j.WasmMemory> createMemoryAsync(ai.tegmentum.wasmtime4j.type.MemoryType memoryType) - Specified by:
createMemoryAsyncin interfaceai.tegmentum.wasmtime4j.Store
-
createTableAsync
public CompletableFuture<ai.tegmentum.wasmtime4j.WasmTable> createTableAsync(ai.tegmentum.wasmtime4j.type.TableType tableType) - Specified by:
createTableAsyncin interfaceai.tegmentum.wasmtime4j.Store
-