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

Side by Side 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: Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/signature.h" 5 #include "src/signature.h"
6 6
7 #include "src/bit-vector.h" 7 #include "src/bit-vector.h"
8 #include "src/flags.h" 8 #include "src/flags.h"
9 #include "src/handles.h" 9 #include "src/handles.h"
10 #include "src/zone-containers.h" 10 #include "src/zone-containers.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 return kArity_##sig; 381 return kArity_##sig;
382 382
383 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE) 383 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE)
384 FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE) 384 FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE)
385 FOREACH_MISC_MEM_OPCODE(DECLARE_OPCODE_CASE) 385 FOREACH_MISC_MEM_OPCODE(DECLARE_OPCODE_CASE)
386 FOREACH_SIMPLE_OPCODE(DECLARE_OPCODE_CASE) 386 FOREACH_SIMPLE_OPCODE(DECLARE_OPCODE_CASE)
387 FOREACH_SIMPLE_MEM_OPCODE(DECLARE_OPCODE_CASE) 387 FOREACH_SIMPLE_MEM_OPCODE(DECLARE_OPCODE_CASE)
388 FOREACH_ASMJS_COMPAT_OPCODE(DECLARE_OPCODE_CASE) 388 FOREACH_ASMJS_COMPAT_OPCODE(DECLARE_OPCODE_CASE)
389 FOREACH_SIMD_OPCODE(DECLARE_OPCODE_CASE) 389 FOREACH_SIMD_OPCODE(DECLARE_OPCODE_CASE)
390 #undef DECLARE_OPCODE_CASE 390 #undef DECLARE_OPCODE_CASE
391 #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
392 FOREACH_SIMD_MISC_OPCODE(DECLARE_OPCODE_CASE)
gdeepti 2016/09/01 00:52:52 Nit: Maybe use a different name here? FOREACH_SIM
aseemgarg 2016/09/02 22:40:12 Done.
393 #undef DECLARE_OPCODE_CASE
394 return 1;
391 default: 395 default:
392 UNREACHABLE(); 396 UNREACHABLE();
393 return 0; 397 return 0;
394 } 398 }
395 } 399 }
396 400
397 unsigned OpcodeLength(const byte* pc) { 401 unsigned OpcodeLength(const byte* pc) {
398 switch (static_cast<WasmOpcode>(*pc)) { 402 switch (static_cast<WasmOpcode>(*pc)) {
399 #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name: 403 #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
400 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE) 404 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 case kExprI8Const: 453 case kExprI8Const:
450 return 2; 454 return 2;
451 case kExprF32Const: 455 case kExprF32Const:
452 return 5; 456 return 5;
453 case kExprF64Const: 457 case kExprF64Const:
454 return 9; 458 return 9;
455 case kExprReturn: { 459 case kExprReturn: {
456 ReturnArityOperand operand(this, pc); 460 ReturnArityOperand operand(this, pc);
457 return 1 + operand.length; 461 return 1 + operand.length;
458 } 462 }
459 463 #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
464 FOREACH_SIMD_OPCODE(DECLARE_OPCODE_CASE) { return 2; }
gdeepti 2016/09/01 00:52:52 This doesn't seem right, for generic SIMD opcodes
aseemgarg 2016/09/02 22:40:12 This just checks the size of opcode. That is 2 (si
465 FOREACH_SIMD_MISC_OPCODE(DECLARE_OPCODE_CASE) { return 3; }
bradnelson 2016/09/01 00:51:34 Not keen on the MISC name, _0OPERAND + _1OPERAND ?
aseemgarg 2016/09/01 00:57:15 Changed name. Lot of opcodes will come in this cat
466 #undef DECLARE_OPCODE_CASE
460 default: 467 default:
461 return 1; 468 return 1;
462 } 469 }
463 } 470 }
464 }; 471 };
465 472
466 static const int32_t kFirstFinallyToken = 1; 473 static const int32_t kFirstFinallyToken = 1;
467 static const int32_t kFallthroughToken = 0; 474 static const int32_t kFallthroughToken = 0;
468 static const int32_t kNullFinallyToken = -1; 475 static const int32_t kNullFinallyToken = -1;
469 476
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 Push(GetReturnType(operand.sig), call); 1271 Push(GetReturnType(operand.sig), call);
1265 } 1272 }
1266 len = 1 + operand.length; 1273 len = 1 + operand.length;
1267 break; 1274 break;
1268 } 1275 }
1269 case kSimdPrefix: { 1276 case kSimdPrefix: {
1270 CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype); 1277 CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype);
1271 len++; 1278 len++;
1272 byte simd_index = *(pc_ + 1); 1279 byte simd_index = *(pc_ + 1);
1273 opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index); 1280 opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index);
1274 DecodeSimdOpcode(opcode); 1281 len += DecodeSimdOpcode(opcode);
1275 break; 1282 break;
1276 } 1283 }
1277 default: 1284 default:
1278 error("Invalid opcode"); 1285 error("Invalid opcode");
1279 return; 1286 return;
1280 } 1287 }
1281 } // end complex bytecode 1288 } // end complex bytecode
1282 1289
1283 #if DEBUG 1290 #if DEBUG
1284 if (FLAG_trace_wasm_decoder) { 1291 if (FLAG_trace_wasm_decoder) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 int DecodeStoreMem(LocalType type, MachineType mem_type) { 1396 int DecodeStoreMem(LocalType type, MachineType mem_type) {
1390 MemoryAccessOperand operand(this, pc_); 1397 MemoryAccessOperand operand(this, pc_);
1391 Value val = Pop(1, type); 1398 Value val = Pop(1, type);
1392 Value index = Pop(0, kAstI32); 1399 Value index = Pop(0, kAstI32);
1393 BUILD(StoreMem, mem_type, index.node, operand.offset, operand.alignment, 1400 BUILD(StoreMem, mem_type, index.node, operand.offset, operand.alignment,
1394 val.node, position()); 1401 val.node, position());
1395 Push(type, val.node); 1402 Push(type, val.node);
1396 return 1 + operand.length; 1403 return 1 + operand.length;
1397 } 1404 }
1398 1405
1399 void DecodeSimdOpcode(WasmOpcode opcode) { 1406 unsigned DecodeSimdOpcode(WasmOpcode opcode) {
1400 FunctionSig* sig = WasmOpcodes::Signature(opcode); 1407 unsigned len = 0;
1401 compiler::NodeVector inputs(sig->parameter_count(), zone_); 1408 switch (opcode) {
1402 for (size_t i = sig->parameter_count(); i > 0; i--) { 1409 case kExprI32x4ExtractLane: {
1403 Value val = Pop(static_cast<int>(i - 1), sig->GetParam(i - 1)); 1410 uint8_t lane = this->checked_read_u8(pc_, 2, "lane number");
1404 inputs[i - 1] = val.node; 1411 DCHECK(lane >= 0 && lane <= 3);
1412 TFNode* input = Pop(0, LocalType::kSimd128).node;
1413 TFNode* node = BUILD(SimdExtractLane, opcode, lane, input);
1414 Push(LocalType::kWord32, node);
1415 len++;
1416 break;
1417 }
1418 default: {
1419 FunctionSig* sig = WasmOpcodes::Signature(opcode);
1420 compiler::NodeVector inputs(sig->parameter_count(), zone_);
1421 for (size_t i = sig->parameter_count(); i > 0; i--) {
1422 Value val = Pop(static_cast<int>(i - 1), sig->GetParam(i - 1));
1423 inputs[i - 1] = val.node;
1424 }
1425 TFNode* node = BUILD(SimdOp, opcode, inputs);
1426 Push(GetReturnType(sig), node);
1427 }
1405 } 1428 }
1406 TFNode* node = BUILD(SimdOp, opcode, inputs); 1429 return len;
1407 Push(GetReturnType(sig), node);
1408 } 1430 }
1409 1431
1410 void DispatchToTargets(Control* next_block, const Value& val) { 1432 void DispatchToTargets(Control* next_block, const Value& val) {
1411 const ZoneVector<IncomingBranch>& incoming_branches = 1433 const ZoneVector<IncomingBranch>& incoming_branches =
1412 next_block->try_info->incoming_branches; 1434 next_block->try_info->incoming_branches;
1413 // Counts how many successors are not current control block. 1435 // Counts how many successors are not current control block.
1414 uint32_t targets = 0; 1436 uint32_t targets = 0;
1415 for (const auto& path_token : incoming_branches) { 1437 for (const auto& path_token : incoming_branches) {
1416 if (path_token.target != next_block) ++targets; 1438 if (path_token.target != next_block) ++targets;
1417 } 1439 }
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, 2086 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals,
2065 const byte* start, const byte* end) { 2087 const byte* start, const byte* end) {
2066 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; 2088 FunctionBody body = {nullptr, nullptr, nullptr, start, end};
2067 WasmFullDecoder decoder(zone, nullptr, body); 2089 WasmFullDecoder decoder(zone, nullptr, body);
2068 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); 2090 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals);
2069 } 2091 }
2070 2092
2071 } // namespace wasm 2093 } // namespace wasm
2072 } // namespace internal 2094 } // namespace internal
2073 } // namespace v8 2095 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698