Reviewers: Søren Gjesse,

Description:
Heap profiler: skip byte arrays that represent free list blocks when  
counting
allocated objects.

This is the one cause of the problem reported in http://crbug/23623. Also it
will be needed to change the way the total heap size is reported by using
Heap::CommittedMemory introduced in http://codereview.chromium.org/261037.

BUG=http://crbug/23623

Please review this at http://codereview.chromium.org/306001

Affected files:
   M src/heap-profiler.cc
   M src/spaces-inl.h
   M src/spaces.h
   M src/spaces.cc


Index: src/heap-profiler.cc
diff --git a/src/heap-profiler.cc b/src/heap-profiler.cc
index  
8f55ce1ce49356b581a6d56731e37e91638e191d..f80c9a07bf97182386dd921e99b2c14cf521e73f
  
100644
--- a/src/heap-profiler.cc
+++ b/src/heap-profiler.cc
@@ -576,8 +576,10 @@ void RetainerHeapProfile::PrintStats() {
  void HeapProfiler::CollectStats(HeapObject* obj, HistogramInfo* info) {
    InstanceType type = obj->map()->instance_type();
    ASSERT(0 <= type && type <= LAST_TYPE);
-  info[type].increment_number(1);
-  info[type].increment_bytes(obj->Size());
+  if (!FreeListNode::IsFreeListNode(obj)) {
+    info[type].increment_number(1);
+    info[type].increment_bytes(obj->Size());
+  }
  }


Index: src/spaces-inl.h
diff --git a/src/spaces-inl.h b/src/spaces-inl.h
index  
da7249792b53bc86503324f95d35235b6a10bdb5..be7bdc39f94396f39487b9ad32c243c8aad7c4d1
  
100644
--- a/src/spaces-inl.h
+++ b/src/spaces-inl.h
@@ -360,6 +360,12 @@ Object* NewSpace::AllocateRawInternal(int  
size_in_bytes,
    return obj;
  }

+
+bool FreeListNode::IsFreeListNode(HeapObject* object) {
+  return object->map() == Heap::raw_unchecked_byte_array_map() ||
+    object->map() == Heap::raw_unchecked_two_pointer_filler_map();
+}
+
  } }  // namespace v8::internal

  #endif  // V8_SPACES_INL_H_
Index: src/spaces.cc
diff --git a/src/spaces.cc b/src/spaces.cc
index  
43abaa499931de9dff2a948a1caf901663620779..7014172655b75414b2cf63b5e0c50d0759336726
  
100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -1540,8 +1540,7 @@ void FreeListNode::set_size(int size_in_bytes) {


  Address FreeListNode::next() {
-  ASSERT(map() == Heap::raw_unchecked_byte_array_map() ||
-         map() == Heap::raw_unchecked_two_pointer_filler_map());
+  ASSERT(IsFreeListNode(this));
    if (map() == Heap::raw_unchecked_byte_array_map()) {
      ASSERT(Size() >= kNextOffset + kPointerSize);
      return Memory::Address_at(address() + kNextOffset);
@@ -1552,8 +1551,7 @@ Address FreeListNode::next() {


  void FreeListNode::set_next(Address next) {
-  ASSERT(map() == Heap::raw_unchecked_byte_array_map() ||
-         map() == Heap::raw_unchecked_two_pointer_filler_map());
+  ASSERT(IsFreeListNode(this));
    if (map() == Heap::raw_unchecked_byte_array_map()) {
      ASSERT(Size() >= kNextOffset + kPointerSize);
      Memory::Address_at(address() + kNextOffset) = next;
Index: src/spaces.h
diff --git a/src/spaces.h b/src/spaces.h
index  
76b88ef7f0c1423ef9896a7e602812879ed3d79d..a51a667b315ad2f1e274782906768bcd0f179317
  
100644
--- a/src/spaces.h
+++ b/src/spaces.h
@@ -1423,6 +1423,8 @@ class FreeListNode: public HeapObject {
      return  
reinterpret_cast<FreeListNode*>(HeapObject::FromAddress(address));
    }

+  static inline bool IsFreeListNode(HeapObject* object);
+
    // Set the size in bytes, which can be read with HeapObject::Size().   
This
    // function also writes a map to the first word of the block so that it
    // looks like a heap object to the garbage collector and heap iteration



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

Reply via email to