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/compiler/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
6 #include "src/compiler/graph.h" | 6 #include "src/compiler/graph.h" |
7 #include "src/compiler/instruction.h" | 7 #include "src/compiler/instruction.h" |
8 #include "src/compiler/schedule.h" | 8 #include "src/compiler/schedule.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 396 |
397 | 397 |
398 void PhiInstruction::SetInput(size_t offset, int virtual_register) { | 398 void PhiInstruction::SetInput(size_t offset, int virtual_register) { |
399 DCHECK_EQ(InstructionOperand::kInvalidVirtualRegister, operands_[offset]); | 399 DCHECK_EQ(InstructionOperand::kInvalidVirtualRegister, operands_[offset]); |
400 operands_[offset] = virtual_register; | 400 operands_[offset] = virtual_register; |
401 } | 401 } |
402 | 402 |
403 | 403 |
404 InstructionBlock::InstructionBlock(Zone* zone, RpoNumber rpo_number, | 404 InstructionBlock::InstructionBlock(Zone* zone, RpoNumber rpo_number, |
405 RpoNumber loop_header, RpoNumber loop_end, | 405 RpoNumber loop_header, RpoNumber loop_end, |
406 bool deferred) | 406 bool deferred, bool handler) |
407 : successors_(zone), | 407 : successors_(zone), |
408 predecessors_(zone), | 408 predecessors_(zone), |
409 phis_(zone), | 409 phis_(zone), |
410 ao_number_(rpo_number), | 410 ao_number_(rpo_number), |
411 rpo_number_(rpo_number), | 411 rpo_number_(rpo_number), |
412 loop_header_(loop_header), | 412 loop_header_(loop_header), |
413 loop_end_(loop_end), | 413 loop_end_(loop_end), |
414 code_start_(-1), | 414 code_start_(-1), |
415 code_end_(-1), | 415 code_end_(-1), |
416 deferred_(deferred), | 416 deferred_(deferred), |
| 417 handler_(handler), |
417 needs_frame_(false), | 418 needs_frame_(false), |
418 must_construct_frame_(false), | 419 must_construct_frame_(false), |
419 must_deconstruct_frame_(false) {} | 420 must_deconstruct_frame_(false) {} |
420 | 421 |
421 | 422 |
422 size_t InstructionBlock::PredecessorIndexOf(RpoNumber rpo_number) const { | 423 size_t InstructionBlock::PredecessorIndexOf(RpoNumber rpo_number) const { |
423 size_t j = 0; | 424 size_t j = 0; |
424 for (InstructionBlock::Predecessors::const_iterator i = predecessors_.begin(); | 425 for (InstructionBlock::Predecessors::const_iterator i = predecessors_.begin(); |
425 i != predecessors_.end(); ++i, ++j) { | 426 i != predecessors_.end(); ++i, ++j) { |
426 if (*i == rpo_number) break; | 427 if (*i == rpo_number) break; |
427 } | 428 } |
428 return j; | 429 return j; |
429 } | 430 } |
430 | 431 |
431 | 432 |
432 static RpoNumber GetRpo(const BasicBlock* block) { | 433 static RpoNumber GetRpo(const BasicBlock* block) { |
433 if (block == NULL) return RpoNumber::Invalid(); | 434 if (block == NULL) return RpoNumber::Invalid(); |
434 return RpoNumber::FromInt(block->rpo_number()); | 435 return RpoNumber::FromInt(block->rpo_number()); |
435 } | 436 } |
436 | 437 |
437 | 438 |
438 static RpoNumber GetLoopEndRpo(const BasicBlock* block) { | 439 static RpoNumber GetLoopEndRpo(const BasicBlock* block) { |
439 if (!block->IsLoopHeader()) return RpoNumber::Invalid(); | 440 if (!block->IsLoopHeader()) return RpoNumber::Invalid(); |
440 return RpoNumber::FromInt(block->loop_end()->rpo_number()); | 441 return RpoNumber::FromInt(block->loop_end()->rpo_number()); |
441 } | 442 } |
442 | 443 |
443 | 444 |
444 static InstructionBlock* InstructionBlockFor(Zone* zone, | 445 static InstructionBlock* InstructionBlockFor(Zone* zone, |
445 const BasicBlock* block) { | 446 const BasicBlock* block) { |
| 447 bool is_handler = |
| 448 !block->empty() && block->front()->opcode() == IrOpcode::kIfException; |
446 InstructionBlock* instr_block = new (zone) | 449 InstructionBlock* instr_block = new (zone) |
447 InstructionBlock(zone, GetRpo(block), GetRpo(block->loop_header()), | 450 InstructionBlock(zone, GetRpo(block), GetRpo(block->loop_header()), |
448 GetLoopEndRpo(block), block->deferred()); | 451 GetLoopEndRpo(block), block->deferred(), is_handler); |
449 // Map successors and precessors | 452 // Map successors and precessors |
450 instr_block->successors().reserve(block->SuccessorCount()); | 453 instr_block->successors().reserve(block->SuccessorCount()); |
451 for (BasicBlock* successor : block->successors()) { | 454 for (BasicBlock* successor : block->successors()) { |
452 instr_block->successors().push_back(GetRpo(successor)); | 455 instr_block->successors().push_back(GetRpo(successor)); |
453 } | 456 } |
454 instr_block->predecessors().reserve(block->PredecessorCount()); | 457 instr_block->predecessors().reserve(block->PredecessorCount()); |
455 for (BasicBlock* predecessor : block->predecessors()) { | 458 for (BasicBlock* predecessor : block->predecessors()) { |
456 instr_block->predecessors().push_back(GetRpo(predecessor)); | 459 instr_block->predecessors().push_back(GetRpo(predecessor)); |
457 } | 460 } |
458 return instr_block; | 461 return instr_block; |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 os << " B" << succ.ToInt(); | 805 os << " B" << succ.ToInt(); |
803 } | 806 } |
804 os << "\n"; | 807 os << "\n"; |
805 } | 808 } |
806 return os; | 809 return os; |
807 } | 810 } |
808 | 811 |
809 } // namespace compiler | 812 } // namespace compiler |
810 } // namespace internal | 813 } // namespace internal |
811 } // namespace v8 | 814 } // namespace v8 |
OLD | NEW |