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

Side by Side Diff: test/cctest/compiler/test-instruction.cc

Issue 669613002: [turbofan] remove schedule from InstructionSequence (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
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 "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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 TestInstr* instr = TestInstr::New(zone(), opcode); 86 TestInstr* instr = TestInstr::New(zone(), opcode);
87 return code->AddInstruction(instr); 87 return code->AddInstruction(instr);
88 } 88 }
89 89
90 UnallocatedOperand* NewUnallocated(int vreg) { 90 UnallocatedOperand* NewUnallocated(int vreg) {
91 UnallocatedOperand* unallocated = 91 UnallocatedOperand* unallocated =
92 new (zone()) UnallocatedOperand(UnallocatedOperand::ANY); 92 new (zone()) UnallocatedOperand(UnallocatedOperand::ANY);
93 unallocated->set_virtual_register(vreg); 93 unallocated->set_virtual_register(vreg);
94 return unallocated; 94 return unallocated;
95 } 95 }
96
97 InstructionBlock* BlockAt(BasicBlock* block) {
98 return code->InstructionBlockAt(block->GetRpoNumber());
99 }
100 BasicBlock* GetBasicBlock(int instruction_index) {
101 const InstructionBlock* block =
102 code->GetInstructionBlock(instruction_index);
103 return schedule.rpo_order()->at(block->rpo_number().ToSize());
104 }
105 int first_instruction_index(BasicBlock* block) {
106 return BlockAt(block)->first_instruction_index();
107 }
108 int last_instruction_index(BasicBlock* block) {
109 return BlockAt(block)->last_instruction_index();
110 }
96 }; 111 };
97 112
98 113
99 TEST(InstructionBasic) { 114 TEST(InstructionBasic) {
100 InstructionTester R; 115 InstructionTester R;
101 116
102 for (int i = 0; i < 10; i++) { 117 for (int i = 0; i < 10; i++) {
103 R.Int32Constant(i); // Add some nodes to the graph. 118 R.Int32Constant(i); // Add some nodes to the graph.
104 } 119 }
105 120
106 BasicBlock* last = R.schedule.start(); 121 BasicBlock* last = R.schedule.start();
107 for (int i = 0; i < 5; i++) { 122 for (int i = 0; i < 5; i++) {
108 BasicBlock* block = R.schedule.NewBasicBlock(); 123 BasicBlock* block = R.schedule.NewBasicBlock();
109 R.schedule.AddGoto(last, block); 124 R.schedule.AddGoto(last, block);
110 last = block; 125 last = block;
111 } 126 }
112 127
113 R.allocCode(); 128 R.allocCode();
114 129
115 CHECK_EQ(R.graph.NodeCount(), R.code->node_count()); 130 CHECK_EQ(R.graph.NodeCount(), R.code->node_count());
116 131
117 BasicBlockVector* blocks = R.schedule.rpo_order(); 132 BasicBlockVector* blocks = R.schedule.rpo_order();
118 CHECK_EQ(static_cast<int>(blocks->size()), R.code->BasicBlockCount()); 133 CHECK_EQ(static_cast<int>(blocks->size()), R.code->BasicBlockCount());
119 134
120 int index = 0; 135 int index = 0;
121 for (BasicBlockVectorIter i = blocks->begin(); i != blocks->end(); 136 for (BasicBlockVectorIter i = blocks->begin(); i != blocks->end();
122 i++, index++) { 137 i++, index++) {
123 BasicBlock* block = *i; 138 BasicBlock* block = *i;
124 CHECK_EQ(block, R.code->BlockAt(index)); 139 CHECK_EQ(block->rpo_number(), R.BlockAt(block)->rpo_number().ToInt());
140 CHECK_EQ(block->id().ToInt(), R.BlockAt(block)->id().ToInt());
125 CHECK_EQ(-1, block->loop_end()); 141 CHECK_EQ(-1, block->loop_end());
126 } 142 }
127 } 143 }
128 144
129 145
130 TEST(InstructionGetBasicBlock) { 146 TEST(InstructionGetBasicBlock) {
131 InstructionTester R; 147 InstructionTester R;
132 148
133 BasicBlock* b0 = R.schedule.start(); 149 BasicBlock* b0 = R.schedule.start();
134 BasicBlock* b1 = R.schedule.NewBasicBlock(); 150 BasicBlock* b1 = R.schedule.NewBasicBlock();
(...skipping 17 matching lines...) Expand all
152 int i5 = R.NewInstr(); 168 int i5 = R.NewInstr();
153 R.code->EndBlock(b1); 169 R.code->EndBlock(b1);
154 R.code->StartBlock(b2); 170 R.code->StartBlock(b2);
155 int i6 = R.NewInstr(); 171 int i6 = R.NewInstr();
156 int i7 = R.NewInstr(); 172 int i7 = R.NewInstr();
157 int i8 = R.NewInstr(); 173 int i8 = R.NewInstr();
158 R.code->EndBlock(b2); 174 R.code->EndBlock(b2);
159 R.code->StartBlock(b3); 175 R.code->StartBlock(b3);
160 R.code->EndBlock(b3); 176 R.code->EndBlock(b3);
161 177
162 CHECK_EQ(b0, R.code->GetBasicBlock(i0)); 178 CHECK_EQ(b0, R.GetBasicBlock(i0));
163 CHECK_EQ(b0, R.code->GetBasicBlock(i1)); 179 CHECK_EQ(b0, R.GetBasicBlock(i1));
164 180
165 CHECK_EQ(b1, R.code->GetBasicBlock(i2)); 181 CHECK_EQ(b1, R.GetBasicBlock(i2));
166 CHECK_EQ(b1, R.code->GetBasicBlock(i3)); 182 CHECK_EQ(b1, R.GetBasicBlock(i3));
167 CHECK_EQ(b1, R.code->GetBasicBlock(i4)); 183 CHECK_EQ(b1, R.GetBasicBlock(i4));
168 CHECK_EQ(b1, R.code->GetBasicBlock(i5)); 184 CHECK_EQ(b1, R.GetBasicBlock(i5));
169 185
170 CHECK_EQ(b2, R.code->GetBasicBlock(i6)); 186 CHECK_EQ(b2, R.GetBasicBlock(i6));
171 CHECK_EQ(b2, R.code->GetBasicBlock(i7)); 187 CHECK_EQ(b2, R.GetBasicBlock(i7));
172 CHECK_EQ(b2, R.code->GetBasicBlock(i8)); 188 CHECK_EQ(b2, R.GetBasicBlock(i8));
173 189
174 CHECK_EQ(b0, R.code->GetBasicBlock(R.code->first_instruction_index(b0))); 190 CHECK_EQ(b0, R.GetBasicBlock(R.first_instruction_index(b0)));
175 CHECK_EQ(b0, R.code->GetBasicBlock(R.code->last_instruction_index(b0))); 191 CHECK_EQ(b0, R.GetBasicBlock(R.last_instruction_index(b0)));
176 192
177 CHECK_EQ(b1, R.code->GetBasicBlock(R.code->first_instruction_index(b1))); 193 CHECK_EQ(b1, R.GetBasicBlock(R.first_instruction_index(b1)));
178 CHECK_EQ(b1, R.code->GetBasicBlock(R.code->last_instruction_index(b1))); 194 CHECK_EQ(b1, R.GetBasicBlock(R.last_instruction_index(b1)));
179 195
180 CHECK_EQ(b2, R.code->GetBasicBlock(R.code->first_instruction_index(b2))); 196 CHECK_EQ(b2, R.GetBasicBlock(R.first_instruction_index(b2)));
181 CHECK_EQ(b2, R.code->GetBasicBlock(R.code->last_instruction_index(b2))); 197 CHECK_EQ(b2, R.GetBasicBlock(R.last_instruction_index(b2)));
182 198
183 CHECK_EQ(b3, R.code->GetBasicBlock(R.code->first_instruction_index(b3))); 199 CHECK_EQ(b3, R.GetBasicBlock(R.first_instruction_index(b3)));
184 CHECK_EQ(b3, R.code->GetBasicBlock(R.code->last_instruction_index(b3))); 200 CHECK_EQ(b3, R.GetBasicBlock(R.last_instruction_index(b3)));
185 } 201 }
186 202
187 203
188 TEST(InstructionIsGapAt) { 204 TEST(InstructionIsGapAt) {
189 InstructionTester R; 205 InstructionTester R;
190 206
191 BasicBlock* b0 = R.schedule.start(); 207 BasicBlock* b0 = R.schedule.start();
192 R.schedule.AddReturn(b0, R.Int32Constant(1)); 208 R.schedule.AddReturn(b0, R.Int32Constant(1));
193 209
194 R.allocCode(); 210 R.allocCode();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 CHECK_EQ(inputs[z], m->InputAt(z)); 357 CHECK_EQ(inputs[z], m->InputAt(z));
342 } 358 }
343 359
344 for (size_t z = 0; z < k; z++) { 360 for (size_t z = 0; z < k; z++) {
345 CHECK_EQ(temps[z], m->TempAt(z)); 361 CHECK_EQ(temps[z], m->TempAt(z));
346 } 362 }
347 } 363 }
348 } 364 }
349 } 365 }
350 } 366 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-codegen-deopt.cc ('k') | test/unittests/compiler/instruction-selector-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698