Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2457,8 +2457,8 @@ private static void LOCAL_SET(MStack stack, Operands operands, StackFrame curren
if (localType.isObjectRef()) {
currentStackFrame.setLocalRef(i, stack.popRef());
} else if (localType.equals(ValType.V128)) {
currentStackFrame.setLocal(i, stack.pop());
currentStackFrame.setLocal(i + 1, stack.pop());
currentStackFrame.setLocal(i, stack.pop());
} else {
currentStackFrame.setLocal(i, stack.pop());
}
Expand All @@ -2472,10 +2472,10 @@ private static void LOCAL_TEE(MStack stack, Operands operands, StackFrame curren
if (localType.isObjectRef()) {
currentStackFrame.setLocalRef(i, stack.peekRef());
} else if (localType.equals(ValType.V128)) {
var tmp = stack.pop();
currentStackFrame.setLocal(i, tmp);
currentStackFrame.setLocal(i + 1, stack.peek());
stack.push(tmp);
var high = stack.pop();
currentStackFrame.setLocal(i + 1, high);
currentStackFrame.setLocal(i, stack.peek());
stack.push(high);
} else {
currentStackFrame.setLocal(i, stack.peek());
}
Expand Down
15 changes: 15 additions & 0 deletions simd/src/test/java/run/endive/simd/BasicSimdTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ public void shouldRunBasicExample() {
var result = main.apply()[0];
assertEquals(6L, result);
}

@Test
public void shouldRoundTripV128Locals() {
var instance =
Instance.builder(
Parser.parse(
CorpusResources.getResource(
"compiled/simd-locals.wat.wasm")))
.withMachineFactory(SimdInterpreterMachine::new)
.build();
assertEquals(10L, instance.export("local_roundtrip").apply()[0]);
assertEquals(7L, instance.export("local_roundtrip_lane0").apply()[0]);
assertEquals(10L, instance.export("local_tee").apply()[0]);
assertEquals(7L, instance.export("local_tee_get").apply()[0]);
}
}
Binary file not shown.
16 changes: 16 additions & 0 deletions wasm-corpus/src/main/resources/wat/simd-locals.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(module
(func (export "local_roundtrip") (result i32) (local v128)
(local.set 0 (v128.const i32x4 7 8 9 10))
(i32x4.extract_lane 3 (local.get 0)))

(func (export "local_roundtrip_lane0") (result i32) (local v128)
(local.set 0 (v128.const i32x4 7 8 9 10))
(i32x4.extract_lane 0 (local.get 0)))

(func (export "local_tee") (result i32) (local v128)
(i32x4.extract_lane 3 (local.tee 0 (v128.const i32x4 7 8 9 10))))

(func (export "local_tee_get") (result i32) (local v128)
(drop (local.tee 0 (v128.const i32x4 7 8 9 10)))
(i32x4.extract_lane 0 (local.get 0)))
)
Loading