OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 | 6 |
7 #include "src/lithium.h" | 7 #include "src/lithium.h" |
8 #include "src/scopes.h" | 8 #include "src/scopes.h" |
9 #include "src/serialize.h" | 9 #include "src/serialize.h" |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 stream->Add("v%d", unalloc->virtual_register()); | 48 stream->Add("v%d", unalloc->virtual_register()); |
49 if (unalloc->basic_policy() == LUnallocated::FIXED_SLOT) { | 49 if (unalloc->basic_policy() == LUnallocated::FIXED_SLOT) { |
50 stream->Add("(=%dS)", unalloc->fixed_slot_index()); | 50 stream->Add("(=%dS)", unalloc->fixed_slot_index()); |
51 break; | 51 break; |
52 } | 52 } |
53 switch (unalloc->extended_policy()) { | 53 switch (unalloc->extended_policy()) { |
54 case LUnallocated::NONE: | 54 case LUnallocated::NONE: |
55 break; | 55 break; |
56 case LUnallocated::FIXED_REGISTER: { | 56 case LUnallocated::FIXED_REGISTER: { |
57 int reg_index = unalloc->fixed_register_index(); | 57 int reg_index = unalloc->fixed_register_index(); |
58 const char* register_name = | 58 if (reg_index < 0 || |
59 Register::AllocationIndexToString(reg_index); | 59 reg_index >= Register::kMaxNumAllocatableRegisters) { |
60 stream->Add("(=%s)", register_name); | 60 stream->Add("(=invalid_reg#%d)", reg_index); |
| 61 } else { |
| 62 const char* register_name = |
| 63 Register::AllocationIndexToString(reg_index); |
| 64 stream->Add("(=%s)", register_name); |
| 65 } |
61 break; | 66 break; |
62 } | 67 } |
63 case LUnallocated::FIXED_DOUBLE_REGISTER: { | 68 case LUnallocated::FIXED_DOUBLE_REGISTER: { |
64 int reg_index = unalloc->fixed_register_index(); | 69 int reg_index = unalloc->fixed_register_index(); |
65 const char* double_register_name = | 70 if (reg_index < 0 || |
66 DoubleRegister::AllocationIndexToString(reg_index); | 71 reg_index >= DoubleRegister::kMaxNumAllocatableRegisters) { |
67 stream->Add("(=%s)", double_register_name); | 72 stream->Add("(=invalid_double_reg#%d)", reg_index); |
| 73 } else { |
| 74 const char* double_register_name = |
| 75 DoubleRegister::AllocationIndexToString(reg_index); |
| 76 stream->Add("(=%s)", double_register_name); |
| 77 } |
68 break; | 78 break; |
69 } | 79 } |
70 case LUnallocated::MUST_HAVE_REGISTER: | 80 case LUnallocated::MUST_HAVE_REGISTER: |
71 stream->Add("(R)"); | 81 stream->Add("(R)"); |
72 break; | 82 break; |
73 case LUnallocated::MUST_HAVE_DOUBLE_REGISTER: | 83 case LUnallocated::MUST_HAVE_DOUBLE_REGISTER: |
74 stream->Add("(D)"); | 84 stream->Add("(D)"); |
75 break; | 85 break; |
76 case LUnallocated::WRITABLE_REGISTER: | 86 case LUnallocated::WRITABLE_REGISTER: |
77 stream->Add("(WR)"); | 87 stream->Add("(WR)"); |
78 break; | 88 break; |
79 case LUnallocated::SAME_AS_FIRST_INPUT: | 89 case LUnallocated::SAME_AS_FIRST_INPUT: |
80 stream->Add("(1)"); | 90 stream->Add("(1)"); |
81 break; | 91 break; |
82 case LUnallocated::ANY: | 92 case LUnallocated::ANY: |
83 stream->Add("(-)"); | 93 stream->Add("(-)"); |
84 break; | 94 break; |
85 } | 95 } |
86 break; | 96 break; |
87 case CONSTANT_OPERAND: | 97 case CONSTANT_OPERAND: |
88 stream->Add("[constant:%d]", index()); | 98 stream->Add("[constant:%d]", index()); |
89 break; | 99 break; |
90 case STACK_SLOT: | 100 case STACK_SLOT: |
91 stream->Add("[stack:%d]", index()); | 101 stream->Add("[stack:%d]", index()); |
92 break; | 102 break; |
93 case DOUBLE_STACK_SLOT: | 103 case DOUBLE_STACK_SLOT: |
94 stream->Add("[double_stack:%d]", index()); | 104 stream->Add("[double_stack:%d]", index()); |
95 break; | 105 break; |
96 case REGISTER: | 106 case REGISTER: { |
97 stream->Add("[%s|R]", Register::AllocationIndexToString(index())); | 107 int reg_index = index(); |
| 108 if (reg_index < 0 || reg_index >= Register::kMaxNumAllocatableRegisters) { |
| 109 stream->Add("(=invalid_reg#%d|R)", reg_index); |
| 110 } else { |
| 111 stream->Add("[%s|R]", Register::AllocationIndexToString(reg_index)); |
| 112 } |
98 break; | 113 break; |
99 case DOUBLE_REGISTER: | 114 } |
100 stream->Add("[%s|R]", DoubleRegister::AllocationIndexToString(index())); | 115 case DOUBLE_REGISTER: { |
| 116 int reg_index = index(); |
| 117 if (reg_index < 0 || |
| 118 reg_index >= DoubleRegister::kMaxNumAllocatableRegisters) { |
| 119 stream->Add("(=invalid_double_reg#%d|R)", reg_index); |
| 120 } else { |
| 121 stream->Add("[%s|R]", |
| 122 DoubleRegister::AllocationIndexToString(reg_index)); |
| 123 } |
101 break; | 124 break; |
| 125 } |
102 } | 126 } |
103 } | 127 } |
104 | 128 |
105 | 129 |
106 template<LOperand::Kind kOperandKind, int kNumCachedOperands> | 130 template<LOperand::Kind kOperandKind, int kNumCachedOperands> |
107 LSubKindOperand<kOperandKind, kNumCachedOperands>* | 131 LSubKindOperand<kOperandKind, kNumCachedOperands>* |
108 LSubKindOperand<kOperandKind, kNumCachedOperands>::cache = NULL; | 132 LSubKindOperand<kOperandKind, kNumCachedOperands>::cache = NULL; |
109 | 133 |
110 | 134 |
111 template<LOperand::Kind kOperandKind, int kNumCachedOperands> | 135 template<LOperand::Kind kOperandKind, int kNumCachedOperands> |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // Incoming parameter. Skip the return address. | 259 // Incoming parameter. Skip the return address. |
236 return -(index + 1) * kPointerSize + kFPOnStackSize + kPCOnStackSize; | 260 return -(index + 1) * kPointerSize + kFPOnStackSize + kPCOnStackSize; |
237 } | 261 } |
238 } | 262 } |
239 | 263 |
240 | 264 |
241 LChunk::LChunk(CompilationInfo* info, HGraph* graph) | 265 LChunk::LChunk(CompilationInfo* info, HGraph* graph) |
242 : spill_slot_count_(0), | 266 : spill_slot_count_(0), |
243 info_(info), | 267 info_(info), |
244 graph_(graph), | 268 graph_(graph), |
245 instructions_(32, graph->zone()), | 269 instructions_(32, info->zone()), |
246 pointer_maps_(8, graph->zone()), | 270 pointer_maps_(8, info->zone()), |
247 inlined_closures_(1, graph->zone()), | 271 inlined_closures_(1, info->zone()), |
248 deprecation_dependencies_(MapLess(), MapAllocator(graph->zone())), | 272 deprecation_dependencies_(MapLess(), MapAllocator(info->zone())), |
249 stability_dependencies_(MapLess(), MapAllocator(graph->zone())) { | 273 stability_dependencies_(MapLess(), MapAllocator(info->zone())) {} |
250 } | |
251 | 274 |
252 | 275 |
253 LLabel* LChunk::GetLabel(int block_id) const { | 276 LLabel* LChunk::GetLabel(int block_id) const { |
254 HBasicBlock* block = graph_->blocks()->at(block_id); | 277 HBasicBlock* block = graph_->blocks()->at(block_id); |
255 int first_instruction = block->first_instruction_index(); | 278 int first_instruction = block->first_instruction_index(); |
256 return LLabel::cast(instructions_[first_instruction]); | 279 return LLabel::cast(instructions_[first_instruction]); |
257 } | 280 } |
258 | 281 |
259 | 282 |
260 int LChunk::LookupDestination(int block_id) const { | 283 int LChunk::LookupDestination(int block_id) const { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 if (can_eliminate) { | 324 if (can_eliminate) { |
302 label->set_replacement(GetLabel(goto_instr->block_id())); | 325 label->set_replacement(GetLabel(goto_instr->block_id())); |
303 } | 326 } |
304 } | 327 } |
305 } | 328 } |
306 } | 329 } |
307 } | 330 } |
308 | 331 |
309 | 332 |
310 void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) { | 333 void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) { |
311 LInstructionGap* gap = new(graph_->zone()) LInstructionGap(block); | 334 LInstructionGap* gap = new (zone()) LInstructionGap(block); |
312 gap->set_hydrogen_value(instr->hydrogen_value()); | 335 gap->set_hydrogen_value(instr->hydrogen_value()); |
313 int index = -1; | 336 int index = -1; |
314 if (instr->IsControl()) { | 337 if (instr->IsControl()) { |
315 instructions_.Add(gap, zone()); | 338 instructions_.Add(gap, zone()); |
316 index = instructions_.length(); | 339 index = instructions_.length(); |
317 instructions_.Add(instr, zone()); | 340 instructions_.Add(instr, zone()); |
318 } else { | 341 } else { |
319 index = instructions_.length(); | 342 index = instructions_.length(); |
320 instructions_.Add(instr, zone()); | 343 instructions_.Add(instr, zone()); |
321 instructions_.Add(gap, zone()); | 344 instructions_.Add(gap, zone()); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 | 642 |
620 | 643 |
621 LPhase::~LPhase() { | 644 LPhase::~LPhase() { |
622 if (ShouldProduceTraceOutput()) { | 645 if (ShouldProduceTraceOutput()) { |
623 isolate()->GetHTracer()->TraceLithium(name(), chunk_); | 646 isolate()->GetHTracer()->TraceLithium(name(), chunk_); |
624 } | 647 } |
625 } | 648 } |
626 | 649 |
627 | 650 |
628 } } // namespace v8::internal | 651 } } // namespace v8::internal |
OLD | NEW |