Commit 7c92b0b5 authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

[wasm-simd] Emit SIMD opcodes as LEB encoded bytes

With https://crrev.com/c/2118476, we can decode multi byte opcodes. So
the module builder should be emitting the correct LEB encoded bytes for
SIMD opcodes.

This also fixes an error discovered by the fuzzer: I added f64x2.add to
the fuzzer, but that's actually a multi-byte opcode, so it resulted in
incorrect bytes generated. This should fix it.

Bug: chromium:1072090
Bug: v8:10258
Change-Id: I0b32ac27aa24d25ee8694dacb12d3d8339d9f839
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2158005Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67257}
parent aab04bd6
...@@ -91,7 +91,12 @@ void WasmFunctionBuilder::Emit(WasmOpcode opcode) { body_.write_u8(opcode); } ...@@ -91,7 +91,12 @@ void WasmFunctionBuilder::Emit(WasmOpcode opcode) { body_.write_u8(opcode); }
void WasmFunctionBuilder::EmitWithPrefix(WasmOpcode opcode) { void WasmFunctionBuilder::EmitWithPrefix(WasmOpcode opcode) {
DCHECK_NE(0, opcode & 0xff00); DCHECK_NE(0, opcode & 0xff00);
body_.write_u8(opcode >> 8); body_.write_u8(opcode >> 8);
body_.write_u8(opcode); if ((opcode >> 8) == WasmOpcode::kSimdPrefix) {
// SIMD opcodes are LEB encoded
body_.write_u32v(opcode & 0xff);
} else {
body_.write_u8(opcode);
}
} }
void WasmFunctionBuilder::EmitWithU8(WasmOpcode opcode, const byte immediate) { void WasmFunctionBuilder::EmitWithU8(WasmOpcode opcode, const byte immediate) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment