Author: whessev8
Date: Tue Nov  4 05:05:56 2008
New Revision: 688

Modified:
    branches/bleeding_edge/src/mark-compact.cc
    branches/bleeding_edge/src/mark-compact.h
    branches/bleeding_edge/src/v8-counters.h

Log:
Code cleanup & simplification.
Moves the calls to tracer and UpdateLiveObjectCount inside the call to
(inlined) SetMark.  Removes global object counter.
Review URL: http://codereview.chromium.org/8910

Modified: branches/bleeding_edge/src/mark-compact.cc
==============================================================================
--- branches/bleeding_edge/src/mark-compact.cc  (original)
+++ branches/bleeding_edge/src/mark-compact.cc  Tue Nov  4 05:05:56 2008
@@ -152,8 +152,6 @@
      space->PrepareForMarkCompact(compacting_collection_);
    }

-  Counters::global_objects.Set(0);
-
  #ifdef DEBUG
    live_bytes_ = 0;
    live_young_objects_ = 0;
@@ -327,12 +325,10 @@
    void VisitUnmarkedObject(HeapObject* obj) {
  #ifdef DEBUG
      ASSERT(Heap::Contains(obj));
-    MarkCompactCollector::UpdateLiveObjectCount(obj);
      ASSERT(!obj->IsMarked());
  #endif
      Map* map = obj->map();
-    obj->SetMark();
-    MarkCompactCollector::tracer()->increment_marked_count();
+    MarkCompactCollector::SetMark(obj);
      // Mark the map pointer and the body.
      MarkCompactCollector::MarkObject(map);
      obj->IterateBody(map->instance_type(), obj->SizeFromMap(map), this);
@@ -380,13 +376,9 @@
      HeapObject* object = ShortCircuitConsString(p);
      if (object->IsMarked()) return;

-#ifdef DEBUG
-    MarkCompactCollector::UpdateLiveObjectCount(object);
-#endif
      Map* map = object->map();
      // Mark the object.
-    object->SetMark();
-    MarkCompactCollector::tracer()->increment_marked_count();
+    MarkCompactCollector::SetMark(object);
      // Mark the map pointer and body, and push them on the marking stack.
      MarkCompactCollector::MarkObject(map);
      object->IterateBody(map->instance_type(), object->SizeFromMap(map),
@@ -423,20 +415,14 @@


  void MarkCompactCollector::MarkUnmarkedObject(HeapObject* object) {
-#ifdef DEBUG
-  UpdateLiveObjectCount(object);
-#endif
    ASSERT(!object->IsMarked());
-  if (object->IsJSGlobalObject()) Counters::global_objects.Increment();
-
-  tracer_->increment_marked_count();
    ASSERT(Heap::Contains(object));
    if (object->IsMap()) {
      Map* map = Map::cast(object);
      if (FLAG_cleanup_caches_in_maps_at_gc) {
        map->ClearCodeCache();
      }
-    map->SetMark();
+    SetMark(map);
      if (FLAG_collect_maps &&
          map->instance_type() >= FIRST_JS_OBJECT_TYPE &&
          map->instance_type() <= JS_FUNCTION_TYPE) {
@@ -445,7 +431,7 @@
        marking_stack.Push(map);
      }
    } else {
-    object->SetMark();
+    SetMark(object);
      marking_stack.Push(object);
    }
  }
@@ -469,12 +455,7 @@
    if (descriptors->IsMarked()) return;
    // Empty descriptor array is marked as a root before any maps are marked.
    ASSERT(descriptors != Heap::empty_descriptor_array());
-
-  tracer_->increment_marked_count();
-#ifdef DEBUG
-  UpdateLiveObjectCount(descriptors);
-#endif
-  descriptors->SetMark();
+  SetMark(descriptors);

    FixedArray* contents = reinterpret_cast<FixedArray*>(
        descriptors->get(DescriptorArray::kContentArrayIndex));
@@ -482,11 +463,7 @@
    ASSERT(!contents->IsMarked());
    ASSERT(contents->IsFixedArray());
    ASSERT(contents->length() >= 2);
-  tracer_->increment_marked_count();
-#ifdef DEBUG
-  UpdateLiveObjectCount(contents);
-#endif
-  contents->SetMark();
+  SetMark(contents);
    // Contents contains (value, details) pairs.  If the details say
    // that the type of descriptor is MAP_TRANSITION, CONSTANT_TRANSITION,
    // or NULL_DESCRIPTOR, we don't mark the value as live.  Only for
@@ -498,11 +475,7 @@
      if (details.type() < FIRST_PHANTOM_PROPERTY_TYPE) {
        HeapObject* object = reinterpret_cast<HeapObject*>(contents->get(i));
        if (object->IsHeapObject() && !object->IsMarked()) {
-        tracer_->increment_marked_count();
-#ifdef DEBUG
-        UpdateLiveObjectCount(object);
-#endif
-        object->SetMark();
+        SetMark(object);
          marking_stack.Push(object);
        }
      }
@@ -578,13 +551,9 @@
    SymbolTable* symbol_table = SymbolTable::cast(Heap::symbol_table());
    // 1. Mark the prefix of the symbol table gray.
    symbol_table->IteratePrefix(visitor);
-#ifdef DEBUG
-  UpdateLiveObjectCount(symbol_table);
-#endif
    // 2. Mark the symbol table black (ie, do not push it on the marking  
stack
    // or mark it overflowed).
-  symbol_table->SetMark();
-  tracer_->increment_marked_count();
+  SetMark(symbol_table);

    // There may be overflowed objects in the heap.  Visit them now.
    while (marking_stack.overflowed()) {

Modified: branches/bleeding_edge/src/mark-compact.h
==============================================================================
--- branches/bleeding_edge/src/mark-compact.h   (original)
+++ branches/bleeding_edge/src/mark-compact.h   Tue Nov  4 05:05:56 2008
@@ -152,7 +152,15 @@
    static void MarkUnmarkedObject(HeapObject* obj);

    static inline void MarkObject(HeapObject* obj) {
-     if (!obj->IsMarked()) MarkUnmarkedObject(obj);
+    if (!obj->IsMarked()) MarkUnmarkedObject(obj);
+  }
+
+  static inline void SetMark(HeapObject* obj) {
+    tracer_->increment_marked_count();
+#ifdef DEBUG
+    UpdateLiveObjectCount(obj);
+#endif
+    obj->SetMark();
    }

    // Creates back pointers for all map transitions, stores them in

Modified: branches/bleeding_edge/src/v8-counters.h
==============================================================================
--- branches/bleeding_edge/src/v8-counters.h    (original)
+++ branches/bleeding_edge/src/v8-counters.h    Tue Nov  4 05:05:56 2008
@@ -50,8 +50,6 @@
  #define STATS_COUNTER_LIST_1(SC)                                 \
    /* Global Handle Count*/                                       \
    SC(global_handles, V8.GlobalHandles)                           \
-  /* Global Object Count */                                      \
-  SC(global_objects, V8.GlobalObjects)                           \
    /* Mallocs from PCRE */                                        \
    SC(pcre_mallocs, V8.PcreMallocCount)                           \
    /* OS Memory allocated */                                      \

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

Reply via email to