From d245348585002dae57dd03ba4bb1e9382e6fffe9 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 26 Dec 2023 23:02:50 +0000 Subject: Add support for i64.load instruction --- ...mpiler.testing.snapshots.Snapshotter)].expected | 14 ++++++---- ...mpiler.testing.snapshots.Snapshotter)].expected | 14 ++++++---- ...mpiler.testing.snapshots.Snapshotter)].expected | 28 +++++++++++++++++++ ...mpiler.testing.snapshots.Snapshotter)].expected | 14 ++++++---- ...mpiler.testing.snapshots.Snapshotter)].expected | 14 ++++++---- ...mpiler.testing.snapshots.Snapshotter)].expected | 14 ++++++---- ...mpiler.testing.snapshots.Snapshotter)].expected | 14 ++++++---- ...mpiler.testing.snapshots.Snapshotter)].expected | 28 +++++++++++++++++++ ...mpiler.testing.snapshots.Snapshotter)].expected | 14 ++++++---- ...mpiler.testing.snapshots.Snapshotter)].expected | 14 ++++++---- .../structure/ast/instructions/WasmI64Load.java | 4 +++ .../ast/instructions/WasmInstruction.java | 2 +- .../binary/WasmBinaryFormatInstructions.java | 5 ++++ .../binary/WasmBinaryFormatInstructionsTests.java | 32 ++++++++++++++++++++++ 14 files changed, 162 insertions(+), 49 deletions(-) create mode 100644 snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Load(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected create mode 100644 snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Load(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected create mode 100644 src/main/java/org/shedlang/compiler/backends/wasm/structure/ast/instructions/WasmI64Load.java diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Add(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Add(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index 6d1bbe07..ed11e0d9 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Add(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Add(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -7,6 +7,8 @@ Type[1]: - type[0] () -> nil Function[1]: - func[0] sig=0 +Memory[1]: + - memory[0] pages: initial=0 Code[1]: - func[0] size=8 Custom: @@ -19,9 +21,9 @@ Custom: Code Disassembly: -000026 func[0] : - 000027: 41 00 | i32.const 0 - 000029: 41 00 | i32.const 0 - 00002b: 6a | i32.add - 00002c: 1a | drop - 00002d: 0b | end \ No newline at end of file +00002f func[0] : + 000030: 41 00 | i32.const 0 + 000032: 41 00 | i32.const 0 + 000034: 6a | i32.add + 000035: 1a | drop + 000036: 0b | end \ No newline at end of file diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Eq(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Eq(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index 70732582..f3539d94 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Eq(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Eq(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -7,6 +7,8 @@ Type[1]: - type[0] () -> nil Function[1]: - func[0] sig=0 +Memory[1]: + - memory[0] pages: initial=0 Code[1]: - func[0] size=8 Custom: @@ -19,9 +21,9 @@ Custom: Code Disassembly: -000026 func[0] : - 000027: 41 00 | i32.const 0 - 000029: 41 00 | i32.const 0 - 00002b: 46 | i32.eq - 00002c: 1a | drop - 00002d: 0b | end \ No newline at end of file +00002f func[0] : + 000030: 41 00 | i32.const 0 + 000032: 41 00 | i32.const 0 + 000034: 46 | i32.eq + 000035: 1a | drop + 000036: 0b | end \ No newline at end of file diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Load(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Load(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected new file mode 100644 index 00000000..4871e7c3 --- /dev/null +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Load(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -0,0 +1,28 @@ + +module.wasm: file format wasm 0x1 + +Section Details: + +Type[1]: + - type[0] () -> nil +Function[1]: + - func[0] sig=0 +Memory[1]: + - memory[0] pages: initial=0 +Code[1]: + - func[0] size=9 +Custom: + - name: "linking" + - symbol table [count=1] + - 0: F func=0 [ binding=global vis=default ] +Custom: + - name: "name" + - func[0] + +Code Disassembly: + +00002f func[0] : + 000030: 41 00 | i32.const 0 + 000032: 28 00 80 01 | i32.load 0 128 + 000036: 1a | drop + 000037: 0b | end \ No newline at end of file diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Ne(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Ne(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index 482fabf1..fb529284 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Ne(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Ne(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -7,6 +7,8 @@ Type[1]: - type[0] () -> nil Function[1]: - func[0] sig=0 +Memory[1]: + - memory[0] pages: initial=0 Code[1]: - func[0] size=8 Custom: @@ -19,9 +21,9 @@ Custom: Code Disassembly: -000026 func[0] : - 000027: 41 00 | i32.const 0 - 000029: 41 00 | i32.const 0 - 00002b: 47 | i32.ne - 00002c: 1a | drop - 00002d: 0b | end \ No newline at end of file +00002f func[0] : + 000030: 41 00 | i32.const 0 + 000032: 41 00 | i32.const 0 + 000034: 47 | i32.ne + 000035: 1a | drop + 000036: 0b | end \ No newline at end of file diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Sub(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Sub(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index 9a1d3406..daf3ed62 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Sub(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI32Sub(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -7,6 +7,8 @@ Type[1]: - type[0] () -> nil Function[1]: - func[0] sig=0 +Memory[1]: + - memory[0] pages: initial=0 Code[1]: - func[0] size=8 Custom: @@ -19,9 +21,9 @@ Custom: Code Disassembly: -000026 func[0] : - 000027: 41 00 | i32.const 0 - 000029: 41 00 | i32.const 0 - 00002b: 6b | i32.sub - 00002c: 1a | drop - 00002d: 0b | end \ No newline at end of file +00002f func[0] : + 000030: 41 00 | i32.const 0 + 000032: 41 00 | i32.const 0 + 000034: 6b | i32.sub + 000035: 1a | drop + 000036: 0b | end \ No newline at end of file diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Add(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Add(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index 77ac9eb9..599027fc 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Add(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Add(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -7,6 +7,8 @@ Type[1]: - type[0] () -> nil Function[1]: - func[0] sig=0 +Memory[1]: + - memory[0] pages: initial=0 Code[1]: - func[0] size=8 Custom: @@ -19,9 +21,9 @@ Custom: Code Disassembly: -000026 func[0] : - 000027: 42 00 | i64.const 0 - 000029: 42 00 | i64.const 0 - 00002b: 7c | i64.add - 00002c: 1a | drop - 00002d: 0b | end \ No newline at end of file +00002f func[0] : + 000030: 42 00 | i64.const 0 + 000032: 42 00 | i64.const 0 + 000034: 7c | i64.add + 000035: 1a | drop + 000036: 0b | end \ No newline at end of file diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Eq(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Eq(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index 98c106fe..0293944d 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Eq(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Eq(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -7,6 +7,8 @@ Type[1]: - type[0] () -> nil Function[1]: - func[0] sig=0 +Memory[1]: + - memory[0] pages: initial=0 Code[1]: - func[0] size=8 Custom: @@ -19,9 +21,9 @@ Custom: Code Disassembly: -000026 func[0] : - 000027: 42 00 | i64.const 0 - 000029: 42 00 | i64.const 0 - 00002b: 51 | i64.eq - 00002c: 1a | drop - 00002d: 0b | end \ No newline at end of file +00002f func[0] : + 000030: 42 00 | i64.const 0 + 000032: 42 00 | i64.const 0 + 000034: 51 | i64.eq + 000035: 1a | drop + 000036: 0b | end \ No newline at end of file diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Load(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Load(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected new file mode 100644 index 00000000..7f845af4 --- /dev/null +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Load(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -0,0 +1,28 @@ + +module.wasm: file format wasm 0x1 + +Section Details: + +Type[1]: + - type[0] () -> nil +Function[1]: + - func[0] sig=0 +Memory[1]: + - memory[0] pages: initial=0 +Code[1]: + - func[0] size=9 +Custom: + - name: "linking" + - symbol table [count=1] + - 0: F func=0 [ binding=global vis=default ] +Custom: + - name: "name" + - func[0] + +Code Disassembly: + +00002f func[0] : + 000030: 41 00 | i32.const 0 + 000032: 29 00 80 01 | i64.load 0 128 + 000036: 1a | drop + 000037: 0b | end \ No newline at end of file diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Ne(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Ne(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index b4c4526b..2cba197b 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Ne(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Ne(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -7,6 +7,8 @@ Type[1]: - type[0] () -> nil Function[1]: - func[0] sig=0 +Memory[1]: + - memory[0] pages: initial=0 Code[1]: - func[0] size=8 Custom: @@ -19,9 +21,9 @@ Custom: Code Disassembly: -000026 func[0] : - 000027: 42 00 | i64.const 0 - 000029: 42 00 | i64.const 0 - 00002b: 52 | i64.ne - 00002c: 1a | drop - 00002d: 0b | end \ No newline at end of file +00002f func[0] : + 000030: 42 00 | i64.const 0 + 000032: 42 00 | i64.const 0 + 000034: 52 | i64.ne + 000035: 1a | drop + 000036: 0b | end \ No newline at end of file diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Sub(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Sub(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index e310c0ad..13335ad4 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Sub(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatInstructionsTests]/[method:canSerializeI64Sub(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -7,6 +7,8 @@ Type[1]: - type[0] () -> nil Function[1]: - func[0] sig=0 +Memory[1]: + - memory[0] pages: initial=0 Code[1]: - func[0] size=8 Custom: @@ -19,9 +21,9 @@ Custom: Code Disassembly: -000026 func[0] : - 000027: 42 00 | i64.const 0 - 000029: 42 00 | i64.const 0 - 00002b: 7d | i64.sub - 00002c: 1a | drop - 00002d: 0b | end \ No newline at end of file +00002f func[0] : + 000030: 42 00 | i64.const 0 + 000032: 42 00 | i64.const 0 + 000034: 7d | i64.sub + 000035: 1a | drop + 000036: 0b | end \ No newline at end of file diff --git a/src/main/java/org/shedlang/compiler/backends/wasm/structure/ast/instructions/WasmI64Load.java b/src/main/java/org/shedlang/compiler/backends/wasm/structure/ast/instructions/WasmI64Load.java new file mode 100644 index 00000000..1724e654 --- /dev/null +++ b/src/main/java/org/shedlang/compiler/backends/wasm/structure/ast/instructions/WasmI64Load.java @@ -0,0 +1,4 @@ +package org.shedlang.compiler.backends.wasm.structure.ast.instructions; + +public record WasmI64Load(WasmMemoryArg memoryArg) implements WasmInstruction { +} diff --git a/src/main/java/org/shedlang/compiler/backends/wasm/structure/ast/instructions/WasmInstruction.java b/src/main/java/org/shedlang/compiler/backends/wasm/structure/ast/instructions/WasmInstruction.java index c59e6e21..5198d187 100644 --- a/src/main/java/org/shedlang/compiler/backends/wasm/structure/ast/instructions/WasmInstruction.java +++ b/src/main/java/org/shedlang/compiler/backends/wasm/structure/ast/instructions/WasmInstruction.java @@ -1,4 +1,4 @@ package org.shedlang.compiler.backends.wasm.structure.ast.instructions; -public sealed interface WasmInstruction permits WasmBlock, WasmBr, WasmCall, WasmCallIndirect, WasmDrop, WasmGlobalGet, WasmGlobalSet, WasmI32Add, WasmI32Const, WasmI32Eq, WasmI32Load, WasmI32Ne, WasmI32Store, WasmI32Sub, WasmI64Add, WasmI64Const, WasmI64Eq, WasmI64Ne, WasmI64Sub, WasmIf, WasmLocalGet, WasmLocalSet, WasmLoop, WasmMemoryAddressConst, WasmMemoryGrow, WasmReturn, WasmTableElementIndexConst, WasmThrow, WasmTry, WasmUnreachable { +public sealed interface WasmInstruction permits WasmBlock, WasmBr, WasmCall, WasmCallIndirect, WasmDrop, WasmGlobalGet, WasmGlobalSet, WasmI32Add, WasmI32Const, WasmI32Eq, WasmI32Load, WasmI32Ne, WasmI32Store, WasmI32Sub, WasmI64Add, WasmI64Const, WasmI64Eq, WasmI64Load, WasmI64Ne, WasmI64Sub, WasmIf, WasmLocalGet, WasmLocalSet, WasmLoop, WasmMemoryAddressConst, WasmMemoryGrow, WasmReturn, WasmTableElementIndexConst, WasmThrow, WasmTry, WasmUnreachable { } diff --git a/src/main/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructions.java b/src/main/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructions.java index d32b35b2..0af98318 100644 --- a/src/main/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructions.java +++ b/src/main/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructions.java @@ -112,6 +112,11 @@ public class WasmBinaryFormatInstructions { writeMemoryArg(i32Load.memoryArg(), writer); } + case WasmI64Load i64Load -> { + writer.writeByte(0x29); + writeMemoryArg(i64Load.memoryArg(), writer); + } + case WasmI32Store i32Store -> { writer.writeByte(0x36); writeMemoryArg(i32Store.memoryArg(), writer); diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructionsTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructionsTests.java index 80a5b609..373ad37b 100644 --- a/src/test/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructionsTests.java +++ b/src/test/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructionsTests.java @@ -4,6 +4,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; 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.WasmIndexType; +import org.shedlang.compiler.backends.wasm.structure.ast.types.WasmLimits; +import org.shedlang.compiler.backends.wasm.structure.ast.types.WasmMemoryType; import org.shedlang.compiler.backends.wasm.structure.ast.types.WasmValueType; import org.shedlang.compiler.testing.snapshots.SnapshotResolver; import org.shedlang.compiler.testing.snapshots.Snapshotter; @@ -16,6 +19,34 @@ import static org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFor @ExtendWith({SnapshotResolver.class}) public class WasmBinaryFormatInstructionsTests { + // == Memory Instructions == + + @Test + public void canSerializeI32Load(Snapshotter snapshotter) throws IOException, InterruptedException { + var instructions = List.of( + new WasmI32Const(0), + new WasmI32Load(new WasmMemoryArg(128, WasmAlignment.NONE)), + new WasmDrop() + ); + + var result = serializeInstructions(instructions); + + snapshotter.assertSnapshot(result); + } + + @Test + public void canSerializeI64Load(Snapshotter snapshotter) throws IOException, InterruptedException { + var instructions = List.of( + new WasmI32Const(0), + new WasmI64Load(new WasmMemoryArg(128, WasmAlignment.NONE)), + new WasmDrop() + ); + + var result = serializeInstructions(instructions); + + snapshotter.assertSnapshot(result); + } + // == Numeric Instructions == @Test @@ -237,6 +268,7 @@ public class WasmBinaryFormatInstructionsTests { instructions ) throws IOException, InterruptedException { var module = WasmModule.EMPTY + .addMemory(new WasmMemory(new WasmMemoryType(WasmLimits.min32(0)))) .addFunction(new WasmFunction( "f", List.of(), -- cgit v1.2.3