Class PanamaInstance
java.lang.Object
ai.tegmentum.wasmtime4j.panama.PanamaInstance
- All Implemented Interfaces:
ai.tegmentum.wasmtime4j.Instance,Closeable,AutoCloseable
Panama FFI implementation of WebAssembly Instance.
- Since:
- 1.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionPanamaInstance(PanamaModule module, PanamaStore store) Creates a new Panama instance. -
Method Summary
Modifier and TypeMethodDescriptiondoublecallF64ToF64Fast(String functionName, double arg) Fast-path call for functions with one f64 parameter returning f64.ai.tegmentum.wasmtime4j.WasmValue[]callFunction(String functionName, ai.tegmentum.wasmtime4j.WasmValue... params) ai.tegmentum.wasmtime4j.WasmValue[]callFunctionAsync(String functionName, ai.tegmentum.wasmtime4j.WasmValue... params) Calls a function using Wasmtime's native async call path.intcallI32I32ToI32Fast(String functionName, int arg1, int arg2) Fast-path call for functions with two i32 parameters returning i32.intcallI32ToI32Fast(String functionName, int arg) Fast-path call for functions with one i32 parameter returning i32.longcallI64ToI64Fast(String functionName, long arg) Fast-path call for functions with one i64 parameter returning i64.intcallToI32Fast(String functionName) Fast-path call for functions with no parameters returning i32.voidcallVoidFast(String functionName) Fast-path call for functions with no parameters and no return value.static voidReleases the current thread's call context arena, freeing its off-heap memory.voidclose()Optional<ai.tegmentum.wasmtime4j.WasmFunction> debugFunction(int functionIndex) Optional<ai.tegmentum.wasmtime4j.WasmGlobal> debugGlobal(int globalIndex) Optional<ai.tegmentum.wasmtime4j.WasmMemory> debugMemory(int memoryIndex) Optional<ai.tegmentum.wasmtime4j.WasmMemory> debugSharedMemory(int memoryIndex) Optional<ai.tegmentum.wasmtime4j.WasmTable> debugTable(int tableIndex) Optional<ai.tegmentum.wasmtime4j.memory.Tag> debugTag(int tagIndex) Optional<ai.tegmentum.wasmtime4j.Extern> getExport(ai.tegmentum.wasmtime4j.Store store, ai.tegmentum.wasmtime4j.ModuleExport moduleExport) Optional<ai.tegmentum.wasmtime4j.Extern> String[]Optional<ai.tegmentum.wasmtime4j.WasmFunction> getFunction(String name) Optional<ai.tegmentum.wasmtime4j.WasmGlobal> Optional<ai.tegmentum.wasmtime4j.WasmMemory> ai.tegmentum.wasmtime4j.ModuleGets the native instance pointer.Optional<ai.tegmentum.wasmtime4j.WasmMemory> getSharedMemory(String name) ai.tegmentum.wasmtime4j.StoregetStore()Optional<ai.tegmentum.wasmtime4j.WasmTable> Optional<ai.tegmentum.wasmtime4j.memory.Tag> booleanbooleanisValid()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ai.tegmentum.wasmtime4j.Instance
getDefaultMemory, getExports, getTypedFunc
-
Constructor Details
-
PanamaInstance
public PanamaInstance(PanamaModule module, PanamaStore store) throws ai.tegmentum.wasmtime4j.exception.WasmException Creates a new Panama instance.- Parameters:
module- the module to instantiatestore- the store to create the instance in- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException- if instance creation fails
-
-
Method Details
-
clearCallContext
public static void clearCallContext()Releases the current thread's call context arena, freeing its off-heap memory.This is useful when a thread-pool worker is about to be returned to the pool and will not make further WASM calls for a while. A new context will be lazily created on the next call.
-
getFunction
-
getGlobal
-
getTag
-
getMemory
-
getTable
-
getExportNames
- Specified by:
getExportNamesin interfaceai.tegmentum.wasmtime4j.Instance
-
debugFunction
- Specified by:
debugFunctionin interfaceai.tegmentum.wasmtime4j.Instance
-
debugGlobal
- Specified by:
debugGlobalin interfaceai.tegmentum.wasmtime4j.Instance
-
debugMemory
- Specified by:
debugMemoryin interfaceai.tegmentum.wasmtime4j.Instance
-
debugTable
- Specified by:
debugTablein interfaceai.tegmentum.wasmtime4j.Instance
-
debugTag
- Specified by:
debugTagin interfaceai.tegmentum.wasmtime4j.Instance
-
hasExport
- Specified by:
hasExportin interfaceai.tegmentum.wasmtime4j.Instance
-
getExport
-
getExport
public Optional<ai.tegmentum.wasmtime4j.Extern> getExport(ai.tegmentum.wasmtime4j.Store store, ai.tegmentum.wasmtime4j.ModuleExport moduleExport) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
getExportin interfaceai.tegmentum.wasmtime4j.Instance- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
getModule
public ai.tegmentum.wasmtime4j.Module getModule()- Specified by:
getModulein interfaceai.tegmentum.wasmtime4j.Instance
-
getStore
public ai.tegmentum.wasmtime4j.Store getStore()- Specified by:
getStorein interfaceai.tegmentum.wasmtime4j.Instance
-
getNativeInstance
Gets the native instance pointer.- Returns:
- the native instance pointer
-
callFunction
public ai.tegmentum.wasmtime4j.WasmValue[] callFunction(String functionName, ai.tegmentum.wasmtime4j.WasmValue... params) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callFunctionin interfaceai.tegmentum.wasmtime4j.Instance- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callFunctionAsync
public ai.tegmentum.wasmtime4j.WasmValue[] callFunctionAsync(String functionName, ai.tegmentum.wasmtime4j.WasmValue... params) throws ai.tegmentum.wasmtime4j.exception.WasmException Calls a function using Wasmtime's native async call path.Gets the function handle by name, calls it via
Func::call_async, and frees the handle. This enables proper async host function interleaving for stores configured with async support.- Parameters:
functionName- the function nameparams- the parameters to pass- Returns:
- the results
- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException- if the call fails
-
isValid
public boolean isValid()- Specified by:
isValidin interfaceai.tegmentum.wasmtime4j.Instance
-
callI32I32ToI32Fast
public int callI32I32ToI32Fast(String functionName, int arg1, int arg2) throws ai.tegmentum.wasmtime4j.exception.WasmException Fast-path call for functions with two i32 parameters returning i32. Bypasses WasmValue boxing entirely by writing primitives directly to native memory.- Parameters:
functionName- the name of the function to callarg1- the first i32 argumentarg2- the second i32 argument- Returns:
- the i32 result
- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException- if function execution fails
-
callI32ToI32Fast
public int callI32ToI32Fast(String functionName, int arg) throws ai.tegmentum.wasmtime4j.exception.WasmException Fast-path call for functions with one i32 parameter returning i32. Bypasses WasmValue boxing entirely by writing primitives directly to native memory.- Parameters:
functionName- the name of the function to callarg- the i32 argument- Returns:
- the i32 result
- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException- if function execution fails
-
callToI32Fast
public int callToI32Fast(String functionName) throws ai.tegmentum.wasmtime4j.exception.WasmException Fast-path call for functions with no parameters returning i32. Bypasses WasmValue boxing entirely.- Parameters:
functionName- the name of the function to call- Returns:
- the i32 result
- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException- if function execution fails
-
callVoidFast
public void callVoidFast(String functionName) throws ai.tegmentum.wasmtime4j.exception.WasmException Fast-path call for functions with no parameters and no return value. Bypasses WasmValue boxing entirely.- Parameters:
functionName- the name of the function to call- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException- if function execution fails
-
callI64ToI64Fast
public long callI64ToI64Fast(String functionName, long arg) throws ai.tegmentum.wasmtime4j.exception.WasmException Fast-path call for functions with one i64 parameter returning i64. Bypasses WasmValue boxing entirely.- Parameters:
functionName- the name of the function to callarg- the i64 argument- Returns:
- the i64 result
- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException- if function execution fails
-
callF64ToF64Fast
public double callF64ToF64Fast(String functionName, double arg) throws ai.tegmentum.wasmtime4j.exception.WasmException Fast-path call for functions with one f64 parameter returning f64. Bypasses WasmValue boxing entirely.- Parameters:
functionName- the name of the function to callarg- the f64 argument- Returns:
- the f64 result
- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException- if function execution fails
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceai.tegmentum.wasmtime4j.Instance
-