| 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/v8.h" | 5 #include "src/v8.h" |
| 6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
| 7 | 7 |
| 8 #include "src/compiler/code-generator.h" | 8 #include "src/compiler/code-generator.h" |
| 9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
| 10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 Zone* zone() { return main_zone(); } | 49 Zone* zone() { return main_zone(); } |
| 50 | 50 |
| 51 void allocCode() { | 51 void allocCode() { |
| 52 if (schedule.rpo_order()->size() == 0) { | 52 if (schedule.rpo_order()->size() == 0) { |
| 53 // Compute the RPO order. | 53 // Compute the RPO order. |
| 54 ZonePool zone_pool(isolate); | 54 ZonePool zone_pool(isolate); |
| 55 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); | 55 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); |
| 56 DCHECK(schedule.rpo_order()->size() > 0); | 56 DCHECK(schedule.rpo_order()->size() > 0); |
| 57 } | 57 } |
| 58 code = new TestInstrSeq(main_zone(), &graph, &schedule); | 58 code = new TestInstrSeq(main_zone(), &schedule); |
| 59 } | 59 } |
| 60 | 60 |
| 61 Node* Int32Constant(int32_t val) { | 61 Node* Int32Constant(int32_t val) { |
| 62 Node* node = graph.NewNode(common.Int32Constant(val)); | 62 Node* node = graph.NewNode(common.Int32Constant(val)); |
| 63 schedule.AddNode(schedule.start(), node); | 63 schedule.AddNode(schedule.start(), node); |
| 64 return node; | 64 return node; |
| 65 } | 65 } |
| 66 | 66 |
| 67 Node* Float64Constant(double val) { | 67 Node* Float64Constant(double val) { |
| 68 Node* node = graph.NewNode(common.Float64Constant(val)); | 68 Node* node = graph.NewNode(common.Float64Constant(val)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 BasicBlock* last = R.schedule.start(); | 122 BasicBlock* last = R.schedule.start(); |
| 123 for (int i = 0; i < 5; i++) { | 123 for (int i = 0; i < 5; i++) { |
| 124 BasicBlock* block = R.schedule.NewBasicBlock(); | 124 BasicBlock* block = R.schedule.NewBasicBlock(); |
| 125 R.schedule.AddGoto(last, block); | 125 R.schedule.AddGoto(last, block); |
| 126 last = block; | 126 last = block; |
| 127 } | 127 } |
| 128 | 128 |
| 129 R.allocCode(); | 129 R.allocCode(); |
| 130 | 130 |
| 131 CHECK_EQ(R.graph.NodeCount(), R.code->node_count()); | |
| 132 | |
| 133 BasicBlockVector* blocks = R.schedule.rpo_order(); | 131 BasicBlockVector* blocks = R.schedule.rpo_order(); |
| 134 CHECK_EQ(static_cast<int>(blocks->size()), R.code->InstructionBlockCount()); | 132 CHECK_EQ(static_cast<int>(blocks->size()), R.code->InstructionBlockCount()); |
| 135 | 133 |
| 136 int index = 0; | 134 int index = 0; |
| 137 for (BasicBlockVectorIter i = blocks->begin(); i != blocks->end(); | 135 for (BasicBlockVectorIter i = blocks->begin(); i != blocks->end(); |
| 138 i++, index++) { | 136 i++, index++) { |
| 139 BasicBlock* block = *i; | 137 BasicBlock* block = *i; |
| 140 CHECK_EQ(block->rpo_number(), R.BlockAt(block)->rpo_number().ToInt()); | 138 CHECK_EQ(block->rpo_number(), R.BlockAt(block)->rpo_number().ToInt()); |
| 141 CHECK_EQ(block->id().ToInt(), R.BlockAt(block)->id().ToInt()); | 139 CHECK_EQ(block->id().ToInt(), R.BlockAt(block)->id().ToInt()); |
| 142 CHECK_EQ(-1, block->loop_end()); | 140 CHECK_EQ(-1, block->loop_end()); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 CHECK_EQ(inputs[z], m->InputAt(z)); | 356 CHECK_EQ(inputs[z], m->InputAt(z)); |
| 359 } | 357 } |
| 360 | 358 |
| 361 for (size_t z = 0; z < k; z++) { | 359 for (size_t z = 0; z < k; z++) { |
| 362 CHECK_EQ(temps[z], m->TempAt(z)); | 360 CHECK_EQ(temps[z], m->TempAt(z)); |
| 363 } | 361 } |
| 364 } | 362 } |
| 365 } | 363 } |
| 366 } | 364 } |
| 367 } | 365 } |
| OLD | NEW |