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

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

Issue 1370893002: [Interpreter] Add support for short (16 bit) operands. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 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 "test/unittests/compiler/interpreter-assembler-unittest.h" 5 #include "test/unittests/compiler/interpreter-assembler-unittest.h"
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/compiler/graph.h" 8 #include "src/compiler/graph.h"
9 #include "src/compiler/node.h" 9 #include "src/compiler/node.h"
10 #include "src/interface-descriptors.h" 10 #include "src/interface-descriptors.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 53
54 54
55 Matcher<Node*> IsWordSar(const Matcher<Node*>& lhs_matcher, 55 Matcher<Node*> IsWordSar(const Matcher<Node*>& lhs_matcher,
56 const Matcher<Node*>& rhs_matcher) { 56 const Matcher<Node*>& rhs_matcher) {
57 return kPointerSize == 8 ? IsWord64Sar(lhs_matcher, rhs_matcher) 57 return kPointerSize == 8 ? IsWord64Sar(lhs_matcher, rhs_matcher)
58 : IsWord32Sar(lhs_matcher, rhs_matcher); 58 : IsWord32Sar(lhs_matcher, rhs_matcher);
59 } 59 }
60 60
61 61
62 Matcher<Node*> IsWordOr(const Matcher<Node*>& lhs_matcher,
63 const Matcher<Node*>& rhs_matcher) {
64 return kPointerSize == 8 ? IsWord64Or(lhs_matcher, rhs_matcher)
65 : IsWord32Or(lhs_matcher, rhs_matcher);
66 }
67
68
62 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsLoad( 69 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsLoad(
63 const Matcher<LoadRepresentation>& rep_matcher, 70 const Matcher<LoadRepresentation>& rep_matcher,
64 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher) { 71 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher) {
65 return ::i::compiler::IsLoad(rep_matcher, base_matcher, index_matcher, 72 return ::i::compiler::IsLoad(rep_matcher, base_matcher, index_matcher,
66 graph()->start(), graph()->start()); 73 graph()->start(), graph()->start());
67 } 74 }
68 75
69 76
70 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsStore( 77 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsStore(
71 const Matcher<StoreRepresentation>& rep_matcher, 78 const Matcher<StoreRepresentation>& rep_matcher,
72 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, 79 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher,
73 const Matcher<Node*>& value_matcher) { 80 const Matcher<Node*>& value_matcher) {
74 return ::i::compiler::IsStore(rep_matcher, base_matcher, index_matcher, 81 return ::i::compiler::IsStore(rep_matcher, base_matcher, index_matcher,
75 value_matcher, graph()->start(), 82 value_matcher, graph()->start(),
76 graph()->start()); 83 graph()->start());
77 } 84 }
78 85
79 86
80 template <class... A> 87 template <class... A>
81 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsCall( 88 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsCall(
82 const Matcher<const CallDescriptor*>& descriptor_matcher, A... args) { 89 const Matcher<const CallDescriptor*>& descriptor_matcher, A... args) {
83 return ::i::compiler::IsCall(descriptor_matcher, args..., graph()->start(), 90 return ::i::compiler::IsCall(descriptor_matcher, args..., graph()->start(),
84 graph()->start()); 91 graph()->start());
85 } 92 }
86 93
87 94
88 Matcher<Node*> 95 Matcher<Node*>
89 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsBytecodeOperand( 96 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsBytecodeOperand(
90 int operand) { 97 int offset) {
91 return IsLoad( 98 return IsLoad(
92 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), 99 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
93 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), 100 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter),
94 IsInt32Constant(1 + operand))); 101 IsInt32Constant(offset)));
95 } 102 }
96 103
97 104
98 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest:: 105 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::
99 IsBytecodeOperandSignExtended(int operand) { 106 IsBytecodeOperandSignExtended(int offset) {
100 Matcher<Node*> load_matcher = IsLoad( 107 Matcher<Node*> load_matcher = IsLoad(
101 kMachInt8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), 108 kMachInt8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
102 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), 109 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter),
103 IsInt32Constant(1 + operand))); 110 IsInt32Constant(offset)));
104 if (kPointerSize == 8) { 111 if (kPointerSize == 8) {
105 load_matcher = IsChangeInt32ToInt64(load_matcher); 112 load_matcher = IsChangeInt32ToInt64(load_matcher);
106 } 113 }
107 return load_matcher; 114 return load_matcher;
108 } 115 }
109 116
110 117
118 Matcher<Node*>
119 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsBytecodeOperandShort(
120 int offset) {
121 if (TargetSupportsUnalignedAccess()) {
122 return IsLoad(
123 kMachUint16, IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
124 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter),
125 IsInt32Constant(offset)));
126 } else {
127 Matcher<Node*> first_byte = IsLoad(
128 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
129 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter),
130 IsInt32Constant(offset)));
131 Matcher<Node*> second_byte = IsLoad(
132 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
133 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter),
134 IsInt32Constant(offset + 1)));
135 #if V8_TARGET_LITTLE_ENDIAN
136 return IsWordOr(IsWordShl(second_byte, IsInt32Constant(kBitsPerByte)),
137 first_byte);
138 #elif V8_TARGET_BIG_ENDIAN
139 return IsWordOr(IsWordShl(first_byte, IsInt32Constant(kBitsPerByte)),
140 second_byte);
141 #else
142 #error "Unknown Architecture"
143 #endif
144 }
145 }
146
147
111 Graph* 148 Graph*
112 InterpreterAssemblerTest::InterpreterAssemblerForTest::GetCompletedGraph() { 149 InterpreterAssemblerTest::InterpreterAssemblerForTest::GetCompletedGraph() {
113 End(); 150 End();
114 return graph(); 151 return graph();
115 } 152 }
116 153
117 154
118 TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) { 155 TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) {
119 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 156 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
120 InterpreterAssemblerForTest m(this, bytecode); 157 InterpreterAssemblerForTest m(this, bytecode);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 graph->start(), graph->start())); 298 graph->start(), graph->start()));
262 } 299 }
263 } 300 }
264 301
265 302
266 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { 303 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) {
267 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 304 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
268 InterpreterAssemblerForTest m(this, bytecode); 305 InterpreterAssemblerForTest m(this, bytecode);
269 int number_of_operands = interpreter::Bytecodes::NumberOfOperands(bytecode); 306 int number_of_operands = interpreter::Bytecodes::NumberOfOperands(bytecode);
270 for (int i = 0; i < number_of_operands; i++) { 307 for (int i = 0; i < number_of_operands; i++) {
308 int offset = interpreter::Bytecodes::GetOperandOffset(bytecode, i);
271 switch (interpreter::Bytecodes::GetOperandType(bytecode, i)) { 309 switch (interpreter::Bytecodes::GetOperandType(bytecode, i)) {
272 case interpreter::OperandType::kCount: 310 case interpreter::OperandType::kCount8:
273 EXPECT_THAT(m.BytecodeOperandCount(i), m.IsBytecodeOperand(i)); 311 EXPECT_THAT(m.BytecodeOperandCount8(i), m.IsBytecodeOperand(offset));
274 break; 312 break;
275 case interpreter::OperandType::kIdx: 313 case interpreter::OperandType::kIdx8:
276 EXPECT_THAT(m.BytecodeOperandIdx(i), m.IsBytecodeOperand(i)); 314 EXPECT_THAT(m.BytecodeOperandIdx8(i), m.IsBytecodeOperand(offset));
277 break; 315 break;
278 case interpreter::OperandType::kImm8: 316 case interpreter::OperandType::kImm8:
279 EXPECT_THAT(m.BytecodeOperandImm8(i), 317 EXPECT_THAT(m.BytecodeOperandImm8(i),
280 m.IsBytecodeOperandSignExtended(i)); 318 m.IsBytecodeOperandSignExtended(offset));
281 break; 319 break;
282 case interpreter::OperandType::kReg: 320 case interpreter::OperandType::kReg8:
283 EXPECT_THAT(m.BytecodeOperandReg(i), 321 EXPECT_THAT(m.BytecodeOperandReg8(i),
284 m.IsBytecodeOperandSignExtended(i)); 322 m.IsBytecodeOperandSignExtended(offset));
323 break;
324 case interpreter::OperandType::kIdx16:
325 EXPECT_THAT(m.BytecodeOperandIdx16(i),
326 m.IsBytecodeOperandShort(offset));
285 break; 327 break;
286 case interpreter::OperandType::kNone: 328 case interpreter::OperandType::kNone:
287 UNREACHABLE(); 329 UNREACHABLE();
288 break; 330 break;
289 } 331 }
290 } 332 }
291 } 333 }
292 } 334 }
293 335
294 336
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 feedback_vector, 567 feedback_vector,
526 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, 568 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher,
527 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - 569 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset -
528 kHeapObjectTag))); 570 kHeapObjectTag)));
529 } 571 }
530 } 572 }
531 573
532 } // namespace compiler 574 } // namespace compiler
533 } // namespace internal 575 } // namespace internal
534 } // namespace v8 576 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/interpreter-assembler-unittest.h ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698