Author: [email protected]
Date: Tue May 19 06:26:02 2009
New Revision: 2000

Modified:
    branches/bleeding_edge/src/jump-target.cc
    branches/bleeding_edge/src/list-inl.h
    branches/bleeding_edge/src/list.h
    branches/bleeding_edge/src/virtual-frame.cc

Log:
Introduced copy constructor for List<T, P> and changed constructor of  
VirtualFrame to use it.

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

Modified: branches/bleeding_edge/src/jump-target.cc
==============================================================================
--- branches/bleeding_edge/src/jump-target.cc   (original)
+++ branches/bleeding_edge/src/jump-target.cc   Tue May 19 06:26:02 2009
@@ -484,13 +484,8 @@
  void BreakTarget::CopyTo(BreakTarget* destination) {
    ASSERT(destination != NULL);
    destination->direction_ = direction_;
-  destination->reaching_frames_.Clear();
-  destination->merge_labels_.Clear();
-  ASSERT(reaching_frames_.length() == merge_labels_.length());
-  for (int i = 0; i < reaching_frames_.length(); i++) {
-    destination->reaching_frames_.Add(reaching_frames_[i]);
-    destination->merge_labels_.Add(merge_labels_[i]);
-  }
+  destination->reaching_frames_ = reaching_frames_;
+  destination->merge_labels_ = merge_labels_;
    destination->entry_frame_ = entry_frame_;
    destination->entry_label_ = entry_label_;
    destination->expected_height_ = expected_height_;

Modified: branches/bleeding_edge/src/list-inl.h
==============================================================================
--- branches/bleeding_edge/src/list-inl.h       (original)
+++ branches/bleeding_edge/src/list-inl.h       Tue May 19 06:26:02 2009
@@ -34,6 +34,26 @@


  template<typename T, class P>
+List<T, P>::List(const List<T, P>& other) {
+  ASSERT(other.capacity() >= 0);
+  capacity_ = other.capacity();
+  length_ = other.length();
+  if (capacity_ > 0) {
+    data_ = NewData(capacity_);
+    int copy_size = length_ * sizeof(T);
+    const int kMinMemCpySize = 64;
+    if (copy_size < kMinMemCpySize) {
+      for (int i = 0; i < length_; i++) data_[i] = other.data_[i];
+    } else {
+      memcpy(data_, other.data_, copy_size);
+    }
+  } else {
+    data_ = NULL;
+  }
+}
+
+
+template<typename T, class P>
  void List<T, P>::Add(const T& element) {
    if (length_ < capacity_) {
      data_[length_++] = element;

Modified: branches/bleeding_edge/src/list.h
==============================================================================
--- branches/bleeding_edge/src/list.h   (original)
+++ branches/bleeding_edge/src/list.h   Tue May 19 06:26:02 2009
@@ -48,6 +48,7 @@
   public:

    INLINE(explicit List(int capacity)) { Initialize(capacity); }
+  INLINE(explicit List(const List<T, P>& other));
    INLINE(~List()) { DeleteData(data_); }

    INLINE(void* operator new(size_t size)) { return P::New(size); }
@@ -125,8 +126,6 @@
    // Inlined implementation of ResizeAdd, shared by inlined and
    // non-inlined versions of ResizeAdd.
    void ResizeAddInternal(const T& element);
-
-  DISALLOW_COPY_AND_ASSIGN(List);
  };

  class FrameElement;

Modified: branches/bleeding_edge/src/virtual-frame.cc
==============================================================================
--- branches/bleeding_edge/src/virtual-frame.cc (original)
+++ branches/bleeding_edge/src/virtual-frame.cc Tue May 19 06:26:02 2009
@@ -39,18 +39,15 @@
  VirtualFrame::VirtualFrame(VirtualFrame* original)
      : cgen_(original->cgen_),
        masm_(original->masm_),
-      elements_(original->elements_.capacity()),
+      elements_(original->elements_),
        parameter_count_(original->parameter_count_),
        local_count_(original->local_count_),
        stack_pointer_(original->stack_pointer_),
        frame_pointer_(original->frame_pointer_) {
-  // Copy all the elements from the original.
-  for (int i = 0; i < original->elements_.length(); i++) {
-    elements_.Add(original->elements_[i]);
-  }
-  for (int i = 0; i < kNumRegisters; i++) {
-    register_locations_[i] = original->register_locations_[i];
-  }
+  // Copy register locations from original.
+  memcpy(&register_locations_,
+         original->register_locations_,
+         sizeof(register_locations_));
  }



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

Reply via email to