use of org.graalvm.wasm.memory.ByteArrayWasmMemory in project graal by oracle.
the class SymbolTable method allocateMemory.
public void allocateMemory(int declaredMinSize, int declaredMaxSize) {
checkNotParsed();
validateSingleMemory();
memory = new MemoryInfo(declaredMinSize, declaredMaxSize);
module().addLinkAction((context, instance) -> {
final int maxAllowedSize = minUnsigned(declaredMaxSize, module().limits().memoryInstanceSizeLimit());
module().limits().checkMemoryInstanceSize(declaredMinSize);
final WasmMemory wasmMemory;
if (context.environment().getOptions().get(WasmOptions.UseUnsafeMemory)) {
wasmMemory = new UnsafeWasmMemory(declaredMinSize, declaredMaxSize, maxAllowedSize);
} else {
wasmMemory = new ByteArrayWasmMemory(declaredMinSize, declaredMaxSize, maxAllowedSize);
}
final int memoryIndex = context.memories().register(wasmMemory);
final WasmMemory allocatedMemory = context.memories().memory(memoryIndex);
instance.setMemory(allocatedMemory);
});
}
Aggregations