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

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

Issue 1343363002: [Interpreter] Basic flow control. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Switch test-bytecode-generator/IfConditions to use new style bytecode array check. Created 5 years, 3 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 IsParameter(Linkage::kInterpreterRegisterFileParameter), 145 IsParameter(Linkage::kInterpreterRegisterFileParameter),
146 next_bytecode_offset_matcher, 146 next_bytecode_offset_matcher,
147 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), 147 IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
148 IsParameter(Linkage::kInterpreterDispatchTableParameter), 148 IsParameter(Linkage::kInterpreterDispatchTableParameter),
149 IsParameter(Linkage::kInterpreterContextParameter), 149 IsParameter(Linkage::kInterpreterContextParameter),
150 graph->start(), graph->start())); 150 graph->start(), graph->start()));
151 } 151 }
152 } 152 }
153 153
154 154
155 TARGET_TEST_F(InterpreterAssemblerTest, Jump) {
156 int jump_offsets[] = {-9710, -77, 0, +3, +97109};
157 TRACED_FOREACH(int, jump_offset, jump_offsets) {
158 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
159 InterpreterAssemblerForTest m(this, bytecode);
160 m.Jump(m.Int32Constant(jump_offset));
161 Graph* graph = m.GetCompletedGraph();
162 Node* end = graph->end();
163 EXPECT_EQ(1, end->InputCount());
164 Node* tail_call_node = end->InputAt(0);
165
166 Matcher<Node*> next_bytecode_offset_matcher =
167 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter),
168 IsInt32Constant(jump_offset));
169 Matcher<Node*> target_bytecode_matcher = m.IsLoad(
170 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
171 next_bytecode_offset_matcher);
172 Matcher<Node*> code_target_matcher = m.IsLoad(
173 kMachPtr, IsParameter(Linkage::kInterpreterDispatchTableParameter),
174 IsWord32Shl(target_bytecode_matcher,
175 IsInt32Constant(kPointerSizeLog2)));
176
177 EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind());
178 EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots);
179 EXPECT_THAT(
180 tail_call_node,
181 IsTailCall(m.call_descriptor(), code_target_matcher,
182 IsParameter(Linkage::kInterpreterAccumulatorParameter),
183 IsParameter(Linkage::kInterpreterRegisterFileParameter),
184 next_bytecode_offset_matcher,
185 IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
186 IsParameter(Linkage::kInterpreterDispatchTableParameter),
187 IsParameter(Linkage::kInterpreterContextParameter),
188 graph->start(), graph->start()));
189 }
190 }
191 }
192
193
194 TARGET_TEST_F(InterpreterAssemblerTest, JumpIfWordEqual) {
195 static const int kJumpIfTrueOffset = 73;
196
197 MachineOperatorBuilder machine(zone());
198
199 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
200 InterpreterAssemblerForTest m(this, bytecode);
201 Node* lhs = m.IntPtrConstant(0);
202 Node* rhs = m.IntPtrConstant(1);
203 m.JumpIfWordEqual(lhs, rhs, m.Int32Constant(kJumpIfTrueOffset));
204 Graph* graph = m.GetCompletedGraph();
205 Node* end = graph->end();
206 EXPECT_EQ(2, end->InputCount());
207
208 int jump_offsets[] = {kJumpIfTrueOffset,
209 interpreter::Bytecodes::Size(bytecode)};
210 for (int i = 0; i < static_cast<int>(arraysize(jump_offsets)); i++) {
211 Matcher<Node*> next_bytecode_offset_matcher =
212 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter),
213 IsInt32Constant(jump_offsets[i]));
214 Matcher<Node*> target_bytecode_matcher = m.IsLoad(
215 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
216 next_bytecode_offset_matcher);
217 Matcher<Node*> code_target_matcher = m.IsLoad(
218 kMachPtr, IsParameter(Linkage::kInterpreterDispatchTableParameter),
219 IsWord32Shl(target_bytecode_matcher,
220 IsInt32Constant(kPointerSizeLog2)));
221 EXPECT_THAT(
222 end->InputAt(i),
223 IsTailCall(m.call_descriptor(), code_target_matcher,
224 IsParameter(Linkage::kInterpreterAccumulatorParameter),
225 IsParameter(Linkage::kInterpreterRegisterFileParameter),
226 next_bytecode_offset_matcher,
227 IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
228 IsParameter(Linkage::kInterpreterDispatchTableParameter),
229 IsParameter(Linkage::kInterpreterContextParameter),
230 graph->start(), graph->start()));
231 }
232
233 // TODO(oth): test control flow paths.
234 }
235 }
236
237
155 TARGET_TEST_F(InterpreterAssemblerTest, Return) { 238 TARGET_TEST_F(InterpreterAssemblerTest, Return) {
156 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 239 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
157 InterpreterAssemblerForTest m(this, bytecode); 240 InterpreterAssemblerForTest m(this, bytecode);
158 m.Return(); 241 m.Return();
159 Graph* graph = m.GetCompletedGraph(); 242 Graph* graph = m.GetCompletedGraph();
160 243
161 Node* end = graph->end(); 244 Node* end = graph->end();
162 EXPECT_EQ(1, end->InputCount()); 245 EXPECT_EQ(1, end->InputCount());
163 Node* tail_call_node = end->InputAt(0); 246 Node* tail_call_node = end->InputAt(0);
164 247
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 feedback_vector, 525 feedback_vector,
443 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, 526 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher,
444 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - 527 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset -
445 kHeapObjectTag))); 528 kHeapObjectTag)));
446 } 529 }
447 } 530 }
448 531
449 } // namespace compiler 532 } // namespace compiler
450 } // namespace internal 533 } // namespace internal
451 } // namespace v8 534 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/interpreter/test-interpreter.cc ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698