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

Side by Side Diff: test/unittests/compiler/instruction-selector-unittest.cc

Issue 1191243003: [turbofan] Factor out the function specific part from the frame state operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Tweaks Created 5 years, 6 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/instruction-selector-unittest.h" 5 #include "test/unittests/compiler/instruction-selector-unittest.h"
6 6
7 #include "src/compiler/graph.h" 7 #include "src/compiler/graph.h"
8 #include "src/compiler/schedule.h" 8 #include "src/compiler/schedule.h"
9 #include "src/flags.h" 9 #include "src/flags.h"
10 #include "test/unittests/compiler/compiler-test-utils.h" 10 #include "test/unittests/compiler/compiler-test-utils.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 142
143 bool InstructionSelectorTest::Stream::IsUsedAtStart( 143 bool InstructionSelectorTest::Stream::IsUsedAtStart(
144 const InstructionOperand* operand) const { 144 const InstructionOperand* operand) const {
145 if (!operand->IsUnallocated()) return false; 145 if (!operand->IsUnallocated()) return false;
146 const UnallocatedOperand* unallocated = UnallocatedOperand::cast(operand); 146 const UnallocatedOperand* unallocated = UnallocatedOperand::cast(operand);
147 return unallocated->IsUsedAtStart(); 147 return unallocated->IsUsedAtStart();
148 } 148 }
149 149
150 150
151 const FrameStateFunctionInfo*
152 InstructionSelectorTest::StreamBuilder::GetFrameStateFunctionInfo(
153 int parameter_count, int local_count) {
154 return common()->CreateFrameStateFunctionInfo(
155 FrameStateType::kJavaScriptFunction, parameter_count, local_count,
156 Handle<SharedFunctionInfo>());
157 }
158
159
151 // ----------------------------------------------------------------------------- 160 // -----------------------------------------------------------------------------
152 // Return. 161 // Return.
153 162
154 163
155 TARGET_TEST_F(InstructionSelectorTest, ReturnFloat32Constant) { 164 TARGET_TEST_F(InstructionSelectorTest, ReturnFloat32Constant) {
156 const float kValue = 4.2f; 165 const float kValue = 4.2f;
157 StreamBuilder m(this, kMachFloat32); 166 StreamBuilder m(this, kMachFloat32);
158 m.Return(m.Float32Constant(kValue)); 167 m.Return(m.Float32Constant(kValue));
159 Stream s = m.Build(kAllInstructions); 168 Stream s = m.Build(kAllInstructions);
160 ASSERT_EQ(3U, s.size()); 169 ASSERT_EQ(3U, s.size());
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 364
356 ZoneVector<MachineType> int32_type(1, kMachInt32, zone()); 365 ZoneVector<MachineType> int32_type(1, kMachInt32, zone());
357 ZoneVector<MachineType> empty_types(zone()); 366 ZoneVector<MachineType> empty_types(zone());
358 367
359 Node* parameters = 368 Node* parameters =
360 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(1)); 369 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(1));
361 Node* locals = m.NewNode(m.common()->TypedStateValues(&empty_types)); 370 Node* locals = m.NewNode(m.common()->TypedStateValues(&empty_types));
362 Node* stack = m.NewNode(m.common()->TypedStateValues(&empty_types)); 371 Node* stack = m.NewNode(m.common()->TypedStateValues(&empty_types));
363 Node* context_dummy = m.Int32Constant(0); 372 Node* context_dummy = m.Int32Constant(0);
364 373
365 Node* state_node = 374 Node* state_node = m.NewNode(
366 m.NewNode(m.common()->FrameState(JS_FRAME, bailout_id, 375 m.common()->FrameState(bailout_id, OutputFrameStateCombine::Push(),
367 OutputFrameStateCombine::Push()), 376 m.GetFrameStateFunctionInfo(1, 0)),
368 parameters, locals, stack, context_dummy, function_node, 377 parameters, locals, stack, context_dummy, function_node,
369 m.UndefinedConstant()); 378 m.UndefinedConstant());
370 Node* call = m.CallJS0(function_node, receiver, context, state_node); 379 Node* call = m.CallJS0(function_node, receiver, context, state_node);
371 m.Return(call); 380 m.Return(call);
372 381
373 Stream s = m.Build(kAllExceptNopInstructions); 382 Stream s = m.Build(kAllExceptNopInstructions);
374 383
375 // Skip until kArchCallJSFunction. 384 // Skip until kArchCallJSFunction.
376 size_t index = 0; 385 size_t index = 0;
377 for (; index < s.size() && s[index]->arch_opcode() != kArchCallJSFunction; 386 for (; index < s.size() && s[index]->arch_opcode() != kArchCallJSFunction;
378 index++) { 387 index++) {
379 } 388 }
(...skipping 24 matching lines...) Expand all
404 413
405 // Build frame state for the state before the call. 414 // Build frame state for the state before the call.
406 Node* parameters = 415 Node* parameters =
407 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(43)); 416 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(43));
408 Node* locals = m.NewNode(m.common()->TypedStateValues(&float64_type), 417 Node* locals = m.NewNode(m.common()->TypedStateValues(&float64_type),
409 m.Float64Constant(0.5)); 418 m.Float64Constant(0.5));
410 Node* stack = m.NewNode(m.common()->TypedStateValues(&tagged_type), 419 Node* stack = m.NewNode(m.common()->TypedStateValues(&tagged_type),
411 m.UndefinedConstant()); 420 m.UndefinedConstant());
412 421
413 Node* context_sentinel = m.Int32Constant(0); 422 Node* context_sentinel = m.Int32Constant(0);
414 Node* frame_state_before = 423 Node* frame_state_before = m.NewNode(
415 m.NewNode(m.common()->FrameState(JS_FRAME, bailout_id_before, 424 m.common()->FrameState(bailout_id_before, OutputFrameStateCombine::Push(),
416 OutputFrameStateCombine::Push()), 425 m.GetFrameStateFunctionInfo(1, 1)),
417 parameters, locals, stack, context_sentinel, function_node, 426 parameters, locals, stack, context_sentinel, function_node,
418 m.UndefinedConstant()); 427 m.UndefinedConstant());
419 428
420 // Build the call. 429 // Build the call.
421 Node* call = m.CallFunctionStub0(function_node, receiver, context, 430 Node* call = m.CallFunctionStub0(function_node, receiver, context,
422 frame_state_before, CALL_AS_METHOD); 431 frame_state_before, CALL_AS_METHOD);
423 432
424 m.Return(call); 433 m.Return(call);
425 434
426 Stream s = m.Build(kAllExceptNopInstructions); 435 Stream s = m.Build(kAllExceptNopInstructions);
427 436
428 // Skip until kArchCallJSFunction. 437 // Skip until kArchCallJSFunction.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 ZoneVector<MachineType> float64_type(1, kMachFloat64, zone()); 508 ZoneVector<MachineType> float64_type(1, kMachFloat64, zone());
500 509
501 // Build frame state for the state before the call. 510 // Build frame state for the state before the call.
502 Node* parameters = 511 Node* parameters =
503 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(63)); 512 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(63));
504 Node* locals = 513 Node* locals =
505 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(64)); 514 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(64));
506 Node* stack = 515 Node* stack =
507 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(65)); 516 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(65));
508 Node* frame_state_parent = m.NewNode( 517 Node* frame_state_parent = m.NewNode(
509 m.common()->FrameState(JS_FRAME, bailout_id_parent, 518 m.common()->FrameState(bailout_id_parent,
510 OutputFrameStateCombine::Ignore()), 519 OutputFrameStateCombine::Ignore(),
520 m.GetFrameStateFunctionInfo(1, 1)),
511 parameters, locals, stack, context, function_node, m.UndefinedConstant()); 521 parameters, locals, stack, context, function_node, m.UndefinedConstant());
512 522
513 Node* context2 = m.Int32Constant(46); 523 Node* context2 = m.Int32Constant(46);
514 Node* parameters2 = 524 Node* parameters2 =
515 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(43)); 525 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(43));
516 Node* locals2 = m.NewNode(m.common()->TypedStateValues(&float64_type), 526 Node* locals2 = m.NewNode(m.common()->TypedStateValues(&float64_type),
517 m.Float64Constant(0.25)); 527 m.Float64Constant(0.25));
518 Node* stack2 = m.NewNode(m.common()->TypedStateValues(&int32x2_type), 528 Node* stack2 = m.NewNode(m.common()->TypedStateValues(&int32x2_type),
519 m.Int32Constant(44), m.Int32Constant(45)); 529 m.Int32Constant(44), m.Int32Constant(45));
520 Node* frame_state_before = 530 Node* frame_state_before = m.NewNode(
521 m.NewNode(m.common()->FrameState(JS_FRAME, bailout_id_before, 531 m.common()->FrameState(bailout_id_before, OutputFrameStateCombine::Push(),
522 OutputFrameStateCombine::Push()), 532 m.GetFrameStateFunctionInfo(1, 1)),
523 parameters2, locals2, stack2, context2, function_node, 533 parameters2, locals2, stack2, context2, function_node,
524 frame_state_parent); 534 frame_state_parent);
525 535
526 // Build the call. 536 // Build the call.
527 Node* call = m.CallFunctionStub0(function_node, receiver, context2, 537 Node* call = m.CallFunctionStub0(function_node, receiver, context2,
528 frame_state_before, CALL_AS_METHOD); 538 frame_state_before, CALL_AS_METHOD);
529 539
530 m.Return(call); 540 m.Return(call);
531 541
532 Stream s = m.Build(kAllExceptNopInstructions); 542 Stream s = m.Build(kAllExceptNopInstructions);
533 543
534 // Skip until kArchCallJSFunction. 544 // Skip until kArchCallJSFunction.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 EXPECT_EQ(s.ToVreg(context2), s.ToVreg(call_instr->InputAt(14))); 605 EXPECT_EQ(s.ToVreg(context2), s.ToVreg(call_instr->InputAt(14)));
596 // Continuation. 606 // Continuation.
597 607
598 EXPECT_EQ(kArchRet, s[index++]->arch_opcode()); 608 EXPECT_EQ(kArchRet, s[index++]->arch_opcode());
599 EXPECT_EQ(index, s.size()); 609 EXPECT_EQ(index, s.size());
600 } 610 }
601 611
602 } // namespace compiler 612 } // namespace compiler
603 } // namespace internal 613 } // namespace internal
604 } // namespace v8 614 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/instruction-selector-unittest.h ('k') | test/unittests/compiler/liveness-analyzer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698