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

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

Issue 2294743003: [wasm] simd scalar lowering F32x4Add and I32x4Add (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: [wasm] simd scalar lowering F32x4Add and I32x4Add Created 4 years, 2 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 025ccdf1d7bfc0d2c159e511600b0d313cf0fa9b..a9282841d6b8716d1b55e8f7a5cd43ffef55735b 100644
--- a/src/wasm/ast-decoder.cc
+++ b/src/wasm/ast-decoder.cc
@@ -241,7 +241,8 @@ class WasmDecoder : public Decoder {
}
unsigned OpcodeLength(const byte* pc) {
- switch (static_cast<WasmOpcode>(*pc)) {
+ WasmOpcode opcode = ExtractWasmOpcode(pc);
titzer 2016/10/12 19:06:55 Could you do the trick in the main decoder loop of
aseemgarg 2016/10/17 19:01:44 Done. Actually seems like we don't need this at al
titzer 2016/10/19 18:31:49 No, you do, since we still want to be able to iter
aseemgarg 2016/10/19 23:37:33 Done.
+ switch (opcode) {
#define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE)
FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE)
@@ -308,6 +309,15 @@ class WasmDecoder : public Decoder {
return 1;
}
}
+
+ private:
+ WasmOpcode ExtractWasmOpcode(const byte* pc) {
+ WasmOpcode opcode = static_cast<WasmOpcode>(*pc);
+ if (opcode == kSimdPrefix) {
+ opcode = static_cast<WasmOpcode>((opcode << 8) | *(pc + 1));
+ }
+ return opcode;
+ }
};
static const int32_t kNullCatch = -1;
@@ -1248,18 +1258,28 @@ class WasmFullDecoder : public WasmDecoder {
return 1 + operand.length;
}
+ unsigned ExtractLane(WasmOpcode opcode, LocalType type) {
titzer 2016/10/12 19:06:55 Please make a LaneOperand class similar to the oth
aseemgarg 2016/10/17 19:01:44 Done.
+ unsigned len = 0;
+ uint8_t lane = this->checked_read_u8(pc_, 2, "lane number");
+ if (lane < 0 || lane > 3) {
+ error(pc_, pc_ + 2, "invalid extract lane value");
+ }
+ TFNode* input = Pop(0, LocalType::kSimd128).node;
+ TFNode* node = BUILD(SimdExtractLane, opcode, lane, input);
+ Push(type, node);
+ len++;
+ return len;
+ }
+
unsigned DecodeSimdOpcode(WasmOpcode opcode) {
unsigned len = 0;
switch (opcode) {
case kExprI32x4ExtractLane: {
- uint8_t lane = this->checked_read_u8(pc_, 2, "lane number");
- if (lane < 0 || lane > 3) {
- error(pc_, pc_ + 2, "invalid extract lane value");
- }
- TFNode* input = Pop(0, LocalType::kSimd128).node;
- TFNode* node = BUILD(SimdExtractLane, opcode, lane, input);
- Push(LocalType::kWord32, node);
- len++;
+ len = ExtractLane(opcode, LocalType::kWord32);
+ break;
+ }
+ case kExprF32x4ExtractLane: {
+ len = ExtractLane(opcode, LocalType::kFloat32);
break;
}
default: {
« src/compiler/wasm-linkage.cc ('K') | « src/v8.gyp ('k') | src/wasm/wasm-macro-gen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698