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

Side by Side Diff: src/compiler/instruction.cc

Issue 618643002: Replace OStream with std::ostream. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix 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
« no previous file with comments | « src/compiler/instruction.h ('k') | src/compiler/instruction-codes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/compiler/instruction.h" 5 #include "src/compiler/instruction.h"
6 6
7 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/generic-node-inl.h" 8 #include "src/compiler/generic-node-inl.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 namespace compiler { 12 namespace compiler {
13 13
14 OStream& operator<<(OStream& os, const InstructionOperand& op) { 14 std::ostream& operator<<(std::ostream& os, const InstructionOperand& op) {
15 switch (op.kind()) { 15 switch (op.kind()) {
16 case InstructionOperand::INVALID: 16 case InstructionOperand::INVALID:
17 return os << "(0)"; 17 return os << "(0)";
18 case InstructionOperand::UNALLOCATED: { 18 case InstructionOperand::UNALLOCATED: {
19 const UnallocatedOperand* unalloc = UnallocatedOperand::cast(&op); 19 const UnallocatedOperand* unalloc = UnallocatedOperand::cast(&op);
20 os << "v" << unalloc->virtual_register(); 20 os << "v" << unalloc->virtual_register();
21 if (unalloc->basic_policy() == UnallocatedOperand::FIXED_SLOT) { 21 if (unalloc->basic_policy() == UnallocatedOperand::FIXED_SLOT) {
22 return os << "(=" << unalloc->fixed_slot_index() << "S)"; 22 return os << "(=" << unalloc->fixed_slot_index() << "S)";
23 } 23 }
24 switch (unalloc->extended_policy()) { 24 switch (unalloc->extended_policy()) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 90
91 void InstructionOperand::TearDownCaches() { 91 void InstructionOperand::TearDownCaches() {
92 #define INSTRUCTION_OPERAND_TEARDOWN(name, type, number) \ 92 #define INSTRUCTION_OPERAND_TEARDOWN(name, type, number) \
93 name##Operand::TearDownCache(); 93 name##Operand::TearDownCache();
94 INSTRUCTION_OPERAND_LIST(INSTRUCTION_OPERAND_TEARDOWN) 94 INSTRUCTION_OPERAND_LIST(INSTRUCTION_OPERAND_TEARDOWN)
95 #undef INSTRUCTION_OPERAND_TEARDOWN 95 #undef INSTRUCTION_OPERAND_TEARDOWN
96 } 96 }
97 97
98 98
99 OStream& operator<<(OStream& os, const MoveOperands& mo) { 99 std::ostream& operator<<(std::ostream& os, const MoveOperands& mo) {
100 os << *mo.destination(); 100 os << *mo.destination();
101 if (!mo.source()->Equals(mo.destination())) os << " = " << *mo.source(); 101 if (!mo.source()->Equals(mo.destination())) os << " = " << *mo.source();
102 return os << ";"; 102 return os << ";";
103 } 103 }
104 104
105 105
106 bool ParallelMove::IsRedundant() const { 106 bool ParallelMove::IsRedundant() const {
107 for (int i = 0; i < move_operands_.length(); ++i) { 107 for (int i = 0; i < move_operands_.length(); ++i) {
108 if (!move_operands_[i].IsRedundant()) return false; 108 if (!move_operands_[i].IsRedundant()) return false;
109 } 109 }
110 return true; 110 return true;
111 } 111 }
112 112
113 113
114 OStream& operator<<(OStream& os, const ParallelMove& pm) { 114 std::ostream& operator<<(std::ostream& os, const ParallelMove& pm) {
115 bool first = true; 115 bool first = true;
116 for (ZoneList<MoveOperands>::iterator move = pm.move_operands()->begin(); 116 for (ZoneList<MoveOperands>::iterator move = pm.move_operands()->begin();
117 move != pm.move_operands()->end(); ++move) { 117 move != pm.move_operands()->end(); ++move) {
118 if (move->IsEliminated()) continue; 118 if (move->IsEliminated()) continue;
119 if (!first) os << " "; 119 if (!first) os << " ";
120 first = false; 120 first = false;
121 os << *move; 121 os << *move;
122 } 122 }
123 return os; 123 return os;
124 } 124 }
(...skipping 21 matching lines...) Expand all
146 146
147 147
148 void PointerMap::RecordUntagged(InstructionOperand* op, Zone* zone) { 148 void PointerMap::RecordUntagged(InstructionOperand* op, Zone* zone) {
149 // Do not record arguments as pointers. 149 // Do not record arguments as pointers.
150 if (op->IsStackSlot() && op->index() < 0) return; 150 if (op->IsStackSlot() && op->index() < 0) return;
151 DCHECK(!op->IsDoubleRegister() && !op->IsDoubleStackSlot()); 151 DCHECK(!op->IsDoubleRegister() && !op->IsDoubleStackSlot());
152 untagged_operands_.Add(op, zone); 152 untagged_operands_.Add(op, zone);
153 } 153 }
154 154
155 155
156 OStream& operator<<(OStream& os, const PointerMap& pm) { 156 std::ostream& operator<<(std::ostream& os, const PointerMap& pm) {
157 os << "{"; 157 os << "{";
158 for (ZoneList<InstructionOperand*>::iterator op = 158 for (ZoneList<InstructionOperand*>::iterator op =
159 pm.pointer_operands_.begin(); 159 pm.pointer_operands_.begin();
160 op != pm.pointer_operands_.end(); ++op) { 160 op != pm.pointer_operands_.end(); ++op) {
161 if (op != pm.pointer_operands_.begin()) os << ";"; 161 if (op != pm.pointer_operands_.begin()) os << ";";
162 os << *op; 162 os << *op;
163 } 163 }
164 return os << "}"; 164 return os << "}";
165 } 165 }
166 166
167 167
168 OStream& operator<<(OStream& os, const ArchOpcode& ao) { 168 std::ostream& operator<<(std::ostream& os, const ArchOpcode& ao) {
169 switch (ao) { 169 switch (ao) {
170 #define CASE(Name) \ 170 #define CASE(Name) \
171 case k##Name: \ 171 case k##Name: \
172 return os << #Name; 172 return os << #Name;
173 ARCH_OPCODE_LIST(CASE) 173 ARCH_OPCODE_LIST(CASE)
174 #undef CASE 174 #undef CASE
175 } 175 }
176 UNREACHABLE(); 176 UNREACHABLE();
177 return os; 177 return os;
178 } 178 }
179 179
180 180
181 OStream& operator<<(OStream& os, const AddressingMode& am) { 181 std::ostream& operator<<(std::ostream& os, const AddressingMode& am) {
182 switch (am) { 182 switch (am) {
183 case kMode_None: 183 case kMode_None:
184 return os; 184 return os;
185 #define CASE(Name) \ 185 #define CASE(Name) \
186 case kMode_##Name: \ 186 case kMode_##Name: \
187 return os << #Name; 187 return os << #Name;
188 TARGET_ADDRESSING_MODE_LIST(CASE) 188 TARGET_ADDRESSING_MODE_LIST(CASE)
189 #undef CASE 189 #undef CASE
190 } 190 }
191 UNREACHABLE(); 191 UNREACHABLE();
192 return os; 192 return os;
193 } 193 }
194 194
195 195
196 OStream& operator<<(OStream& os, const FlagsMode& fm) { 196 std::ostream& operator<<(std::ostream& os, const FlagsMode& fm) {
197 switch (fm) { 197 switch (fm) {
198 case kFlags_none: 198 case kFlags_none:
199 return os; 199 return os;
200 case kFlags_branch: 200 case kFlags_branch:
201 return os << "branch"; 201 return os << "branch";
202 case kFlags_set: 202 case kFlags_set:
203 return os << "set"; 203 return os << "set";
204 } 204 }
205 UNREACHABLE(); 205 UNREACHABLE();
206 return os; 206 return os;
207 } 207 }
208 208
209 209
210 OStream& operator<<(OStream& os, const FlagsCondition& fc) { 210 std::ostream& operator<<(std::ostream& os, const FlagsCondition& fc) {
211 switch (fc) { 211 switch (fc) {
212 case kEqual: 212 case kEqual:
213 return os << "equal"; 213 return os << "equal";
214 case kNotEqual: 214 case kNotEqual:
215 return os << "not equal"; 215 return os << "not equal";
216 case kSignedLessThan: 216 case kSignedLessThan:
217 return os << "signed less than"; 217 return os << "signed less than";
218 case kSignedGreaterThanOrEqual: 218 case kSignedGreaterThanOrEqual:
219 return os << "signed greater than or equal"; 219 return os << "signed greater than or equal";
220 case kSignedLessThanOrEqual: 220 case kSignedLessThanOrEqual:
(...skipping 23 matching lines...) Expand all
244 case kOverflow: 244 case kOverflow:
245 return os << "overflow"; 245 return os << "overflow";
246 case kNotOverflow: 246 case kNotOverflow:
247 return os << "not overflow"; 247 return os << "not overflow";
248 } 248 }
249 UNREACHABLE(); 249 UNREACHABLE();
250 return os; 250 return os;
251 } 251 }
252 252
253 253
254 OStream& operator<<(OStream& os, const Instruction& instr) { 254 std::ostream& operator<<(std::ostream& os, const Instruction& instr) {
255 if (instr.OutputCount() > 1) os << "("; 255 if (instr.OutputCount() > 1) os << "(";
256 for (size_t i = 0; i < instr.OutputCount(); i++) { 256 for (size_t i = 0; i < instr.OutputCount(); i++) {
257 if (i > 0) os << ", "; 257 if (i > 0) os << ", ";
258 os << *instr.OutputAt(i); 258 os << *instr.OutputAt(i);
259 } 259 }
260 260
261 if (instr.OutputCount() > 1) os << ") = "; 261 if (instr.OutputCount() > 1) os << ") = ";
262 if (instr.OutputCount() == 1) os << " = "; 262 if (instr.OutputCount() == 1) os << " = ";
263 263
264 if (instr.IsGapMoves()) { 264 if (instr.IsGapMoves()) {
(...skipping 23 matching lines...) Expand all
288 } 288 }
289 if (instr.InputCount() > 0) { 289 if (instr.InputCount() > 0) {
290 for (size_t i = 0; i < instr.InputCount(); i++) { 290 for (size_t i = 0; i < instr.InputCount(); i++) {
291 os << " " << *instr.InputAt(i); 291 os << " " << *instr.InputAt(i);
292 } 292 }
293 } 293 }
294 return os << "\n"; 294 return os << "\n";
295 } 295 }
296 296
297 297
298 OStream& operator<<(OStream& os, const Constant& constant) { 298 std::ostream& operator<<(std::ostream& os, const Constant& constant) {
299 switch (constant.type()) { 299 switch (constant.type()) {
300 case Constant::kInt32: 300 case Constant::kInt32:
301 return os << constant.ToInt32(); 301 return os << constant.ToInt32();
302 case Constant::kInt64: 302 case Constant::kInt64:
303 return os << constant.ToInt64() << "l"; 303 return os << constant.ToInt64() << "l";
304 case Constant::kFloat32: 304 case Constant::kFloat32:
305 return os << constant.ToFloat32() << "f"; 305 return os << constant.ToFloat32() << "f";
306 case Constant::kFloat64: 306 case Constant::kFloat64:
307 return os << constant.ToFloat64(); 307 return os << constant.ToFloat64();
308 case Constant::kExternalReference: 308 case Constant::kExternalReference:
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 InstructionSequence::StateId state_id) { 408 InstructionSequence::StateId state_id) {
409 return deoptimization_entries_[state_id.ToInt()]; 409 return deoptimization_entries_[state_id.ToInt()];
410 } 410 }
411 411
412 412
413 int InstructionSequence::GetFrameStateDescriptorCount() { 413 int InstructionSequence::GetFrameStateDescriptorCount() {
414 return static_cast<int>(deoptimization_entries_.size()); 414 return static_cast<int>(deoptimization_entries_.size());
415 } 415 }
416 416
417 417
418 OStream& operator<<(OStream& os, const InstructionSequence& code) { 418 std::ostream& operator<<(std::ostream& os, const InstructionSequence& code) {
419 for (size_t i = 0; i < code.immediates_.size(); ++i) { 419 for (size_t i = 0; i < code.immediates_.size(); ++i) {
420 Constant constant = code.immediates_[i]; 420 Constant constant = code.immediates_[i];
421 os << "IMM#" << i << ": " << constant << "\n"; 421 os << "IMM#" << i << ": " << constant << "\n";
422 } 422 }
423 int i = 0; 423 int i = 0;
424 for (ConstantMap::const_iterator it = code.constants_.begin(); 424 for (ConstantMap::const_iterator it = code.constants_.begin();
425 it != code.constants_.end(); ++i, ++it) { 425 it != code.constants_.end(); ++i, ++it) {
426 os << "CST#" << i << ": v" << it->first << " = " << it->second << "\n"; 426 os << "CST#" << i << ": v" << it->first << " = " << it->second << "\n";
427 } 427 }
428 for (int i = 0; i < code.BasicBlockCount(); i++) { 428 for (int i = 0; i < code.BasicBlockCount(); i++) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 os << " B" << (*iter)->id(); 475 os << " B" << (*iter)->id();
476 } 476 }
477 os << "\n"; 477 os << "\n";
478 } 478 }
479 return os; 479 return os;
480 } 480 }
481 481
482 } // namespace compiler 482 } // namespace compiler
483 } // namespace internal 483 } // namespace internal
484 } // namespace v8 484 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction.h ('k') | src/compiler/instruction-codes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698