OLD | NEW |
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/base/platform/elapsed-timer.h" | 7 #include "src/base/platform/elapsed-timer.h" |
8 #include "src/bit-vector.h" | 8 #include "src/bit-vector.h" |
9 #include "src/flags.h" | 9 #include "src/flags.h" |
10 #include "src/handles.h" | 10 #include "src/handles.h" |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 break; | 404 break; |
405 } | 405 } |
406 if (operand.shift < 0 || operand.shift >= max_shift) { | 406 if (operand.shift < 0 || operand.shift >= max_shift) { |
407 error(pc_ + 2, "invalid shift amount"); | 407 error(pc_ + 2, "invalid shift amount"); |
408 return false; | 408 return false; |
409 } else { | 409 } else { |
410 return true; | 410 return true; |
411 } | 411 } |
412 } | 412 } |
413 | 413 |
| 414 inline bool Validate(const byte* pc, WasmOpcode opcode, |
| 415 SimdConcatOperand<true>& operand) { |
| 416 DCHECK_EQ(wasm::kExprS8x16Concat, opcode); |
| 417 if (operand.bytes <= 0 || operand.bytes >= kSimd128Size) { |
| 418 error(pc_ + 2, "invalid byte amount"); |
| 419 return false; |
| 420 } else { |
| 421 return true; |
| 422 } |
| 423 } |
| 424 |
414 static unsigned OpcodeLength(Decoder* decoder, const byte* pc) { | 425 static unsigned OpcodeLength(Decoder* decoder, const byte* pc) { |
415 switch (static_cast<byte>(*pc)) { | 426 switch (static_cast<byte>(*pc)) { |
416 #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name: | 427 #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name: |
417 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE) | 428 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE) |
418 FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE) | 429 FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE) |
419 #undef DECLARE_OPCODE_CASE | 430 #undef DECLARE_OPCODE_CASE |
420 { | 431 { |
421 MemoryAccessOperand<true> operand(decoder, pc, UINT32_MAX); | 432 MemoryAccessOperand<true> operand(decoder, pc, UINT32_MAX); |
422 return 1 + operand.length; | 433 return 1 + operand.length; |
423 } | 434 } |
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 SimdShiftOperand<true> operand(this, pc_); | 1479 SimdShiftOperand<true> operand(this, pc_); |
1469 if (Validate(pc_, opcode, operand)) { | 1480 if (Validate(pc_, opcode, operand)) { |
1470 compiler::NodeVector inputs(1, zone_); | 1481 compiler::NodeVector inputs(1, zone_); |
1471 inputs[0] = Pop(0, ValueType::kSimd128).node; | 1482 inputs[0] = Pop(0, ValueType::kSimd128).node; |
1472 TFNode* node = BUILD(SimdShiftOp, opcode, operand.shift, inputs); | 1483 TFNode* node = BUILD(SimdShiftOp, opcode, operand.shift, inputs); |
1473 Push(ValueType::kSimd128, node); | 1484 Push(ValueType::kSimd128, node); |
1474 } | 1485 } |
1475 return operand.length; | 1486 return operand.length; |
1476 } | 1487 } |
1477 | 1488 |
| 1489 unsigned SimdConcatOp(WasmOpcode opcode) { |
| 1490 DCHECK_EQ(wasm::kExprS8x16Concat, opcode); |
| 1491 SimdConcatOperand<true> operand(this, pc_); |
| 1492 if (Validate(pc_, opcode, operand)) { |
| 1493 compiler::NodeVector inputs(2, zone_); |
| 1494 inputs[1] = Pop(1, ValueType::kSimd128).node; |
| 1495 inputs[0] = Pop(0, ValueType::kSimd128).node; |
| 1496 TFNode* node = BUILD(SimdConcatOp, operand.bytes, inputs); |
| 1497 Push(ValueType::kSimd128, node); |
| 1498 } |
| 1499 return operand.length; |
| 1500 } |
| 1501 |
1478 unsigned DecodeSimdOpcode(WasmOpcode opcode) { | 1502 unsigned DecodeSimdOpcode(WasmOpcode opcode) { |
1479 unsigned len = 0; | 1503 unsigned len = 0; |
1480 switch (opcode) { | 1504 switch (opcode) { |
1481 case kExprF32x4ExtractLane: { | 1505 case kExprF32x4ExtractLane: { |
1482 len = SimdExtractLane(opcode, ValueType::kFloat32); | 1506 len = SimdExtractLane(opcode, ValueType::kFloat32); |
1483 break; | 1507 break; |
1484 } | 1508 } |
1485 case kExprI32x4ExtractLane: | 1509 case kExprI32x4ExtractLane: |
1486 case kExprI16x8ExtractLane: | 1510 case kExprI16x8ExtractLane: |
1487 case kExprI8x16ExtractLane: { | 1511 case kExprI8x16ExtractLane: { |
(...skipping 15 matching lines...) Expand all Loading... |
1503 case kExprI32x4ShrU: | 1527 case kExprI32x4ShrU: |
1504 case kExprI16x8Shl: | 1528 case kExprI16x8Shl: |
1505 case kExprI16x8ShrS: | 1529 case kExprI16x8ShrS: |
1506 case kExprI16x8ShrU: | 1530 case kExprI16x8ShrU: |
1507 case kExprI8x16Shl: | 1531 case kExprI8x16Shl: |
1508 case kExprI8x16ShrS: | 1532 case kExprI8x16ShrS: |
1509 case kExprI8x16ShrU: { | 1533 case kExprI8x16ShrU: { |
1510 len = SimdShiftOp(opcode); | 1534 len = SimdShiftOp(opcode); |
1511 break; | 1535 break; |
1512 } | 1536 } |
| 1537 case kExprS8x16Concat: { |
| 1538 len = SimdConcatOp(opcode); |
| 1539 break; |
| 1540 } |
1513 default: { | 1541 default: { |
1514 FunctionSig* sig = WasmOpcodes::Signature(opcode); | 1542 FunctionSig* sig = WasmOpcodes::Signature(opcode); |
1515 if (sig != nullptr) { | 1543 if (sig != nullptr) { |
1516 compiler::NodeVector inputs(sig->parameter_count(), zone_); | 1544 compiler::NodeVector inputs(sig->parameter_count(), zone_); |
1517 for (size_t i = sig->parameter_count(); i > 0; i--) { | 1545 for (size_t i = sig->parameter_count(); i > 0; i--) { |
1518 Value val = Pop(static_cast<int>(i - 1), sig->GetParam(i - 1)); | 1546 Value val = Pop(static_cast<int>(i - 1), sig->GetParam(i - 1)); |
1519 inputs[i - 1] = val.node; | 1547 inputs[i - 1] = val.node; |
1520 } | 1548 } |
1521 TFNode* node = BUILD(SimdOp, opcode, inputs); | 1549 TFNode* node = BUILD(SimdOp, opcode, inputs); |
1522 Push(GetReturnType(sig), node); | 1550 Push(GetReturnType(sig), node); |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2175 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 2203 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
2176 const byte* start, const byte* end) { | 2204 const byte* start, const byte* end) { |
2177 Decoder decoder(start, end); | 2205 Decoder decoder(start, end); |
2178 return WasmDecoder::AnalyzeLoopAssignment(&decoder, start, | 2206 return WasmDecoder::AnalyzeLoopAssignment(&decoder, start, |
2179 static_cast<int>(num_locals), zone); | 2207 static_cast<int>(num_locals), zone); |
2180 } | 2208 } |
2181 | 2209 |
2182 } // namespace wasm | 2210 } // namespace wasm |
2183 } // namespace internal | 2211 } // namespace internal |
2184 } // namespace v8 | 2212 } // namespace v8 |
OLD | NEW |