Commit 11d1188e authored by vegorov@chromium.org's avatar vegorov@chromium.org

Remember required register kind when creating artificial virtual register.

Review URL: http://codereview.chromium.org/6065010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6138 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c1fd8bcf
......@@ -112,10 +112,13 @@ class BitVector: public ZoneObject {
}
void CopyFrom(const BitVector& other) {
ASSERT(other.length() == length());
for (int i = 0; i < data_length_; i++) {
ASSERT(other.length() <= length());
for (int i = 0; i < other.data_length_; i++) {
data_[i] = other.data_[i];
}
for (int i = other.data_length_; i < data_length_; i++) {
data_[i] = 0;
}
}
bool Contains(int i) const {
......
......@@ -27,7 +27,6 @@
#include "lithium-allocator.h"
#include "data-flow.h"
#include "hydrogen.h"
#include "string-stream.h"
......@@ -763,6 +762,7 @@ void LAllocator::AddConstraintsGapMove(int index,
void LAllocator::MeetRegisterConstraints(HBasicBlock* block) {
first_artificial_register_ = next_virtual_register_;
int start = block->first_instruction_index();
int end = block->last_instruction_index();
for (int i = start; i <= end; ++i) {
......@@ -834,6 +834,13 @@ void LAllocator::MeetConstraintsBetween(InstructionSummary* first,
} else if (cur_input->policy() == LUnallocated::WRITABLE_REGISTER) {
LUnallocated* input_copy = cur_input->CopyUnconstrained();
cur_input->set_virtual_register(next_virtual_register_++);
if (RequiredRegisterKind(input_copy->virtual_register()) ==
DOUBLE_REGISTERS) {
double_artificial_registers_.Add(
cur_input->virtual_register() - first_artificial_register_);
}
second->AddTemp(cur_input);
AddConstraintsGapMove(gap_index, input_copy, cur_input);
}
......@@ -1564,10 +1571,16 @@ bool LAllocator::HasTaggedValue(int virtual_register) const {
RegisterKind LAllocator::RequiredRegisterKind(int virtual_register) const {
HValue* value = graph()->LookupValue(virtual_register);
if (value != NULL && value->representation().IsDouble()) {
if (virtual_register < first_artificial_register_) {
HValue* value = graph()->LookupValue(virtual_register);
if (value != NULL && value->representation().IsDouble()) {
return DOUBLE_REGISTERS;
}
} else if (double_artificial_registers_.Contains(
virtual_register - first_artificial_register_)) {
return DOUBLE_REGISTERS;
}
return GENERAL_REGISTERS;
}
......
......@@ -30,6 +30,7 @@
#include "v8.h"
#include "data-flow.h"
#include "zone.h"
namespace v8 {
......@@ -754,6 +755,40 @@ class LiveRange: public ZoneObject {
};
class GrowableBitVector BASE_EMBEDDED {
public:
GrowableBitVector() : bits_(NULL) { }
bool Contains(int value) const {
if (!InBitsRange(value)) return false;
return bits_->Contains(value);
}
void Add(int value) {
EnsureCapacity(value);
bits_->Add(value);
}
private:
static const int kInitialLength = 1024;
bool InBitsRange(int value) const {
return bits_ != NULL && bits_->length() > value;
}
void EnsureCapacity(int value) {
if (InBitsRange(value)) return;
int new_length = bits_ == NULL ? kInitialLength : bits_->length();
while (new_length <= value) new_length *= 2;
BitVector* new_bits = new BitVector(new_length);
if (bits_ != NULL) new_bits->CopyFrom(*bits_);
bits_ = new_bits;
}
BitVector* bits_;
};
class LAllocator BASE_EMBEDDED {
public:
explicit LAllocator(int first_virtual_register, HGraph* graph)
......@@ -770,6 +805,7 @@ class LAllocator BASE_EMBEDDED {
inactive_live_ranges_(8),
reusable_slots_(8),
next_virtual_register_(first_virtual_register),
first_artificial_register_(first_virtual_register),
mode_(NONE),
num_registers_(-1),
graph_(graph),
......@@ -972,6 +1008,8 @@ class LAllocator BASE_EMBEDDED {
// Next virtual register number to be assigned to temporaries.
int next_virtual_register_;
int first_artificial_register_;
GrowableBitVector double_artificial_registers_;
RegisterKind mode_;
int num_registers_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment