Author: [email protected]
Date: Fri May  1 07:37:28 2009
New Revision: 1835

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

Log:
Stop inlining of list reallocation in virtual frames.
Review URL: http://codereview.chromium.org/100253

Modified: branches/bleeding_edge/src/list-inl.h
==============================================================================
--- branches/bleeding_edge/src/list-inl.h       (original)
+++ branches/bleeding_edge/src/list-inl.h       Fri May  1 07:37:28 2009
@@ -1,4 +1,4 @@
-// Copyright 2006-2008 the V8 project authors. All rights reserved.
+// Copyright 2006-2009 the V8 project authors. All rights reserved.
  // Redistribution and use in source and binary forms, with or without
  // modification, are permitted provided that the following conditions are
  // met:
@@ -38,18 +38,33 @@
    if (length_ < capacity_) {
      data_[length_++] = element;
    } else {
-    // Grow the list capacity by 50%, but make sure to let it grow
-    // even when the capacity is zero (possible initial case).
-    int new_capacity = 1 + capacity_ + (capacity_ >> 1);
-    T* new_data = NewData(new_capacity);
-    memcpy(new_data, data_, capacity_ * sizeof(T));
-    // Since the element reference could be an element of the list,
-    // assign it to the new backing store before deleting the old.
-    new_data[length_++] = element;
-    DeleteData(data_);
-    data_ = new_data;
-    capacity_ = new_capacity;
+    List<T, P>::ResizeAdd(element);
    }
+}
+
+
+// Use two layers of inlining so that the non-inlined function can
+// use the same implementation as the inlined version.
+template<typename T, class P>
+void List<T, P>::ResizeAdd(const T& element) {
+  ResizeAddInternal(element);
+}
+
+
+template<typename T, class P>
+void List<T, P>::ResizeAddInternal(const T& element) {
+  ASSERT(length_ >= capacity_);
+  // Grow the list capacity by 50%, but make sure to let it grow
+  // even when the capacity is zero (possible initial case).
+  int new_capacity = 1 + capacity_ + (capacity_ >> 1);
+  T* new_data = List<T, P>::NewData(new_capacity);
+  memcpy(new_data, data_, capacity_ * sizeof(T));
+  // Since the element reference could be an element of the list,
+  // assign it to the new backing store before deleting the old.
+  new_data[length_++] = element;
+  List<T, P>::DeleteData(data_);
+  data_ = new_data;
+  capacity_ = new_capacity;
  }



Modified: branches/bleeding_edge/src/list.h
==============================================================================
--- branches/bleeding_edge/src/list.h   (original)
+++ branches/bleeding_edge/src/list.h   Fri May  1 07:37:28 2009
@@ -118,9 +118,24 @@
    INLINE(T* NewData(int n))  { return static_cast<T*>(P::New(n *  
sizeof(T))); }
    INLINE(void DeleteData(T* data))  { P::Delete(data); }

+  // Increase the capacity of a full list, and add an element.
+  // List must be full already.
+  void ResizeAdd(const T& element);
+
+  // 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;
+
+// Add() is inlined, ResizeAdd() called by Add() is inlined except for
+// Lists of FrameElements, and ResizeAddInternal() is inlined in  
ResizeAdd().
+template <>
+void List<FrameElement,
+          FreeStoreAllocationPolicy>::ResizeAdd(const FrameElement&  
element);

  } }  // namespace v8::internal


Modified: branches/bleeding_edge/src/virtual-frame.cc
==============================================================================
--- branches/bleeding_edge/src/virtual-frame.cc (original)
+++ branches/bleeding_edge/src/virtual-frame.cc Fri May  1 07:37:28 2009
@@ -507,4 +507,14 @@
    return true;
  }

+
+// Specialization of List::ResizeAdd to non-inlined version for  
FrameElements.
+// The function ResizeAdd becomes a real function, whose implementation is  
the
+// inlined ResizeAddInternal.
+template <>
+void List<FrameElement,
+          FreeStoreAllocationPolicy>::ResizeAdd(const FrameElement&  
element) {
+  ResizeAddInternal(element);
+}
+
  } }  // namespace v8::internal

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

Reply via email to