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

Unified Diff: src/lithium-allocator.cc

Issue 6352006: Remove instruction summaries and provide a LIR-interface for the register all... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: src/lithium-allocator.cc
===================================================================
--- src/lithium-allocator.cc (revision 6414)
+++ src/lithium-allocator.cc (working copy)
@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include "lithium-allocator.h"
+#include "lithium-allocator-inl.h"
#include "hydrogen.h"
#include "string-stream.h"
@@ -761,23 +761,23 @@
int end = block->last_instruction_index();
for (int i = start; i <= end; ++i) {
if (chunk_->IsGapAt(i)) {
- InstructionSummary* summary = NULL;
- InstructionSummary* prev_summary = NULL;
- if (i < end) summary = GetSummary(i + 1);
- if (i > start) prev_summary = GetSummary(i - 1);
- MeetConstraintsBetween(prev_summary, summary, i);
+ LInstruction* instr = NULL;
+ LInstruction* prev_instr = NULL;
+ if (i < end) instr = chunk_->instructions()->at(i + 1);
+ if (i > start) prev_instr = chunk_->instructions()->at(i - 1);
+ MeetConstraintsBetween(prev_instr, instr, i);
}
}
}
-void LAllocator::MeetConstraintsBetween(InstructionSummary* first,
- InstructionSummary* second,
+void LAllocator::MeetConstraintsBetween(LInstruction* first,
+ LInstruction* second,
int gap_index) {
// Handle fixed temporaries.
if (first != NULL) {
- for (int i = 0; i < first->TempCount(); ++i) {
- LUnallocated* temp = LUnallocated::cast(first->TempAt(i));
+ for (TempIterator it = first->GetTempIterator(); it.HasNext(); ) {
Kevin Millikin (Chromium) 2011/01/20 12:20:30 for (TempIterator it(first); it.HasNext(); it.Adva
fschneider 2011/01/20 17:13:08 Done.
+ LUnallocated* temp = LUnallocated::cast(it.Next());
Kevin Millikin (Chromium) 2011/01/20 12:20:30 There's an extra space after =.
fschneider 2011/01/20 17:13:08 Done.
if (temp->HasFixedPolicy()) {
AllocateFixed(temp, gap_index - 1, false);
}
@@ -818,8 +818,8 @@
// Handle fixed input operands of second instruction.
if (second != NULL) {
- for (int i = 0; i < second->InputCount(); ++i) {
- LUnallocated* cur_input = LUnallocated::cast(second->InputAt(i));
+ for (UseIterator it = second->GetUseIterator(); it.HasNext(); ) {
+ LUnallocated* cur_input = LUnallocated::cast(it.Next());
if (cur_input->HasFixedPolicy()) {
LUnallocated* input_copy = cur_input->CopyUnconstrained();
bool is_tagged = HasTaggedValue(cur_input->VirtualRegister());
@@ -848,7 +848,7 @@
if (second != NULL && second->Output() != NULL) {
LUnallocated* second_output = LUnallocated::cast(second->Output());
if (second_output->HasSameAsInputPolicy()) {
- LUnallocated* cur_input = LUnallocated::cast(second->InputAt(0));
+ LUnallocated* cur_input = LUnallocated::cast(second->FirstInput());
int output_vreg = second_output->VirtualRegister();
int input_vreg = cur_input->VirtualRegister();
@@ -923,16 +923,16 @@
}
} else {
ASSERT(!chunk_->IsGapAt(index));
- InstructionSummary* summary = GetSummary(index);
+ LInstruction* instr = chunk_->instructions()->at(index);
Kevin Millikin (Chromium) 2011/01/20 12:20:30 It might be easier to read and write these sites i
fschneider 2011/01/20 17:13:08 Done. Introduces InstructionAt and GapAt helpers.
- if (summary != NULL) {
- LOperand* output = summary->Output();
+ if (instr != NULL) {
+ LOperand* output = instr->Output();
if (output != NULL) {
if (output->IsUnallocated()) live->Remove(output->VirtualRegister());
Define(curr_position, output, NULL);
}
- if (summary->IsCall()) {
+ if (instr->IsMarkedAsCall()) {
for (int i = 0; i < Register::kNumAllocatableRegisters; ++i) {
if (output == NULL || !output->IsRegister() ||
output->index() != i) {
@@ -943,7 +943,7 @@
}
}
- if (summary->IsCall() || summary->IsSaveDoubles()) {
+ if (instr->IsMarkedAsCall() || instr->IsSaveDoubles()) {
for (int i = 0; i < DoubleRegister::kNumAllocatableRegisters; ++i) {
if (output == NULL || !output->IsDoubleRegister() ||
output->index() != i) {
@@ -954,8 +954,8 @@
}
}
- for (int i = 0; i < summary->InputCount(); ++i) {
- LOperand* input = summary->InputAt(i);
+ for (UseIterator it = instr->GetUseIterator(); it.HasNext(); ) {
+ LOperand* input = it.Next();
LifetimePosition use_pos;
if (input->IsUnallocated() &&
@@ -969,9 +969,9 @@
if (input->IsUnallocated()) live->Add(input->VirtualRegister());
}
- for (int i = 0; i < summary->TempCount(); ++i) {
- LOperand* temp = summary->TempAt(i);
- if (summary->IsCall()) {
+ for (TempIterator it = instr->GetTempIterator(); it.HasNext(); ) {
+ LOperand* temp = it.Next();
+ if (instr->IsMarkedAsCall()) {
if (temp->IsRegister()) continue;
if (temp->IsUnallocated()) {
LUnallocated* temp_unalloc = LUnallocated::cast(temp);
@@ -1558,12 +1558,6 @@
}
-void LAllocator::RecordUse(HValue* value, LUnallocated* operand) {
- operand->set_virtual_register(value->id());
- current_summary()->AddInput(operand);
-}
-
-
bool LAllocator::HasTaggedValue(int virtual_register) const {
HValue* value = graph()->LookupValue(virtual_register);
if (value == NULL) return false;
@@ -1586,39 +1580,8 @@
}
-void LAllocator::MarkAsCall() {
- // Call instructions can use only fixed registers as
- // temporaries and outputs because all registers
- // are blocked by the calling convention.
- // Inputs can use either fixed register or have a short lifetime (be
- // used at start of the instruction).
- InstructionSummary* summary = current_summary();
-#ifdef DEBUG
- ASSERT(summary->Output() == NULL ||
- LUnallocated::cast(summary->Output())->HasFixedPolicy() ||
- !LUnallocated::cast(summary->Output())->HasRegisterPolicy());
- for (int i = 0; i < summary->InputCount(); i++) {
- ASSERT(LUnallocated::cast(summary->InputAt(i))->HasFixedPolicy() ||
- LUnallocated::cast(summary->InputAt(i))->IsUsedAtStart() ||
- !LUnallocated::cast(summary->InputAt(i))->HasRegisterPolicy());
- }
- for (int i = 0; i < summary->TempCount(); i++) {
- ASSERT(LUnallocated::cast(summary->TempAt(i))->HasFixedPolicy() ||
- !LUnallocated::cast(summary->TempAt(i))->HasRegisterPolicy());
- }
-#endif
- summary->MarkAsCall();
-}
-
-
-void LAllocator::MarkAsSaveDoubles() {
- current_summary()->MarkAsSaveDoubles();
-}
-
-
void LAllocator::RecordDefinition(HInstruction* instr, LUnallocated* operand) {
operand->set_virtual_register(instr->id());
- current_summary()->SetOutput(operand);
}
@@ -1627,43 +1590,19 @@
if (!operand->HasFixedPolicy()) {
operand->set_virtual_register(next_virtual_register_++);
}
- current_summary()->AddTemp(operand);
}
-int LAllocator::max_initial_value_ids() {
- return LUnallocated::kMaxVirtualRegisters / 32;
+void LAllocator::RecordUse(HValue* value, LUnallocated* operand) {
+ operand->set_virtual_register(value->id());
}
-void LAllocator::BeginInstruction() {
- if (next_summary_ == NULL) {
- next_summary_ = new InstructionSummary();
- }
- summary_stack_.Add(next_summary_);
- next_summary_ = NULL;
+int LAllocator::max_initial_value_ids() {
+ return LUnallocated::kMaxVirtualRegisters / 32;
}
-void LAllocator::SummarizeInstruction(int index) {
- InstructionSummary* sum = summary_stack_.RemoveLast();
- if (summaries_.length() <= index) {
- summaries_.AddBlock(NULL, index + 1 - summaries_.length());
- }
- ASSERT(summaries_[index] == NULL);
- if (sum->Output() != NULL || sum->InputCount() > 0 || sum->TempCount() > 0) {
- summaries_[index] = sum;
- } else {
- next_summary_ = sum;
- }
-}
-
-
-void LAllocator::OmitInstruction() {
- summary_stack_.RemoveLast();
-}
-
-
void LAllocator::AddToActive(LiveRange* range) {
TraceAlloc("Add live range %d to active\n", range->id());
active_live_ranges_.Add(range);

Powered by Google App Engine
This is Rietveld 408576698