Search in sources :

Example 1 with ByteArrayWasmMemory

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);
    });
}
Also used : UnsafeWasmMemory(org.graalvm.wasm.memory.UnsafeWasmMemory) UnsafeWasmMemory(org.graalvm.wasm.memory.UnsafeWasmMemory) WasmMemory(org.graalvm.wasm.memory.WasmMemory) ByteArrayWasmMemory(org.graalvm.wasm.memory.ByteArrayWasmMemory) ByteArrayWasmMemory(org.graalvm.wasm.memory.ByteArrayWasmMemory)

Aggregations

ByteArrayWasmMemory (org.graalvm.wasm.memory.ByteArrayWasmMemory)1 UnsafeWasmMemory (org.graalvm.wasm.memory.UnsafeWasmMemory)1 WasmMemory (org.graalvm.wasm.memory.WasmMemory)1