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

Side by Side Diff: src/interpreter/bytecodes.cc

Issue 2041913002: [interpreter] Remove OperandScale from front stages of pipeline. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 6 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/interpreter/bytecodes.h" 5 #include "src/interpreter/bytecodes.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 8
9 #include "src/base/bits.h"
9 #include "src/frames.h" 10 #include "src/frames.h"
10 #include "src/interpreter/bytecode-traits.h" 11 #include "src/interpreter/bytecode-traits.h"
11 #include "src/interpreter/interpreter.h" 12 #include "src/interpreter/interpreter.h"
12 13
13 namespace v8 { 14 namespace v8 {
14 namespace internal { 15 namespace internal {
15 namespace interpreter { 16 namespace interpreter {
16 17
17 18
18 // static 19 // static
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 case Bytecode::k##Name: \ 318 case Bytecode::k##Name: \
318 return BytecodeTraits<__VA_ARGS__>::GetOperandTypes(); 319 return BytecodeTraits<__VA_ARGS__>::GetOperandTypes();
319 BYTECODE_LIST(CASE) 320 BYTECODE_LIST(CASE)
320 #undef CASE 321 #undef CASE
321 } 322 }
322 UNREACHABLE(); 323 UNREACHABLE();
323 return nullptr; 324 return nullptr;
324 } 325 }
325 326
326 // static 327 // static
328 const OperandTypeInfo* Bytecodes::GetOperandTypeInfos(Bytecode bytecode) {
329 DCHECK(bytecode <= Bytecode::kLast);
330 switch (bytecode) {
331 #define CASE(Name, ...) \
332 case Bytecode::k##Name: \
333 return BytecodeTraits<__VA_ARGS__>::GetOperandTypeInfos();
334 BYTECODE_LIST(CASE)
335 #undef CASE
336 }
337 UNREACHABLE();
338 return nullptr;
339 }
340
341 // static
327 OperandSize Bytecodes::GetOperandSize(Bytecode bytecode, int i, 342 OperandSize Bytecodes::GetOperandSize(Bytecode bytecode, int i,
328 OperandScale operand_scale) { 343 OperandScale operand_scale) {
329 DCHECK_LT(i, NumberOfOperands(bytecode)); 344 DCHECK_LT(i, NumberOfOperands(bytecode));
330 return GetOperandSizes(bytecode, operand_scale)[i]; 345 return GetOperandSizes(bytecode, operand_scale)[i];
331 } 346 }
332 347
333 // static 348 // static
334 const OperandSize* Bytecodes::GetOperandSizes(Bytecode bytecode, 349 const OperandSize* Bytecodes::GetOperandSizes(Bytecode bytecode,
335 OperandScale operand_scale) { 350 OperandScale operand_scale) {
336 DCHECK(bytecode <= Bytecode::kLast); 351 DCHECK(bytecode <= Bytecode::kLast);
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 UNREACHABLE(); 606 UNREACHABLE();
592 } 607 }
593 return 0; 608 return 0;
594 } 609 }
595 610
596 // static 611 // static
597 bool Bytecodes::IsUnsignedOperandType(OperandType operand_type) { 612 bool Bytecodes::IsUnsignedOperandType(OperandType operand_type) {
598 switch (operand_type) { 613 switch (operand_type) {
599 #define CASE(Name, _) \ 614 #define CASE(Name, _) \
600 case OperandType::k##Name: \ 615 case OperandType::k##Name: \
601 return OperandTraits<OperandType::k##Name>::TypeInfo::kIsUnsigned; 616 return OperandTraits<OperandType::k##Name>::TypeInfoTraits::kIsUnsigned;
602 OPERAND_TYPE_LIST(CASE) 617 OPERAND_TYPE_LIST(CASE)
603 #undef CASE 618 #undef CASE
604 } 619 }
605 UNREACHABLE(); 620 UNREACHABLE();
606 return false; 621 return false;
607 } 622 }
608 623
609 // static 624 // static
610 OperandSize Bytecodes::SizeForSignedOperand(int value) { 625 OperandSize Bytecodes::SizeForSignedOperand(int value) {
611 if (kMinInt8 <= value && value <= kMaxInt8) { 626 if (value >= kMinInt8 && value <= kMaxInt8) {
612 return OperandSize::kByte; 627 return OperandSize::kByte;
613 } else if (kMinInt16 <= value && value <= kMaxInt16) { 628 } else if (value >= kMinInt16 && value <= kMaxInt16) {
614 return OperandSize::kShort; 629 return OperandSize::kShort;
615 } else { 630 } else {
616 return OperandSize::kQuad; 631 return OperandSize::kQuad;
617 } 632 }
618 } 633 }
619 634
620 // static 635 // static
621 OperandSize Bytecodes::SizeForUnsignedOperand(int value) { 636 OperandSize Bytecodes::SizeForUnsignedOperand(uint32_t value) {
622 DCHECK_GE(value, 0);
623 if (value <= kMaxUInt8) { 637 if (value <= kMaxUInt8) {
624 return OperandSize::kByte; 638 return OperandSize::kByte;
625 } else if (value <= kMaxUInt16) { 639 } else if (value <= kMaxUInt16) {
626 return OperandSize::kShort; 640 return OperandSize::kShort;
627 } else { 641 } else {
628 return OperandSize::kQuad; 642 return OperandSize::kQuad;
629 } 643 }
630 } 644 }
631 645
632 OperandSize Bytecodes::SizeForUnsignedOperand(size_t value) {
633 if (value <= static_cast<size_t>(kMaxUInt8)) {
634 return OperandSize::kByte;
635 } else if (value <= static_cast<size_t>(kMaxUInt16)) {
636 return OperandSize::kShort;
637 } else if (value <= kMaxUInt32) {
638 return OperandSize::kQuad;
639 } else {
640 UNREACHABLE();
641 return OperandSize::kQuad;
642 }
643 }
644
645 OperandScale Bytecodes::OperandSizesToScale(OperandSize size0) {
646 OperandScale operand_scale = static_cast<OperandScale>(size0);
647 DCHECK(operand_scale == OperandScale::kSingle ||
648 operand_scale == OperandScale::kDouble ||
649 operand_scale == OperandScale::kQuadruple);
650 return operand_scale;
651 }
652
653 OperandScale Bytecodes::OperandSizesToScale(OperandSize size0,
654 OperandSize size1) {
655 OperandSize operand_size = std::max(size0, size1);
656 // Operand sizes have been scaled before calling this function.
657 // Currently all scalable operands are byte sized at
658 // OperandScale::kSingle.
659 STATIC_ASSERT(static_cast<int>(OperandSize::kByte) ==
660 static_cast<int>(OperandScale::kSingle) &&
661 static_cast<int>(OperandSize::kShort) ==
662 static_cast<int>(OperandScale::kDouble) &&
663 static_cast<int>(OperandSize::kQuad) ==
664 static_cast<int>(OperandScale::kQuadruple));
665 OperandScale operand_scale = static_cast<OperandScale>(operand_size);
666 DCHECK(operand_scale == OperandScale::kSingle ||
667 operand_scale == OperandScale::kDouble ||
668 operand_scale == OperandScale::kQuadruple);
669 return operand_scale;
670 }
671
672 OperandScale Bytecodes::OperandSizesToScale(OperandSize size0,
673 OperandSize size1,
674 OperandSize size2,
675 OperandSize size3) {
676 OperandSize upper = std::max(size0, size1);
677 OperandSize lower = std::max(size2, size3);
678 OperandSize result = std::max(upper, lower);
679 // Operand sizes have been scaled before calling this function.
680 // Currently all scalable operands are byte sized at
681 // OperandScale::kSingle.
682 STATIC_ASSERT(static_cast<int>(OperandSize::kByte) ==
683 static_cast<int>(OperandScale::kSingle) &&
684 static_cast<int>(OperandSize::kShort) ==
685 static_cast<int>(OperandScale::kDouble) &&
686 static_cast<int>(OperandSize::kQuad) ==
687 static_cast<int>(OperandScale::kQuadruple));
688 OperandScale operand_scale = static_cast<OperandScale>(result);
689 DCHECK(operand_scale == OperandScale::kSingle ||
690 operand_scale == OperandScale::kDouble ||
691 operand_scale == OperandScale::kQuadruple);
692 return operand_scale;
693 }
694
695 // static 646 // static
696 Register Bytecodes::DecodeRegisterOperand(const uint8_t* operand_start, 647 Register Bytecodes::DecodeRegisterOperand(const uint8_t* operand_start,
697 OperandType operand_type, 648 OperandType operand_type,
698 OperandScale operand_scale) { 649 OperandScale operand_scale) {
699 DCHECK(Bytecodes::IsRegisterOperandType(operand_type)); 650 DCHECK(Bytecodes::IsRegisterOperandType(operand_type));
700 int32_t operand = 651 int32_t operand =
701 DecodeSignedOperand(operand_start, operand_type, operand_scale); 652 DecodeSignedOperand(operand_start, operand_type, operand_scale);
702 return Register::FromOperand(operand); 653 return Register::FromOperand(operand);
703 } 654 }
704 655
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 } else { 939 } else {
989 std::ostringstream s; 940 std::ostringstream s;
990 s << "r" << index(); 941 s << "r" << index();
991 return s.str(); 942 return s.str();
992 } 943 }
993 } 944 }
994 945
995 } // namespace interpreter 946 } // namespace interpreter
996 } // namespace internal 947 } // namespace internal
997 } // namespace v8 948 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | test/cctest/interpreter/bytecode_expectations/WideRegisters.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698