Revision: 6138
Author: [email protected]
Date: Mon Jan  3 09:02:15 2011
Log: Remember required register kind when creating artificial virtual register.

Review URL: http://codereview.chromium.org/6065010
http://code.google.com/p/v8/source/detail?r=6138

Modified:
 /branches/bleeding_edge/src/data-flow.h
 /branches/bleeding_edge/src/lithium-allocator.cc
 /branches/bleeding_edge/src/lithium-allocator.h

=======================================
--- /branches/bleeding_edge/src/data-flow.h     Tue Dec  7 03:31:57 2010
+++ /branches/bleeding_edge/src/data-flow.h     Mon Jan  3 09:02:15 2011
@@ -112,10 +112,13 @@
   }

   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 {
=======================================
--- /branches/bleeding_edge/src/lithium-allocator.cc Thu Dec 16 04:01:22 2010 +++ /branches/bleeding_edge/src/lithium-allocator.cc Mon Jan 3 09:02:15 2011
@@ -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::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 @@
       } 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 @@


 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;
 }

=======================================
--- /branches/bleeding_edge/src/lithium-allocator.h     Fri Dec 10 06:25:10 2010
+++ /branches/bleeding_edge/src/lithium-allocator.h     Mon Jan  3 09:02:15 2011
@@ -30,6 +30,7 @@

 #include "v8.h"

+#include "data-flow.h"
 #include "zone.h"

 namespace v8 {
@@ -754,6 +755,40 @@
 };


+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 @@
         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 @@

   // 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_;

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to