From a4283a544033fb36159fa07efbb63b8054af47f1 Mon Sep 17 00:00:00 2001 From: "fschneider@chromium.org" Date: Wed, 20 Apr 2011 09:08:26 +0000 Subject: [PATCH] Revert r7665. Review URL: http://codereview.chromium.org/6873106 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7670 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/lithium-arm.cc | 3 +++ src/arm/lithium-arm.h | 13 ++++--------- src/arm/lithium-codegen-arm.cc | 1 + src/ia32/lithium-codegen-ia32.cc | 1 + src/ia32/lithium-ia32.cc | 3 +++ src/ia32/lithium-ia32.h | 13 ++++--------- src/lithium-allocator.cc | 13 ++++++------- src/x64/lithium-codegen-x64.cc | 1 + src/x64/lithium-x64.cc | 3 +++ src/x64/lithium-x64.h | 13 ++++--------- 10 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index 2f6a558..faf6404 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -131,6 +131,7 @@ void OperandContainer::PrintOperandsTo(StringStream* stream) { void LLabel::PrintDataTo(StringStream* stream) { + LGap::PrintDataTo(stream); LLabel* rep = replacement(); if (rep != NULL) { stream->Add(" Dead block replaced with B%d", rep->block_id()); @@ -144,6 +145,7 @@ bool LGap::IsRedundant() const { return false; } } + return true; } @@ -428,6 +430,7 @@ void LChunk::MarkEmptyBlocks() { if (last_instr->IsGoto()) { LGoto* goto_instr = LGoto::cast(last_instr); if (!goto_instr->include_stack_check() && + label->IsRedundant() && !label->is_loop_header()) { bool can_eliminate = true; for (int i = first + 1; i < last && can_eliminate; ++i) { diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h index 6beb137..4add6bf 100644 --- a/src/arm/lithium-arm.h +++ b/src/arm/lithium-arm.h @@ -407,17 +407,17 @@ class LDeoptimize: public LTemplateInstruction<0, 0, 0> { }; -class LLabel: public LTemplateInstruction<0, 0, 0> { +class LLabel: public LGap { public: explicit LLabel(HBasicBlock* block) - : block_(block), replacement_(NULL) { } + : LGap(block), replacement_(NULL) { } DECLARE_CONCRETE_INSTRUCTION(Label, "label") virtual void PrintDataTo(StringStream* stream); - int block_id() const { return block_->block_id(); } - bool is_loop_header() const { return block_->IsLoopHeader(); } + int block_id() const { return block()->block_id(); } + bool is_loop_header() const { return block()->IsLoopHeader(); } Label* label() { return &label_; } LLabel* replacement() const { return replacement_; } void set_replacement(LLabel* label) { replacement_ = label; } @@ -425,7 +425,6 @@ class LLabel: public LTemplateInstruction<0, 0, 0> { private: Label label_; - HBasicBlock* block_; LLabel* replacement_; }; @@ -2023,10 +2022,6 @@ class LChunk: public ZoneObject { int first_instruction = block->first_instruction_index(); return LLabel::cast(instructions_[first_instruction]); } - LGap* GetFirstGap(HBasicBlock* block) const { - int first_instruction = block->first_instruction_index(); - return LGap::cast(instructions_[first_instruction + 1]); - } int LookupDestination(int block_id) const { LLabel* cur = GetLabel(block_id); while (cur->replacement() != NULL) { diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 83a2478..c820e2e 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -739,6 +739,7 @@ void LCodeGen::DoLabel(LLabel* label) { } __ bind(label->label()); current_block_ = label->block_id(); + LCodeGen::DoGap(label); } diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 387d1b5..46c71e8 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -689,6 +689,7 @@ void LCodeGen::DoLabel(LLabel* label) { } __ bind(label->label()); current_block_ = label->block_id(); + LCodeGen::DoGap(label); } diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index aa830c2..aa91a83 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -133,6 +133,7 @@ void OperandContainer::PrintOperandsTo(StringStream* stream) { void LLabel::PrintDataTo(StringStream* stream) { + LGap::PrintDataTo(stream); LLabel* rep = replacement(); if (rep != NULL) { stream->Add(" Dead block replaced with B%d", rep->block_id()); @@ -146,6 +147,7 @@ bool LGap::IsRedundant() const { return false; } } + return true; } @@ -386,6 +388,7 @@ void LChunk::MarkEmptyBlocks() { if (last_instr->IsGoto()) { LGoto* goto_instr = LGoto::cast(last_instr); if (!goto_instr->include_stack_check() && + label->IsRedundant() && !label->is_loop_header()) { bool can_eliminate = true; for (int i = first + 1; i < last && can_eliminate; ++i) { diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h index cb3d850..76c90be 100644 --- a/src/ia32/lithium-ia32.h +++ b/src/ia32/lithium-ia32.h @@ -409,17 +409,17 @@ class LDeoptimize: public LTemplateInstruction<0, 0, 0> { }; -class LLabel: public LTemplateInstruction<0, 0, 0> { +class LLabel: public LGap { public: explicit LLabel(HBasicBlock* block) - : block_(block), replacement_(NULL) { } + : LGap(block), replacement_(NULL) { } DECLARE_CONCRETE_INSTRUCTION(Label, "label") virtual void PrintDataTo(StringStream* stream); - int block_id() const { return block_->block_id(); } - bool is_loop_header() const { return block_->IsLoopHeader(); } + int block_id() const { return block()->block_id(); } + bool is_loop_header() const { return block()->IsLoopHeader(); } Label* label() { return &label_; } LLabel* replacement() const { return replacement_; } void set_replacement(LLabel* label) { replacement_ = label; } @@ -427,7 +427,6 @@ class LLabel: public LTemplateInstruction<0, 0, 0> { private: Label label_; - HBasicBlock* block_; LLabel* replacement_; }; @@ -2082,10 +2081,6 @@ class LChunk: public ZoneObject { int first_instruction = block->first_instruction_index(); return LLabel::cast(instructions_[first_instruction]); } - LGap* GetFirstGap(HBasicBlock* block) const { - int first_instruction = block->first_instruction_index(); - return LGap::cast(instructions_[first_instruction + 1]); - } int LookupDestination(int block_id) const { LLabel* cur = GetLabel(block_id); while (cur->replacement() != NULL) { diff --git a/src/lithium-allocator.cc b/src/lithium-allocator.cc index 911e70d..a42d522 100644 --- a/src/lithium-allocator.cc +++ b/src/lithium-allocator.cc @@ -1047,10 +1047,9 @@ void LAllocator::ResolvePhis(HBasicBlock* block) { } } - // Insert spill-move in the first section of the first gap. LiveRange* live_range = LiveRangeFor(phi->id()); - LGap* gap = chunk_->GetFirstGap(phi->block()); - gap->GetOrCreateParallelMove(LGap::BEFORE)-> + LLabel* label = chunk_->GetLabel(phi->block()->block_id()); + label->GetOrCreateParallelMove(LGap::START)-> AddMove(phi_operand, live_range->GetSpillOperand()); live_range->SetSpillStartIndex(phi->block()->first_instruction_index()); } @@ -1123,12 +1122,12 @@ void LAllocator::ResolveControlFlow(LiveRange* range, LOperand* pred_op = pred_cover->CreateAssignedOperand(); LOperand* cur_op = cur_cover->CreateAssignedOperand(); if (!pred_op->Equals(cur_op)) { + LGap* gap = NULL; if (block->predecessors()->length() == 1) { - LGap* gap = chunk_->GetFirstGap(block); - gap->GetOrCreateParallelMove(LGap::BEFORE)->AddMove(pred_op, cur_op); + gap = GapAt(block->first_instruction_index()); } else { ASSERT(pred->end()->SecondSuccessor() == NULL); - LGap* gap = GetLastGap(pred); + gap = GetLastGap(pred); // We are going to insert a move before the branch instruction. // Some branch instructions (e.g. loops' back edges) @@ -1144,8 +1143,8 @@ void LAllocator::ResolveControlFlow(LiveRange* range, branch->pointer_map()->RecordPointer(cur_op); } } - gap->GetOrCreateParallelMove(LGap::START)->AddMove(pred_op, cur_op); } + gap->GetOrCreateParallelMove(LGap::START)->AddMove(pred_op, cur_op); } } } diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index f2e6b25..c242874 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -690,6 +690,7 @@ void LCodeGen::DoLabel(LLabel* label) { } __ bind(label->label()); current_block_ = label->block_id(); + LCodeGen::DoGap(label); } diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index ccb2313..620bbc9 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -133,6 +133,7 @@ void OperandContainer::PrintOperandsTo(StringStream* stream) { void LLabel::PrintDataTo(StringStream* stream) { + LGap::PrintDataTo(stream); LLabel* rep = replacement(); if (rep != NULL) { stream->Add(" Dead block replaced with B%d", rep->block_id()); @@ -146,6 +147,7 @@ bool LGap::IsRedundant() const { return false; } } + return true; } @@ -385,6 +387,7 @@ void LChunk::MarkEmptyBlocks() { if (last_instr->IsGoto()) { LGoto* goto_instr = LGoto::cast(last_instr); if (!goto_instr->include_stack_check() && + label->IsRedundant() && !label->is_loop_header()) { bool can_eliminate = true; for (int i = first + 1; i < last && can_eliminate; ++i) { diff --git a/src/x64/lithium-x64.h b/src/x64/lithium-x64.h index 04b04e6..74f4820 100644 --- a/src/x64/lithium-x64.h +++ b/src/x64/lithium-x64.h @@ -408,17 +408,17 @@ class LDeoptimize: public LTemplateInstruction<0, 0, 0> { }; -class LLabel: public LTemplateInstruction<0, 0, 0> { +class LLabel: public LGap { public: explicit LLabel(HBasicBlock* block) - : block_(block), replacement_(NULL) { } + : LGap(block), replacement_(NULL) { } DECLARE_CONCRETE_INSTRUCTION(Label, "label") virtual void PrintDataTo(StringStream* stream); - int block_id() const { return block_->block_id(); } - bool is_loop_header() const { return block_->IsLoopHeader(); } + int block_id() const { return block()->block_id(); } + bool is_loop_header() const { return block()->IsLoopHeader(); } Label* label() { return &label_; } LLabel* replacement() const { return replacement_; } void set_replacement(LLabel* label) { replacement_ = label; } @@ -426,7 +426,6 @@ class LLabel: public LTemplateInstruction<0, 0, 0> { private: Label label_; - HBasicBlock* block_; LLabel* replacement_; }; @@ -2005,10 +2004,6 @@ class LChunk: public ZoneObject { int first_instruction = block->first_instruction_index(); return LLabel::cast(instructions_[first_instruction]); } - LGap* GetFirstGap(HBasicBlock* block) const { - int first_instruction = block->first_instruction_index(); - return LGap::cast(instructions_[first_instruction + 1]); - } int LookupDestination(int block_id) const { LLabel* cur = GetLabel(block_id); while (cur->replacement() != NULL) { -- 2.7.4