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/interpreter/bytecodes.h" | 5 #include "src/interpreter/bytecodes.h" |
6 | 6 |
7 #include <iomanip> | 7 #include <iomanip> |
8 | 8 |
9 #include "src/frames.h" | 9 #include "src/frames.h" |
10 #include "src/interpreter/bytecode-traits.h" | 10 #include "src/interpreter/bytecode-traits.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 BYTECODE_LIST(CASE) | 302 BYTECODE_LIST(CASE) |
303 #undef CASE | 303 #undef CASE |
304 } | 304 } |
305 UNREACHABLE(); | 305 UNREACHABLE(); |
306 return nullptr; | 306 return nullptr; |
307 } | 307 } |
308 | 308 |
309 // static | 309 // static |
310 OperandSize Bytecodes::GetOperandSize(Bytecode bytecode, int i, | 310 OperandSize Bytecodes::GetOperandSize(Bytecode bytecode, int i, |
311 OperandScale operand_scale) { | 311 OperandScale operand_scale) { |
| 312 DCHECK_LT(i, NumberOfOperands(bytecode)); |
| 313 return GetOperandSizes(bytecode, operand_scale)[i]; |
| 314 } |
| 315 |
| 316 // static |
| 317 const OperandSize* Bytecodes::GetOperandSizes(Bytecode bytecode, |
| 318 OperandScale operand_scale) { |
312 DCHECK(bytecode <= Bytecode::kLast); | 319 DCHECK(bytecode <= Bytecode::kLast); |
313 switch (bytecode) { | 320 switch (bytecode) { |
314 #define CASE(Name, ...) \ | 321 #define CASE(Name, ...) \ |
315 case Bytecode::k##Name: \ | 322 case Bytecode::k##Name: \ |
316 return BytecodeTraits<__VA_ARGS__>::GetOperandSize(i, operand_scale); | 323 return BytecodeTraits<__VA_ARGS__>::GetOperandSizes(operand_scale); |
317 BYTECODE_LIST(CASE) | 324 BYTECODE_LIST(CASE) |
318 #undef CASE | 325 #undef CASE |
319 } | 326 } |
320 UNREACHABLE(); | 327 UNREACHABLE(); |
321 return OperandSize::kNone; | 328 return nullptr; |
322 } | 329 } |
323 | 330 |
324 // static | 331 // static |
325 int Bytecodes::GetRegisterOperandBitmap(Bytecode bytecode) { | 332 int Bytecodes::GetRegisterOperandBitmap(Bytecode bytecode) { |
326 DCHECK(bytecode <= Bytecode::kLast); | 333 DCHECK(bytecode <= Bytecode::kLast); |
327 switch (bytecode) { | 334 switch (bytecode) { |
328 #define CASE(Name, ...) \ | 335 #define CASE(Name, ...) \ |
329 case Bytecode::k##Name: \ | 336 case Bytecode::k##Name: \ |
330 typedef BytecodeTraits<__VA_ARGS__> Name##Trait; \ | 337 typedef BytecodeTraits<__VA_ARGS__> Name##Trait; \ |
331 return Name##Trait::kRegisterOperandBitmap; | 338 return Name##Trait::kRegisterOperandBitmap; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 } else if (value <= static_cast<size_t>(kMaxUInt16)) { | 618 } else if (value <= static_cast<size_t>(kMaxUInt16)) { |
612 return OperandSize::kShort; | 619 return OperandSize::kShort; |
613 } else if (value <= kMaxUInt32) { | 620 } else if (value <= kMaxUInt32) { |
614 return OperandSize::kQuad; | 621 return OperandSize::kQuad; |
615 } else { | 622 } else { |
616 UNREACHABLE(); | 623 UNREACHABLE(); |
617 return OperandSize::kQuad; | 624 return OperandSize::kQuad; |
618 } | 625 } |
619 } | 626 } |
620 | 627 |
| 628 OperandScale Bytecodes::OperandSizesToScale(OperandSize size0) { |
| 629 OperandScale operand_scale = static_cast<OperandScale>(size0); |
| 630 DCHECK(operand_scale == OperandScale::kSingle || |
| 631 operand_scale == OperandScale::kDouble || |
| 632 operand_scale == OperandScale::kQuadruple); |
| 633 return operand_scale; |
| 634 } |
| 635 |
| 636 OperandScale Bytecodes::OperandSizesToScale(OperandSize size0, |
| 637 OperandSize size1) { |
| 638 OperandSize operand_size = std::max(size0, size1); |
| 639 // Operand sizes have been scaled before calling this function. |
| 640 // Currently all scalable operands are byte sized at |
| 641 // OperandScale::kSingle. |
| 642 STATIC_ASSERT(static_cast<int>(OperandSize::kByte) == |
| 643 static_cast<int>(OperandScale::kSingle) && |
| 644 static_cast<int>(OperandSize::kShort) == |
| 645 static_cast<int>(OperandScale::kDouble) && |
| 646 static_cast<int>(OperandSize::kQuad) == |
| 647 static_cast<int>(OperandScale::kQuadruple)); |
| 648 OperandScale operand_scale = static_cast<OperandScale>(operand_size); |
| 649 DCHECK(operand_scale == OperandScale::kSingle || |
| 650 operand_scale == OperandScale::kDouble || |
| 651 operand_scale == OperandScale::kQuadruple); |
| 652 return operand_scale; |
| 653 } |
| 654 |
621 OperandScale Bytecodes::OperandSizesToScale(OperandSize size0, | 655 OperandScale Bytecodes::OperandSizesToScale(OperandSize size0, |
622 OperandSize size1, | 656 OperandSize size1, |
623 OperandSize size2, | 657 OperandSize size2, |
624 OperandSize size3) { | 658 OperandSize size3) { |
625 OperandSize upper = std::max(size0, size1); | 659 OperandSize upper = std::max(size0, size1); |
626 OperandSize lower = std::max(size2, size3); | 660 OperandSize lower = std::max(size2, size3); |
627 OperandSize result = std::max(upper, lower); | 661 OperandSize result = std::max(upper, lower); |
628 // Operand sizes have been scaled before calling this function. | 662 // Operand sizes have been scaled before calling this function. |
629 // Currently all scalable operands are byte sized at | 663 // Currently all scalable operands are byte sized at |
630 // OperandScale::kSingle. | 664 // OperandScale::kSingle. |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 } else { | 962 } else { |
929 std::ostringstream s; | 963 std::ostringstream s; |
930 s << "r" << index(); | 964 s << "r" << index(); |
931 return s.str(); | 965 return s.str(); |
932 } | 966 } |
933 } | 967 } |
934 | 968 |
935 } // namespace interpreter | 969 } // namespace interpreter |
936 } // namespace internal | 970 } // namespace internal |
937 } // namespace v8 | 971 } // namespace v8 |
OLD | NEW |