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 reg_index >= Register::kMaxNumAllocatableRegisters) { |
| 60 stream->Add("(=invalid_reg#%d)", reg_index); |
| 61 } else { |
| 62 const char* register_name = |
59 Register::AllocationIndexToString(reg_index); | 63 Register::AllocationIndexToString(reg_index); |
60 stream->Add("(=%s)", register_name); | 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 || |
| 71 reg_index >= DoubleRegister::kMaxNumAllocatableRegisters) { |
| 72 stream->Add("(=invalid_double_reg#%d)", reg_index); |
| 73 } else { |
| 74 const char* double_register_name = |
66 DoubleRegister::AllocationIndexToString(reg_index); | 75 DoubleRegister::AllocationIndexToString(reg_index); |
67 stream->Add("(=%s)", double_register_name); | 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 || |
| 109 reg_index >= Register::kMaxNumAllocatableRegisters) { |
| 110 stream->Add("(=invalid_reg#%d|R)", reg_index); |
| 111 } else { |
| 112 stream->Add("[%s|R]", Register::AllocationIndexToString(reg_index)); |
| 113 } |
98 break; | 114 break; |
99 case DOUBLE_REGISTER: | 115 } |
100 stream->Add("[%s|R]", DoubleRegister::AllocationIndexToString(index())); | 116 case DOUBLE_REGISTER: { |
| 117 int reg_index = index(); |
| 118 if (reg_index < 0 || |
| 119 reg_index >= DoubleRegister::kMaxNumAllocatableRegisters) { |
| 120 stream->Add("(=invalid_double_reg#%d|R)", reg_index); |
| 121 } else { |
| 122 stream->Add("[%s|R]", |
| 123 DoubleRegister::AllocationIndexToString(reg_index)); |
| 124 } |
101 break; | 125 break; |
| 126 } |
102 } | 127 } |
103 } | 128 } |
104 | 129 |
105 | 130 |
106 template<LOperand::Kind kOperandKind, int kNumCachedOperands> | 131 template<LOperand::Kind kOperandKind, int kNumCachedOperands> |
107 LSubKindOperand<kOperandKind, kNumCachedOperands>* | 132 LSubKindOperand<kOperandKind, kNumCachedOperands>* |
108 LSubKindOperand<kOperandKind, kNumCachedOperands>::cache = NULL; | 133 LSubKindOperand<kOperandKind, kNumCachedOperands>::cache = NULL; |
109 | 134 |
110 | 135 |
111 template<LOperand::Kind kOperandKind, int kNumCachedOperands> | 136 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. | 260 // Incoming parameter. Skip the return address. |
236 return -(index + 1) * kPointerSize + kFPOnStackSize + kPCOnStackSize; | 261 return -(index + 1) * kPointerSize + kFPOnStackSize + kPCOnStackSize; |
237 } | 262 } |
238 } | 263 } |
239 | 264 |
240 | 265 |
241 LChunk::LChunk(CompilationInfo* info, HGraph* graph) | 266 LChunk::LChunk(CompilationInfo* info, HGraph* graph) |
242 : spill_slot_count_(0), | 267 : spill_slot_count_(0), |
243 info_(info), | 268 info_(info), |
244 graph_(graph), | 269 graph_(graph), |
245 instructions_(32, graph->zone()), | 270 instructions_(32, info->zone()), |
246 pointer_maps_(8, graph->zone()), | 271 pointer_maps_(8, info->zone()), |
247 inlined_closures_(1, graph->zone()), | 272 inlined_closures_(1, info->zone()), |
248 deprecation_dependencies_(MapLess(), MapAllocator(graph->zone())), | 273 deprecation_dependencies_(MapLess(), MapAllocator(info->zone())), |
249 stability_dependencies_(MapLess(), MapAllocator(graph->zone())) { | 274 stability_dependencies_(MapLess(), MapAllocator(info->zone())) { |
250 } | 275 } |
251 | 276 |
252 | 277 |
253 LLabel* LChunk::GetLabel(int block_id) const { | 278 LLabel* LChunk::GetLabel(int block_id) const { |
254 HBasicBlock* block = graph_->blocks()->at(block_id); | 279 HBasicBlock* block = graph_->blocks()->at(block_id); |
255 int first_instruction = block->first_instruction_index(); | 280 int first_instruction = block->first_instruction_index(); |
256 return LLabel::cast(instructions_[first_instruction]); | 281 return LLabel::cast(instructions_[first_instruction]); |
257 } | 282 } |
258 | 283 |
259 | 284 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 if (can_eliminate) { | 326 if (can_eliminate) { |
302 label->set_replacement(GetLabel(goto_instr->block_id())); | 327 label->set_replacement(GetLabel(goto_instr->block_id())); |
303 } | 328 } |
304 } | 329 } |
305 } | 330 } |
306 } | 331 } |
307 } | 332 } |
308 | 333 |
309 | 334 |
310 void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) { | 335 void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) { |
311 LInstructionGap* gap = new(graph_->zone()) LInstructionGap(block); | 336 LInstructionGap* gap = new(zone()) LInstructionGap(block); |
312 gap->set_hydrogen_value(instr->hydrogen_value()); | 337 gap->set_hydrogen_value(instr->hydrogen_value()); |
313 int index = -1; | 338 int index = -1; |
314 if (instr->IsControl()) { | 339 if (instr->IsControl()) { |
315 instructions_.Add(gap, zone()); | 340 instructions_.Add(gap, zone()); |
316 index = instructions_.length(); | 341 index = instructions_.length(); |
317 instructions_.Add(instr, zone()); | 342 instructions_.Add(instr, zone()); |
318 } else { | 343 } else { |
319 index = instructions_.length(); | 344 index = instructions_.length(); |
320 instructions_.Add(instr, zone()); | 345 instructions_.Add(instr, zone()); |
321 instructions_.Add(gap, zone()); | 346 instructions_.Add(gap, zone()); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 | 644 |
620 | 645 |
621 LPhase::~LPhase() { | 646 LPhase::~LPhase() { |
622 if (ShouldProduceTraceOutput()) { | 647 if (ShouldProduceTraceOutput()) { |
623 isolate()->GetHTracer()->TraceLithium(name(), chunk_); | 648 isolate()->GetHTracer()->TraceLithium(name(), chunk_); |
624 } | 649 } |
625 } | 650 } |
626 | 651 |
627 | 652 |
628 } } // namespace v8::internal | 653 } } // namespace v8::internal |
OLD | NEW |