diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-12-03 20:22:40 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-12-03 20:22:40 +0000 |
| commit | 1812ae776a4e1906b20c7845e17d8a0e103eb275 (patch) | |
| tree | b2cd03a5b47fb0c1380093d311f36c428fb446ea /src/main/java | |
| parent | 9e5eb030d1d2a71e453e37fc5f8ba9930122a839 (diff) | |
Use walloc to allocate on wasm32
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/backends/wasm/WasmBackend.java | 23 |
1 files changed, 9 insertions, 14 deletions
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 { |
