Reviewers: Kevin Millikin,
Description:
Remember required register kind when creating artificial virtual register.
Please review this at http://codereview.chromium.org/6065010/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/data-flow.h
M src/lithium-allocator.h
M src/lithium-allocator.cc
Index: src/data-flow.h
diff --git a/src/data-flow.h b/src/data-flow.h
index
6e2230c65ea5d3b2051a766aa62347c914cf61b9..79d760f5a4267433f41c7847482ac9e3acefcdf7
100644
--- a/src/data-flow.h
+++ b/src/data-flow.h
@@ -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 {
Index: src/lithium-allocator.cc
diff --git a/src/lithium-allocator.cc b/src/lithium-allocator.cc
index
ac61c17ba7685615fe49dd3f66928e291b9f69a8..bc5d6cc5f25af5892d5f0e43e555d8331ff994b5
100644
--- a/src/lithium-allocator.cc
+++ b/src/lithium-allocator.cc
@@ -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;
}
Index: src/lithium-allocator.h
diff --git a/src/lithium-allocator.h b/src/lithium-allocator.h
index
3ec984e262f9e397801f98bbfcb11430d2b3f4b1..5587961f2043a6e4dd10055c05dfc8de7d10e272
100644
--- a/src/lithium-allocator.h
+++ b/src/lithium-allocator.h
@@ -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 FlexibleBitVector BASE_EMBEDDED {
+ public:
+ FlexibleBitVector() : 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)
@@ -972,6 +1007,8 @@ class LAllocator BASE_EMBEDDED {
// Next virtual register number to be assigned to temporaries.
int next_virtual_register_;
+ int first_artificial_register_;
+ FlexibleBitVector double_artificial_registers_;
RegisterKind mode_;
int num_registers_;
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev