OLD | NEW |
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 "src/base/utils/random-number-generator.h" | 5 #include "src/base/utils/random-number-generator.h" |
6 #include "src/compiler/pipeline.h" | 6 #include "src/compiler/pipeline.h" |
7 #include "test/unittests/compiler/instruction-sequence-unittest.h" | 7 #include "test/unittests/compiler/instruction-sequence-unittest.h" |
8 #include "test/unittests/test-utils.h" | 8 #include "test/unittests/test-utils.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 | 10 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 Instruction* InstructionSequenceTest::EndBlock(BlockCompletion completion) { | 102 Instruction* InstructionSequenceTest::EndBlock(BlockCompletion completion) { |
103 Instruction* result = nullptr; | 103 Instruction* result = nullptr; |
104 if (block_returns_) { | 104 if (block_returns_) { |
105 CHECK(completion.type_ == kBlockEnd || completion.type_ == kFallThrough); | 105 CHECK(completion.type_ == kBlockEnd || completion.type_ == kFallThrough); |
106 completion.type_ = kBlockEnd; | 106 completion.type_ = kBlockEnd; |
107 } | 107 } |
108 switch (completion.type_) { | 108 switch (completion.type_) { |
109 case kBlockEnd: | 109 case kBlockEnd: |
110 break; | 110 break; |
111 case kFallThrough: | 111 case kFallThrough: |
112 result = EmitFallThrough(); | 112 result = EmitJump(); |
113 break; | 113 break; |
114 case kJump: | 114 case kJump: |
115 CHECK(!block_returns_); | 115 CHECK(!block_returns_); |
116 result = EmitJump(); | 116 result = EmitJump(); |
117 break; | 117 break; |
118 case kBranch: | 118 case kBranch: |
119 CHECK(!block_returns_); | 119 CHECK(!block_returns_); |
120 result = EmitBranch(completion.op_); | 120 result = EmitBranch(completion.op_); |
121 break; | 121 break; |
122 } | 122 } |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 instruction_blocks_.push_back(instruction_block); | 434 instruction_blocks_.push_back(instruction_block); |
435 current_block_ = instruction_block; | 435 current_block_ = instruction_block; |
436 sequence()->StartBlock(rpo); | 436 sequence()->StartBlock(rpo); |
437 return instruction_block; | 437 return instruction_block; |
438 } | 438 } |
439 | 439 |
440 | 440 |
441 void InstructionSequenceTest::WireBlocks() { | 441 void InstructionSequenceTest::WireBlocks() { |
442 CHECK(!current_block()); | 442 CHECK(!current_block()); |
443 CHECK(instruction_blocks_.size() == completions_.size()); | 443 CHECK(instruction_blocks_.size() == completions_.size()); |
| 444 CHECK(loop_blocks_.empty()); |
| 445 // Wire in end block to look like a scheduler produced cfg. |
| 446 auto end_block = NewBlock(); |
| 447 current_block_ = nullptr; |
| 448 sequence()->EndBlock(end_block->rpo_number()); |
444 size_t offset = 0; | 449 size_t offset = 0; |
445 for (const auto& completion : completions_) { | 450 for (const auto& completion : completions_) { |
446 switch (completion.type_) { | 451 switch (completion.type_) { |
447 case kBlockEnd: | 452 case kBlockEnd: { |
| 453 auto block = instruction_blocks_[offset]; |
| 454 block->successors().push_back(end_block->rpo_number()); |
| 455 end_block->predecessors().push_back(block->rpo_number()); |
448 break; | 456 break; |
| 457 } |
449 case kFallThrough: // Fallthrough. | 458 case kFallThrough: // Fallthrough. |
450 case kJump: | 459 case kJump: |
451 WireBlock(offset, completion.offset_0_); | 460 WireBlock(offset, completion.offset_0_); |
452 break; | 461 break; |
453 case kBranch: | 462 case kBranch: |
454 WireBlock(offset, completion.offset_0_); | 463 WireBlock(offset, completion.offset_0_); |
455 WireBlock(offset, completion.offset_1_); | 464 WireBlock(offset, completion.offset_1_); |
456 break; | 465 break; |
457 } | 466 } |
458 ++offset; | 467 ++offset; |
(...skipping 24 matching lines...) Expand all Loading... |
483 | 492 |
484 | 493 |
485 Instruction* InstructionSequenceTest::AddInstruction(Instruction* instruction) { | 494 Instruction* InstructionSequenceTest::AddInstruction(Instruction* instruction) { |
486 sequence()->AddInstruction(instruction); | 495 sequence()->AddInstruction(instruction); |
487 return instruction; | 496 return instruction; |
488 } | 497 } |
489 | 498 |
490 } // namespace compiler | 499 } // namespace compiler |
491 } // namespace internal | 500 } // namespace internal |
492 } // namespace v8 | 501 } // namespace v8 |
OLD | NEW |