Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1335)

Unified Diff: src/wasm/ast-decoder.cc

Issue 2300753005: [wasm] fix Simd ExtractLane to take immediate instead of param (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: [wasm] fix Simd ExtractLane to take immediate instead of param Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/wasm/ast-decoder.cc
diff --git a/src/wasm/ast-decoder.cc b/src/wasm/ast-decoder.cc
index 798f9d393a5bf10dba8e1c5b5ebb944e1d0f171e..1d4b0014a1042f00d41f8b35cc7d25194ba76814 100644
--- a/src/wasm/ast-decoder.cc
+++ b/src/wasm/ast-decoder.cc
@@ -386,8 +386,12 @@ class WasmDecoder : public Decoder {
FOREACH_SIMPLE_OPCODE(DECLARE_OPCODE_CASE)
FOREACH_SIMPLE_MEM_OPCODE(DECLARE_OPCODE_CASE)
FOREACH_ASMJS_COMPAT_OPCODE(DECLARE_OPCODE_CASE)
- FOREACH_SIMD_OPCODE(DECLARE_OPCODE_CASE)
+ FOREACH_SIMD_0_OPERAND_OPCODE(DECLARE_OPCODE_CASE)
#undef DECLARE_OPCODE_CASE
+#define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
+ FOREACH_SIMD_1_OPERAND_OPCODE(DECLARE_OPCODE_CASE)
+#undef DECLARE_OPCODE_CASE
+ return 1;
default:
UNREACHABLE();
return 0;
@@ -456,7 +460,10 @@ class WasmDecoder : public Decoder {
ReturnArityOperand operand(this, pc);
return 1 + operand.length;
}
-
+#define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
+ FOREACH_SIMD_0_OPERAND_OPCODE(DECLARE_OPCODE_CASE) { return 2; }
+ FOREACH_SIMD_1_OPERAND_OPCODE(DECLARE_OPCODE_CASE) { return 3; }
+#undef DECLARE_OPCODE_CASE
default:
return 1;
}
@@ -1271,7 +1278,7 @@ class WasmFullDecoder : public WasmDecoder {
len++;
byte simd_index = *(pc_ + 1);
opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index);
- DecodeSimdOpcode(opcode);
+ len += DecodeSimdOpcode(opcode);
break;
}
default:
@@ -1396,15 +1403,30 @@ class WasmFullDecoder : public WasmDecoder {
return 1 + operand.length;
}
- void DecodeSimdOpcode(WasmOpcode opcode) {
- FunctionSig* sig = WasmOpcodes::Signature(opcode);
- compiler::NodeVector inputs(sig->parameter_count(), zone_);
- for (size_t i = sig->parameter_count(); i > 0; i--) {
- Value val = Pop(static_cast<int>(i - 1), sig->GetParam(i - 1));
- inputs[i - 1] = val.node;
+ unsigned DecodeSimdOpcode(WasmOpcode opcode) {
+ unsigned len = 0;
+ switch (opcode) {
+ case kExprI32x4ExtractLane: {
+ uint8_t lane = this->checked_read_u8(pc_, 2, "lane number");
+ DCHECK(lane >= 0 && lane <= 3);
titzer 2016/09/01 08:32:43 Don't use DCHECK's, they will cause a crash. Inste
aseemgarg 2016/09/02 22:40:13 Done.
+ TFNode* input = Pop(0, LocalType::kSimd128).node;
+ TFNode* node = BUILD(SimdExtractLane, opcode, lane, input);
+ Push(LocalType::kWord32, node);
+ len++;
+ break;
+ }
+ default: {
titzer 2016/09/01 08:32:43 You will need to signal an error for unknown opcod
aseemgarg 2016/09/02 22:40:12 Done.
+ FunctionSig* sig = WasmOpcodes::Signature(opcode);
+ compiler::NodeVector inputs(sig->parameter_count(), zone_);
+ for (size_t i = sig->parameter_count(); i > 0; i--) {
+ Value val = Pop(static_cast<int>(i - 1), sig->GetParam(i - 1));
+ inputs[i - 1] = val.node;
+ }
+ TFNode* node = BUILD(SimdOp, opcode, inputs);
+ Push(GetReturnType(sig), node);
+ }
}
- TFNode* node = BUILD(SimdOp, opcode, inputs);
- Push(GetReturnType(sig), node);
+ return len;
}
void DispatchToTargets(Control* next_block, const Value& val) {

Powered by Google App Engine
This is Rietveld 408576698