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

Side by Side Diff: test/unittests/interpreter/bytecodes-unittest.cc

Issue 1633153002: [interpreter] Reduce move operations for wide register support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove RegisterOperandIsMovable from RegisterMover interface Created 4 years, 10 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 <vector> 5 #include <vector>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/interpreter/bytecodes.h" 9 #include "src/interpreter/bytecodes.h"
10 #include "test/unittests/test-utils.h" 10 #include "test/unittests/test-utils.h"
(...skipping 25 matching lines...) Expand all
36 uint8_t operand = static_cast<uint8_t>(i); 36 uint8_t operand = static_cast<uint8_t>(i);
37 Register reg = Register::FromOperand(operand); 37 Register reg = Register::FromOperand(operand);
38 if (i > 0 && i < -kMinInt8) { 38 if (i > 0 && i < -kMinInt8) {
39 CHECK(reg.is_parameter()); 39 CHECK(reg.is_parameter());
40 } else { 40 } else {
41 CHECK(!reg.is_parameter()); 41 CHECK(!reg.is_parameter());
42 } 42 }
43 } 43 }
44 } 44 }
45 45
46
47 TEST(OperandConversion, Parameters) { 46 TEST(OperandConversion, Parameters) {
48 int parameter_counts[] = {7, 13, 99}; 47 int parameter_counts[] = {7, 13, 99};
49 48
50 size_t count = sizeof(parameter_counts) / sizeof(parameter_counts[0]); 49 size_t count = sizeof(parameter_counts) / sizeof(parameter_counts[0]);
51 for (size_t p = 0; p < count; p++) { 50 for (size_t p = 0; p < count; p++) {
52 int parameter_count = parameter_counts[p]; 51 int parameter_count = parameter_counts[p];
53 for (int i = 0; i < parameter_count; i++) { 52 for (int i = 0; i < parameter_count; i++) {
54 Register r = Register::FromParameterIndex(i, parameter_count); 53 Register r = Register::FromParameterIndex(i, parameter_count);
55 uint8_t operand_value = r.ToOperand(); 54 uint8_t operand_value = r.ToOperand();
56 Register s = Register::FromOperand(operand_value); 55 Register s = Register::FromOperand(operand_value);
57 CHECK_EQ(i, s.ToParameterIndex(parameter_count)); 56 CHECK_EQ(i, s.ToParameterIndex(parameter_count));
58 } 57 }
59 } 58 }
60 } 59 }
61 60
62
63 TEST(OperandConversion, RegistersParametersNoOverlap) { 61 TEST(OperandConversion, RegistersParametersNoOverlap) {
64 int register_count = Register::MaxRegisterIndex() + 1; 62 int register_count = Register::MaxRegisterIndex() + 1;
65 int parameter_count = Register::MaxParameterIndex() + 1; 63 int parameter_count = Register::MaxParameterIndex() + 1;
66 int32_t register_space_size = base::bits::RoundUpToPowerOfTwo32( 64 int32_t register_space_size = base::bits::RoundUpToPowerOfTwo32(
67 static_cast<uint32_t>(register_count + parameter_count)); 65 static_cast<uint32_t>(register_count + parameter_count));
68 uint32_t range = static_cast<uint32_t>(register_space_size); 66 uint32_t range = static_cast<uint32_t>(register_space_size);
69 std::vector<uint8_t> operand_count(range); 67 std::vector<uint8_t> operand_count(range);
70 68
71 for (int i = 0; i < register_count; i += 1) { 69 for (int i = 0; i < register_count; i += 1) {
72 Register r = Register(i); 70 Register r = Register(i);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kCallRuntimeForPair), 109 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kCallRuntimeForPair),
112 10); 110 10);
113 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kStar), 1); 111 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kStar), 1);
114 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kMov), 3); 112 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kMov), 3);
115 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kTestIn), 1); 113 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kTestIn), 1);
116 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kForInPrepare), 1); 114 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kForInPrepare), 1);
117 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kForInDone), 3); 115 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kForInDone), 3);
118 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kForInNext), 7); 116 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kForInNext), 7);
119 } 117 }
120 118
119 TEST(Bytecodes, RegisterOperands) {
120 CHECK(Bytecodes::IsRegisterOperandType(OperandType::kReg8));
121 CHECK(Bytecodes::IsRegisterInputOperandType(OperandType::kReg8));
122 CHECK(!Bytecodes::IsRegisterOutputOperandType(OperandType::kReg8));
123 CHECK(!Bytecodes::IsRegisterInputOperandType(OperandType::kRegOut8));
124 CHECK(Bytecodes::IsRegisterOutputOperandType(OperandType::kRegOut8));
125
126 #define IS_REGISTER_OPERAND_TYPE(Name, _) \
127 CHECK(Bytecodes::IsRegisterOperandType(OperandType::k##Name));
128 REGISTER_OPERAND_TYPE_LIST(IS_REGISTER_OPERAND_TYPE)
129 #undef IS_REGISTER_OPERAND_TYPE
130
131 #define IS_NOT_REGISTER_OPERAND_TYPE(Name, _) \
132 CHECK(!Bytecodes::IsRegisterOperandType(OperandType::k##Name));
133 NON_REGISTER_OPERAND_TYPE_LIST(IS_NOT_REGISTER_OPERAND_TYPE)
134 #undef IS_NOT_REGISTER_OPERAND_TYPE
135
136 #define IS_REGISTER_INPUT_OPERAND_TYPE(Name, _) \
137 CHECK(Bytecodes::IsRegisterInputOperandType(OperandType::k##Name));
138 REGISTER_INPUT_OPERAND_TYPE_LIST(IS_REGISTER_INPUT_OPERAND_TYPE)
139 #undef IS_REGISTER_INPUT_OPERAND_TYPE
140
141 #define IS_NOT_REGISTER_INPUT_OPERAND_TYPE(Name, _) \
142 CHECK(!Bytecodes::IsRegisterInputOperandType(OperandType::k##Name));
143 NON_REGISTER_OPERAND_TYPE_LIST(IS_NOT_REGISTER_INPUT_OPERAND_TYPE);
144 REGISTER_OUTPUT_OPERAND_TYPE_LIST(IS_NOT_REGISTER_INPUT_OPERAND_TYPE)
145 #undef IS_NOT_REGISTER_INPUT_OPERAND_TYPE
146
147 #define IS_REGISTER_OUTPUT_OPERAND_TYPE(Name, _) \
148 CHECK(Bytecodes::IsRegisterOutputOperandType(OperandType::k##Name));
149 REGISTER_OUTPUT_OPERAND_TYPE_LIST(IS_REGISTER_OUTPUT_OPERAND_TYPE)
150 #undef IS_REGISTER_OUTPUT_OPERAND_TYPE
151
152 #define IS_NOT_REGISTER_OUTPUT_OPERAND_TYPE(Name, _) \
153 CHECK(!Bytecodes::IsRegisterOutputOperandType(OperandType::k##Name));
154 NON_REGISTER_OPERAND_TYPE_LIST(IS_NOT_REGISTER_OUTPUT_OPERAND_TYPE)
155 REGISTER_INPUT_OPERAND_TYPE_LIST(IS_NOT_REGISTER_OUTPUT_OPERAND_TYPE)
156 #undef IS_NOT_REGISTER_INPUT_OPERAND_TYPE
157 }
158
121 } // namespace interpreter 159 } // namespace interpreter
122 } // namespace internal 160 } // namespace internal
123 } // namespace v8 161 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/interpreter-assembler-unittest.cc ('k') | test/unittests/interpreter/register-translator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698