Author: [email protected]
Date: Thu May 14 09:06:04 2009
New Revision: 1954

Modified:
    branches/bleeding_edge/src/arm/virtual-frame-arm.h
    branches/bleeding_edge/src/ia32/virtual-frame-ia32.h
    branches/bleeding_edge/src/register-allocator.cc
    branches/bleeding_edge/src/register-allocator.h
    branches/bleeding_edge/src/virtual-frame.cc
    branches/bleeding_edge/src/x64/virtual-frame-x64.h

Log:
Improve algorithm for detaching and attaching a virtual frame to the code
generator.  Inline copying of a register file.
Review URL: http://codereview.chromium.org/113402

Modified: branches/bleeding_edge/src/arm/virtual-frame-arm.h
==============================================================================
--- branches/bleeding_edge/src/arm/virtual-frame-arm.h  (original)
+++ branches/bleeding_edge/src/arm/virtual-frame-arm.h  Thu May 14 09:06:04  
2009
@@ -127,13 +127,29 @@
    // tells the register allocator that it is free to use frame-internal
    // registers.  Used when the code generator's frame is switched from this
    // one to NULL by an unconditional jump.
-  void DetachFromCodeGenerator();
+  void DetachFromCodeGenerator() {
+    RegisterAllocator* cgen_allocator = cgen_->allocator();
+    for (int i = 0; i < kNumRegisters; i++) {
+      if (is_used(i)) {
+        Register temp = { i };
+        cgen_allocator->Unuse(temp);
+      }
+    }
+  }

    // (Re)attach a frame to its code generator.  This informs the register
    // allocator that the frame-internal register references are active  
again.
    // Used when a code generator's frame is switched from NULL to this one  
by
    // binding a label.
-  void AttachToCodeGenerator();
+  void AttachToCodeGenerator() {
+    RegisterAllocator* cgen_allocator = cgen_->allocator();
+    for (int i = 0; i < kNumRegisters; i++) {
+      if (is_used(i)) {
+        Register temp = { i };
+        cgen_allocator->Use(temp);
+      }
+    }
+  }

    // Emit code for the physical JS entry and exit frame sequences.  After
    // calling Enter, the virtual frame is ready for use; and after calling

Modified: branches/bleeding_edge/src/ia32/virtual-frame-ia32.h
==============================================================================
--- branches/bleeding_edge/src/ia32/virtual-frame-ia32.h        (original)
+++ branches/bleeding_edge/src/ia32/virtual-frame-ia32.h        Thu May 14  
09:06:04 2009
@@ -130,13 +130,29 @@
    // tells the register allocator that it is free to use frame-internal
    // registers.  Used when the code generator's frame is switched from this
    // one to NULL by an unconditional jump.
-  void DetachFromCodeGenerator();
+  void DetachFromCodeGenerator() {
+    RegisterAllocator* cgen_allocator = cgen_->allocator();
+    for (int i = 0; i < kNumRegisters; i++) {
+      if (is_used(i)) {
+        Register temp = { i };
+        cgen_allocator->Unuse(temp);
+      }
+    }
+  }

    // (Re)attach a frame to its code generator.  This informs the register
    // allocator that the frame-internal register references are active  
again.
    // Used when a code generator's frame is switched from NULL to this one  
by
    // binding a label.
-  void AttachToCodeGenerator();
+  void AttachToCodeGenerator() {
+    RegisterAllocator* cgen_allocator = cgen_->allocator();
+    for (int i = 0; i < kNumRegisters; i++) {
+      if (is_used(i)) {
+        Register temp = { i };
+        cgen_allocator->Use(temp);
+      }
+    }
+  }

    // Emit code for the physical JS entry and exit frame sequences.  After
    // calling Enter, the virtual frame is ready for use; and after calling

Modified: branches/bleeding_edge/src/register-allocator.cc
==============================================================================
--- branches/bleeding_edge/src/register-allocator.cc    (original)
+++ branches/bleeding_edge/src/register-allocator.cc    Thu May 14 09:06:04  
2009
@@ -72,16 +72,6 @@


  //  
-------------------------------------------------------------------------
-// RegisterFile implementation.
-
-void RegisterFile::CopyTo(RegisterFile* other) {
-  for (int i = 0; i < kNumRegisters; i++) {
-    other->ref_counts_[i] = ref_counts_[i];
-  }
-}
-
-
-//  
-------------------------------------------------------------------------
  // RegisterAllocator implementation.



Modified: branches/bleeding_edge/src/register-allocator.h
==============================================================================
--- branches/bleeding_edge/src/register-allocator.h     (original)
+++ branches/bleeding_edge/src/register-allocator.h     Thu May 14 09:06:04 2009
@@ -243,7 +243,11 @@
    }

    // Copy the reference counts from this register file to the other.
-  void CopyTo(RegisterFile* other);
+  void CopyTo(RegisterFile* other) {
+    for (int i = 0; i < kNumRegisters; i++) {
+      other->ref_counts_[i] = ref_counts_[i];
+    }
+  }

   private:
    int ref_counts_[kNumRegisters];

Modified: branches/bleeding_edge/src/virtual-frame.cc
==============================================================================
--- branches/bleeding_edge/src/virtual-frame.cc (original)
+++ branches/bleeding_edge/src/virtual-frame.cc Thu May 14 09:06:04 2009
@@ -304,30 +304,6 @@
  }


-void VirtualFrame::DetachFromCodeGenerator() {
-  // Tell the global register allocator that it is free to reallocate all
-  // register references contained in this frame.  The frame elements  
remain
-  // register references, so the frame-internal reference count is not
-  // decremented.
-  for (int i = 0; i < elements_.length(); i++) {
-    if (elements_[i].is_register()) {
-      cgen_->allocator()->Unuse(elements_[i].reg());
-    }
-  }
-}
-
-
-void VirtualFrame::AttachToCodeGenerator() {
-  // Tell the global register allocator that the frame-internal register
-  // references are live again.
-  for (int i = 0; i < elements_.length(); i++) {
-    if (elements_[i].is_register()) {
-      cgen_->allocator()->Use(elements_[i].reg());
-    }
-  }
-}
-
-
  void VirtualFrame::PrepareForReturn() {
    // Spill all locals. This is necessary to make sure all locals have
    // the right value when breaking at the return site in the debugger.

Modified: branches/bleeding_edge/src/x64/virtual-frame-x64.h
==============================================================================
--- branches/bleeding_edge/src/x64/virtual-frame-x64.h  (original)
+++ branches/bleeding_edge/src/x64/virtual-frame-x64.h  Thu May 14 09:06:04  
2009
@@ -130,13 +130,28 @@
    // tells the register allocator that it is free to use frame-internal
    // registers.  Used when the code generator's frame is switched from this
    // one to NULL by an unconditional jump.
-  void DetachFromCodeGenerator();
-
+  void DetachFromCodeGenerator() {
+    RegisterAllocator* cgen_allocator = cgen_->allocator();
+    for (int i = 0; i < kNumRegisters; i++) {
+      if (is_used(i)) {
+        Register temp = { i };
+        cgen_allocator->Unuse(temp);
+      }
+    }
+  }
    // (Re)attach a frame to its code generator.  This informs the register
    // allocator that the frame-internal register references are active  
again.
    // Used when a code generator's frame is switched from NULL to this one  
by
    // binding a label.
-  void AttachToCodeGenerator();
+  void AttachToCodeGenerator() {
+    RegisterAllocator* cgen_allocator = cgen_->allocator();
+    for (int i = 0; i < kNumRegisters; i++) {
+      if (is_used(i)) {
+        Register temp = { i };
+        cgen_allocator->Use(temp);
+      }
+    }
+  }

    // Emit code for the physical JS entry and exit frame sequences.  After
    // calling Enter, the virtual frame is ready for use; and after calling

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

Reply via email to