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

Side by Side Diff: src/interpreter/bytecode-array-builder.cc

Issue 2382273002: [Interpreter]: Add kRegList operand type for register list operands. (Closed)
Patch Set: 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 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/bytecode-array-builder.h" 5 #include "src/interpreter/bytecode-array-builder.h"
6 6
7 #include "src/globals.h" 7 #include "src/globals.h"
8 #include "src/interpreter/bytecode-array-writer.h" 8 #include "src/interpreter/bytecode-array-writer.h"
9 #include "src/interpreter/bytecode-dead-code-optimizer.h" 9 #include "src/interpreter/bytecode-dead-code-optimizer.h"
10 #include "src/interpreter/bytecode-label.h" 10 #include "src/interpreter/bytecode-label.h"
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 if (Bytecodes::NumberOfOperands(bytecode) != operand_count) { 858 if (Bytecodes::NumberOfOperands(bytecode) != operand_count) {
859 return false; 859 return false;
860 } 860 }
861 861
862 uint32_t operands[] = {operand0, operand1, operand2, operand3}; 862 uint32_t operands[] = {operand0, operand1, operand2, operand3};
863 const OperandType* operand_types = Bytecodes::GetOperandTypes(bytecode); 863 const OperandType* operand_types = Bytecodes::GetOperandTypes(bytecode);
864 for (int i = 0; i < operand_count; ++i) { 864 for (int i = 0; i < operand_count; ++i) {
865 switch (operand_types[i]) { 865 switch (operand_types[i]) {
866 case OperandType::kNone: 866 case OperandType::kNone:
867 return false; 867 return false;
868 case OperandType::kRegCount: {
869 CHECK_NE(i, 0);
870 CHECK(operand_types[i - 1] == OperandType::kMaybeReg ||
871 operand_types[i - 1] == OperandType::kReg);
872 if (i > 0 && operands[i] > 0) {
873 Register start = Register::FromOperand(operands[i - 1]);
874 Register end(start.index() + static_cast<int>(operands[i]) - 1);
875 if (!RegisterIsValid(start) || !RegisterIsValid(end) || start > end) {
876 return false;
877 }
878 }
879 break;
880 }
881 case OperandType::kFlag8: 868 case OperandType::kFlag8:
882 case OperandType::kIntrinsicId: 869 case OperandType::kIntrinsicId:
883 if (Bytecodes::SizeForUnsignedOperand(operands[i]) > 870 if (Bytecodes::SizeForUnsignedOperand(operands[i]) >
884 OperandSize::kByte) { 871 OperandSize::kByte) {
885 return false; 872 return false;
886 } 873 }
887 break; 874 break;
888 case OperandType::kRuntimeId: 875 case OperandType::kRuntimeId:
889 if (Bytecodes::SizeForUnsignedOperand(operands[i]) > 876 if (Bytecodes::SizeForUnsignedOperand(operands[i]) >
890 OperandSize::kShort) { 877 OperandSize::kShort) {
891 return false; 878 return false;
892 } 879 }
893 break; 880 break;
894 case OperandType::kIdx: 881 case OperandType::kIdx:
895 // TODO(leszeks): Possibly split this up into constant pool indices and 882 // TODO(leszeks): Possibly split this up into constant pool indices and
896 // other indices, for checking. 883 // other indices, for checking.
897 break; 884 break;
898 case OperandType::kUImm: 885 case OperandType::kUImm:
899 case OperandType::kImm: 886 case OperandType::kImm:
900 break; 887 break;
901 case OperandType::kMaybeReg: 888 case OperandType::kRegList: {
902 if (Register::FromOperand(operands[i]) == Register(0)) { 889 CHECK_LT(i, operand_count - 1);
903 break; 890 CHECK(operand_types[i + 1] == OperandType::kRegCount);
891 int reg_count = static_cast<int>(operands[i + 1]);
892 if (reg_count == 0) {
893 return Register::FromOperand(operands[i]) == Register(0);
894 } else {
895 Register start = Register::FromOperand(operands[i]);
896 Register end(start.index() + reg_count - 1);
897 if (!RegisterIsValid(start) || !RegisterIsValid(end) || start > end) {
898 return false;
899 }
904 } 900 }
905 // Fall-through to kReg case. 901 i++; // Skip past kRegCount operand.
902 break;
903 }
906 case OperandType::kReg: 904 case OperandType::kReg:
907 case OperandType::kRegOut: { 905 case OperandType::kRegOut: {
908 Register reg = Register::FromOperand(operands[i]); 906 Register reg = Register::FromOperand(operands[i]);
909 if (!RegisterIsValid(reg)) { 907 if (!RegisterIsValid(reg)) {
910 return false; 908 return false;
911 } 909 }
912 break; 910 break;
913 } 911 }
914 case OperandType::kRegOutPair: 912 case OperandType::kRegOutPair:
915 case OperandType::kRegPair: { 913 case OperandType::kRegPair: {
916 Register reg0 = Register::FromOperand(operands[i]); 914 Register reg0 = Register::FromOperand(operands[i]);
917 Register reg1 = Register(reg0.index() + 1); 915 Register reg1 = Register(reg0.index() + 1);
918 if (!RegisterIsValid(reg0) || !RegisterIsValid(reg1)) { 916 if (!RegisterIsValid(reg0) || !RegisterIsValid(reg1)) {
919 return false; 917 return false;
920 } 918 }
921 break; 919 break;
922 } 920 }
923 case OperandType::kRegOutTriple: { 921 case OperandType::kRegOutTriple: {
924 Register reg0 = Register::FromOperand(operands[i]); 922 Register reg0 = Register::FromOperand(operands[i]);
925 Register reg1 = Register(reg0.index() + 1); 923 Register reg1 = Register(reg0.index() + 1);
926 Register reg2 = Register(reg0.index() + 2); 924 Register reg2 = Register(reg0.index() + 2);
927 if (!RegisterIsValid(reg0) || !RegisterIsValid(reg1) || 925 if (!RegisterIsValid(reg0) || !RegisterIsValid(reg1) ||
928 !RegisterIsValid(reg2)) { 926 !RegisterIsValid(reg2)) {
929 return false; 927 return false;
930 } 928 }
931 break; 929 break;
932 } 930 }
931 case OperandType::kRegCount:
932 UNREACHABLE(); // Dealt with in kRegList above.
933 } 933 }
934 } 934 }
935 935
936 return true; 936 return true;
937 } 937 }
938 938
939 } // namespace interpreter 939 } // namespace interpreter
940 } // namespace internal 940 } // namespace internal
941 } // namespace v8 941 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/interpreter/bytecode-array-iterator.cc » ('j') | test/unittests/interpreter/bytecode-decoder-unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698