From 1812ae776a4e1906b20c7845e17d8a0e103eb275 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 3 Dec 2023 20:22:40 +0000 Subject: Use walloc to allocate on wasm32 --- .../compiler/backends/wasm/WasmBackend.java | 23 +++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/shedlang/compiler/backends/wasm/WasmBackend.java b/src/main/java/org/shedlang/compiler/backends/wasm/WasmBackend.java index 97ea0a60..2006fe83 100644 --- a/src/main/java/org/shedlang/compiler/backends/wasm/WasmBackend.java +++ b/src/main/java/org/shedlang/compiler/backends/wasm/WasmBackend.java @@ -2,15 +2,18 @@ package org.shedlang.compiler.backends.wasm; import org.shedlang.compiler.backends.Backend; import org.shedlang.compiler.backends.wasm.structure.WasmBinaryFormat; -import org.shedlang.compiler.backends.wasm.structure.ast.instructions.*; -import org.shedlang.compiler.backends.wasm.structure.ast.modules.*; -import org.shedlang.compiler.backends.wasm.structure.ast.types.WasmValueType; +import org.shedlang.compiler.backends.wasm.structure.ast.instructions.WasmCall; +import org.shedlang.compiler.backends.wasm.structure.ast.instructions.WasmDrop; +import org.shedlang.compiler.backends.wasm.structure.ast.instructions.WasmExpression; +import org.shedlang.compiler.backends.wasm.structure.ast.modules.WasmFuncName; +import org.shedlang.compiler.backends.wasm.structure.ast.modules.WasmFunction; +import org.shedlang.compiler.backends.wasm.structure.ast.modules.WasmModule; import org.shedlang.compiler.config.ProjectConfig; import org.shedlang.compiler.filesystem.ShedCompilerFiles; import org.shedlang.compiler.patio.PatioCodeGen; import org.shedlang.compiler.patio.PatioCodeGenContext; -import org.shedlang.compiler.sources.Sources; import org.shedlang.compiler.shid.ShidNamespace; +import org.shedlang.compiler.sources.Sources; import org.shedlang.compiler.typechecker.TypeInfos; import org.shedlang.compiler.types.NamespaceName; import org.shedlang.compiler.util.processes.ProcessError; @@ -79,6 +82,7 @@ public class WasmBackend implements Backend { } ldArgs.add(ShedCompilerFiles.getRoot().resolve("runtime/target/wasm32/libshed.a").toString()); + ldArgs.add(ShedCompilerFiles.getRoot().resolve("runtime/target/wasm32/libwalloc.a").toString()); runInheritIo(ldArgs); } @@ -117,16 +121,7 @@ public class WasmBackend implements Backend { * Generates the parts of the runtime that are written in native WASM. */ public static WasmModule generateNativeRuntime(WasmModule wasmModule) { - return wasmModule.addFunction(new WasmFunction( - "wasm_memory_grow", - List.of(new WasmLocal("pages", WasmValueType.I32)), - List.of(), - List.of(WasmValueType.I32), - new WasmExpression(List.of( - new WasmLocalGet(new WasmLocalIndex(0)), - new WasmMemoryGrow() - )) - )); + return wasmModule; } private static Path writeObjectFile(WasmModule module, Path workingDirectory, String name) throws IOException { -- cgit v1.2.3