}
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 {
#include "lithium-allocator.h"
-#include "data-flow.h"
#include "hydrogen.h"
#include "string-stream.h"
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) {
} 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);
}
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;
}
#include "v8.h"
+#include "data-flow.h"
#include "zone.h"
namespace v8 {
};
+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)
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),
// 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_;