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

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

Issue 1323463005: [Interpreter] Add support for JS calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add VisitCall to bytecode-generator 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/compiler/graph.h" 8 #include "src/compiler/graph.h"
8 #include "src/compiler/node.h" 9 #include "src/compiler/node.h"
9 #include "src/interface-descriptors.h" 10 #include "src/interface-descriptors.h"
10 #include "src/isolate.h" 11 #include "src/isolate.h"
11 #include "test/unittests/compiler/compiler-test-utils.h" 12 #include "test/unittests/compiler/compiler-test-utils.h"
12 #include "test/unittests/compiler/node-test-utils.h" 13 #include "test/unittests/compiler/node-test-utils.h"
13 14
14 using ::testing::_; 15 using ::testing::_;
15 16
16 namespace v8 { 17 namespace v8 {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 179 }
179 } 180 }
180 181
181 182
182 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { 183 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) {
183 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 184 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
184 InterpreterAssemblerForTest m(this, bytecode); 185 InterpreterAssemblerForTest m(this, bytecode);
185 int number_of_operands = interpreter::Bytecodes::NumberOfOperands(bytecode); 186 int number_of_operands = interpreter::Bytecodes::NumberOfOperands(bytecode);
186 for (int i = 0; i < number_of_operands; i++) { 187 for (int i = 0; i < number_of_operands; i++) {
187 switch (interpreter::Bytecodes::GetOperandType(bytecode, i)) { 188 switch (interpreter::Bytecodes::GetOperandType(bytecode, i)) {
189 case interpreter::OperandType::kCount:
190 EXPECT_THAT(m.BytecodeOperandCount(i), m.IsBytecodeOperand(i));
191 break;
188 case interpreter::OperandType::kIdx: 192 case interpreter::OperandType::kIdx:
189 EXPECT_THAT(m.BytecodeOperandIdx(i), m.IsBytecodeOperand(i)); 193 EXPECT_THAT(m.BytecodeOperandIdx(i), m.IsBytecodeOperand(i));
190 break; 194 break;
191 case interpreter::OperandType::kImm8: 195 case interpreter::OperandType::kImm8:
192 EXPECT_THAT(m.BytecodeOperandImm8(i), 196 EXPECT_THAT(m.BytecodeOperandImm8(i),
193 m.IsBytecodeOperandSignExtended(i)); 197 m.IsBytecodeOperandSignExtended(i));
194 break; 198 break;
195 case interpreter::OperandType::kReg: 199 case interpreter::OperandType::kReg:
196 EXPECT_THAT(m.BytecodeOperandReg(i), 200 EXPECT_THAT(m.BytecodeOperandReg(i),
197 m.IsBytecodeOperandSignExtended(i)); 201 m.IsBytecodeOperandSignExtended(i));
(...skipping 30 matching lines...) Expand all
228 EXPECT_EQ(1, end->InputCount()); 232 EXPECT_EQ(1, end->InputCount());
229 Node* tail_call_node = end->InputAt(0); 233 Node* tail_call_node = end->InputAt(0);
230 234
231 EXPECT_THAT(tail_call_node, 235 EXPECT_THAT(tail_call_node,
232 IsTailCall(m.call_descriptor(), _, accumulator_value_2, _, _, _, 236 IsTailCall(m.call_descriptor(), _, accumulator_value_2, _, _, _,
233 _, graph->start(), graph->start())); 237 _, graph->start(), graph->start()));
234 } 238 }
235 } 239 }
236 240
237 241
242 TARGET_TEST_F(InterpreterAssemblerTest, RegisterLocation) {
243 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
244 InterpreterAssemblerForTest m(this, bytecode);
245 Node* reg_index_node = m.Int32Constant(44);
246 Node* reg_location_node = m.RegisterLocation(reg_index_node);
247 EXPECT_THAT(
248 reg_location_node,
249 m.IsIntPtrAdd(
250 IsParameter(Linkage::kInterpreterRegisterFileParameter),
251 IsWordShl(reg_index_node, IsInt32Constant(kPointerSizeLog2))));
252 }
253 }
254
255
238 TARGET_TEST_F(InterpreterAssemblerTest, LoadRegister) { 256 TARGET_TEST_F(InterpreterAssemblerTest, LoadRegister) {
239 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 257 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
240 InterpreterAssemblerForTest m(this, bytecode); 258 InterpreterAssemblerForTest m(this, bytecode);
241 Node* reg_index_node = m.Int32Constant(44); 259 Node* reg_index_node = m.Int32Constant(44);
242 Node* load_reg_node = m.LoadRegister(reg_index_node); 260 Node* load_reg_node = m.LoadRegister(reg_index_node);
243 EXPECT_THAT( 261 EXPECT_THAT(
244 load_reg_node, 262 load_reg_node,
245 m.IsLoad(kMachAnyTagged, 263 m.IsLoad(kMachAnyTagged,
246 IsParameter(Linkage::kInterpreterRegisterFileParameter), 264 IsParameter(Linkage::kInterpreterRegisterFileParameter),
247 IsWordShl(reg_index_node, IsInt32Constant(kPointerSizeLog2)))); 265 IsWordShl(reg_index_node, IsInt32Constant(kPointerSizeLog2))));
(...skipping 22 matching lines...) Expand all
270 InterpreterAssemblerForTest m(this, bytecode); 288 InterpreterAssemblerForTest m(this, bytecode);
271 Node* value = m.Int32Constant(44); 289 Node* value = m.Int32Constant(44);
272 EXPECT_THAT(m.SmiTag(value), 290 EXPECT_THAT(m.SmiTag(value),
273 IsWordShl(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize))); 291 IsWordShl(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize)));
274 EXPECT_THAT(m.SmiUntag(value), 292 EXPECT_THAT(m.SmiUntag(value),
275 IsWordSar(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize))); 293 IsWordSar(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize)));
276 } 294 }
277 } 295 }
278 296
279 297
298 TARGET_TEST_F(InterpreterAssemblerTest, IntPtrAdd) {
299 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
300 InterpreterAssemblerForTest m(this, bytecode);
301 Node* a = m.Int32Constant(0);
302 Node* b = m.Int32Constant(1);
303 Node* add = m.IntPtrAdd(a, b);
304 EXPECT_THAT(add, IsIntPtrAdd(a, b));
305 }
306 }
307
308
309 TARGET_TEST_F(InterpreterAssemblerTest, IntPtrSub) {
310 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
311 InterpreterAssemblerForTest m(this, bytecode);
312 Node* a = m.Int32Constant(0);
313 Node* b = m.Int32Constant(1);
314 Node* add = m.IntPtrSub(a, b);
315 EXPECT_THAT(add, IsIntPtrSub(a, b));
316 }
317 }
318
319
320 TARGET_TEST_F(InterpreterAssemblerTest, WordShl) {
321 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
322 InterpreterAssemblerForTest m(this, bytecode);
323 Node* a = m.Int32Constant(0);
324 Node* add = m.WordShl(a, 10);
325 EXPECT_THAT(add, IsWordShl(a, IsInt32Constant(10)));
326 }
327 }
328
329
280 TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { 330 TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) {
281 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 331 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
282 InterpreterAssemblerForTest m(this, bytecode); 332 InterpreterAssemblerForTest m(this, bytecode);
283 Node* index = m.Int32Constant(2); 333 Node* index = m.Int32Constant(2);
284 Node* load_constant = m.LoadConstantPoolEntry(index); 334 Node* load_constant = m.LoadConstantPoolEntry(index);
285 Matcher<Node*> constant_pool_matcher = m.IsLoad( 335 Matcher<Node*> constant_pool_matcher = m.IsLoad(
286 kMachAnyTagged, 336 kMachAnyTagged,
287 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), 337 IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
288 IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - kHeapObjectTag)); 338 IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - kHeapObjectTag));
289 EXPECT_THAT( 339 EXPECT_THAT(
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 Node* arg3 = m.Int32Constant(4); 419 Node* arg3 = m.Int32Constant(4);
370 Node* arg4 = m.Int32Constant(5); 420 Node* arg4 = m.Int32Constant(5);
371 Node* call_ic = m.CallIC(descriptor, target, arg1, arg2, arg3, arg4); 421 Node* call_ic = m.CallIC(descriptor, target, arg1, arg2, arg3, arg4);
372 EXPECT_THAT(call_ic, 422 EXPECT_THAT(call_ic,
373 m.IsCall(_, target, arg1, arg2, arg3, arg4, 423 m.IsCall(_, target, arg1, arg2, arg3, arg4,
374 IsParameter(Linkage::kInterpreterContextParameter))); 424 IsParameter(Linkage::kInterpreterContextParameter)));
375 } 425 }
376 } 426 }
377 427
378 428
429 TARGET_TEST_F(InterpreterAssemblerTest, CallJS) {
430 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
431 InterpreterAssemblerForTest m(this, bytecode);
432 Callable builtin = CodeFactory::PushArgsAndCall(isolate());
433 Node* function = m.Int32Constant(0);
434 Node* first_arg = m.Int32Constant(1);
435 Node* arg_count = m.Int32Constant(2);
436 Node* call_js = m.CallJS(function, first_arg, arg_count);
437 EXPECT_THAT(
438 call_js,
439 m.IsCall(_, IsHeapConstant(builtin.code()), arg_count, first_arg,
440 function, IsParameter(Linkage::kInterpreterContextParameter)));
441 }
442 }
443
444
379 TARGET_TEST_F(InterpreterAssemblerTest, LoadTypeFeedbackVector) { 445 TARGET_TEST_F(InterpreterAssemblerTest, LoadTypeFeedbackVector) {
380 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 446 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
381 InterpreterAssemblerForTest m(this, bytecode); 447 InterpreterAssemblerForTest m(this, bytecode);
382 Node* feedback_vector = m.LoadTypeFeedbackVector(); 448 Node* feedback_vector = m.LoadTypeFeedbackVector();
383 449
384 Matcher<Node*> load_function_matcher = m.IsLoad( 450 Matcher<Node*> load_function_matcher = m.IsLoad(
385 kMachAnyTagged, IsParameter(Linkage::kInterpreterRegisterFileParameter), 451 kMachAnyTagged, IsParameter(Linkage::kInterpreterRegisterFileParameter),
386 IsIntPtrConstant( 452 IsIntPtrConstant(
387 InterpreterFrameConstants::kFunctionFromRegisterPointer)); 453 InterpreterFrameConstants::kFunctionFromRegisterPointer));
388 Matcher<Node*> load_shared_function_info_matcher = 454 Matcher<Node*> load_shared_function_info_matcher =
389 m.IsLoad(kMachAnyTagged, load_function_matcher, 455 m.IsLoad(kMachAnyTagged, load_function_matcher,
390 IsIntPtrConstant(JSFunction::kSharedFunctionInfoOffset - 456 IsIntPtrConstant(JSFunction::kSharedFunctionInfoOffset -
391 kHeapObjectTag)); 457 kHeapObjectTag));
392 458
393 EXPECT_THAT( 459 EXPECT_THAT(
394 feedback_vector, 460 feedback_vector,
395 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, 461 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher,
396 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - 462 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset -
397 kHeapObjectTag))); 463 kHeapObjectTag)));
398 } 464 }
399 } 465 }
400 466
401 } // namespace compiler 467 } // namespace compiler
402 } // namespace internal 468 } // namespace internal
403 } // namespace v8 469 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698