Search in sources :

Example 1 with WasiFdWriteNode

use of org.graalvm.wasm.predefined.wasi.WasiFdWriteNode in project graal by oracle.

the class EmscriptenModule method createInstance.

@Override
protected WasmInstance createInstance(WasmLanguage language, WasmContext context, String name) {
    WasmInstance instance = new WasmInstance(context, WasmModule.createBuiltin(name), NUMBER_OF_FUNCTIONS);
    final WasmInstance testutil = context.moduleInstances().get("testutil");
    if (testutil != null) {
        // re-export some symbols from the testutil module.
        if (testutil.symbolTable().function(TestutilModule.Names.SAVE_BINARY_FILE) != null) {
            importFunction(instance, "testutil", TestutilModule.Names.SAVE_BINARY_FILE, types(I32_TYPE, I32_TYPE, I32_TYPE), types(), "" + TestutilModule.Names.SAVE_BINARY_FILE);
        }
    }
    defineFunction(instance, "abort", types(), types(), new AbortNode(language, instance));
    defineFunction(instance, "abortOnCannotGrowMemory", types(I32_TYPE), types(I32_TYPE), new AbortOnCannotGrowMemoryNode(language, instance));
    defineFunction(instance, "segfault", types(), types(), new SegfaultNode(language, instance));
    defineFunction(instance, "alignfault", types(), types(), new AlignfaultNode(language, instance));
    defineFunction(instance, "emscripten_memcpy_big", types(I32_TYPE, I32_TYPE, I32_TYPE), types(I32_TYPE), new EmscriptenMemcpyBigNode(language, instance));
    defineFunction(instance, "emscripten_get_heap_size", types(), types(I32_TYPE), new EmscriptenGetHeapSizeNode(language, instance));
    defineFunction(instance, "emscripten_resize_heap", types(I32_TYPE), types(I32_TYPE), new EmscriptenResizeHeapNode(language, instance));
    defineFunction(instance, "gettimeofday", types(I32_TYPE, I32_TYPE), types(I32_TYPE), new GetTimeOfDayNode(language, instance));
    defineFunction(instance, "llvm_exp2_f64", types(F64_TYPE), types(F64_TYPE), new LLVMExp2F64Node(language, instance));
    defineFunction(instance, "__wasi_fd_write", types(I32_TYPE, I32_TYPE, I32_TYPE, I32_TYPE), types(I32_TYPE), new WasiFdWriteNode(language, instance));
    defineFunction(instance, "__lock", types(I32_TYPE), types(), new LockNode(language, instance));
    defineFunction(instance, "__unlock", types(I32_TYPE), types(), new UnlockNode(language, instance));
    defineFunction(instance, "__setErrNo", types(I32_TYPE), types(), new SetErrNoNode(language, instance));
    defineFunction(instance, "__syscall140", types(I32_TYPE, I32_TYPE), types(I32_TYPE), new UnimplementedNode("__syscall140", language, instance));
    defineFunction(instance, "__syscall146", types(I32_TYPE, I32_TYPE), types(I32_TYPE), new UnimplementedNode("__syscall146", language, instance));
    defineFunction(instance, "__syscall54", types(I32_TYPE, I32_TYPE), types(I32_TYPE), new UnimplementedNode("__syscall54", language, instance));
    defineFunction(instance, "__syscall6", types(I32_TYPE, I32_TYPE), types(I32_TYPE), new UnimplementedNode("__syscall6", language, instance));
    defineFunction(instance, "setTempRet0", types(I32_TYPE), types(), new UnimplementedNode("setTempRet0", language, instance));
    defineGlobal(instance, "_table_base", I32_TYPE, (byte) GlobalModifier.CONSTANT, 0);
    defineGlobal(instance, "_memory_base", I32_TYPE, (byte) GlobalModifier.CONSTANT, 0);
    defineGlobal(instance, "DYNAMICTOP_PTR", I32_TYPE, (byte) GlobalModifier.CONSTANT, 0);
    defineGlobal(instance, "DYNAMIC_BASE", I32_TYPE, (byte) GlobalModifier.CONSTANT, 0);
    defineTable(instance, "table", 0, -1, ReferenceTypes.FUNCREF);
    return instance;
}
Also used : WasmInstance(org.graalvm.wasm.WasmInstance) WasiFdWriteNode(org.graalvm.wasm.predefined.wasi.WasiFdWriteNode)

Aggregations

WasmInstance (org.graalvm.wasm.WasmInstance)1 WasiFdWriteNode (org.graalvm.wasm.predefined.wasi.WasiFdWriteNode)1