Commit eb9c7f32 authored by whessev8's avatar whessev8

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@688 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 801e168d
...@@ -152,8 +152,6 @@ void MarkCompactCollector::Prepare() { ...@@ -152,8 +152,6 @@ void MarkCompactCollector::Prepare() {
space->PrepareForMarkCompact(compacting_collection_); space->PrepareForMarkCompact(compacting_collection_);
} }
Counters::global_objects.Set(0);
#ifdef DEBUG #ifdef DEBUG
live_bytes_ = 0; live_bytes_ = 0;
live_young_objects_ = 0; live_young_objects_ = 0;
...@@ -327,12 +325,10 @@ class MarkingVisitor : public ObjectVisitor { ...@@ -327,12 +325,10 @@ class MarkingVisitor : public ObjectVisitor {
void VisitUnmarkedObject(HeapObject* obj) { void VisitUnmarkedObject(HeapObject* obj) {
#ifdef DEBUG #ifdef DEBUG
ASSERT(Heap::Contains(obj)); ASSERT(Heap::Contains(obj));
MarkCompactCollector::UpdateLiveObjectCount(obj);
ASSERT(!obj->IsMarked()); ASSERT(!obj->IsMarked());
#endif #endif
Map* map = obj->map(); Map* map = obj->map();
obj->SetMark(); MarkCompactCollector::SetMark(obj);
MarkCompactCollector::tracer()->increment_marked_count();
// Mark the map pointer and the body. // Mark the map pointer and the body.
MarkCompactCollector::MarkObject(map); MarkCompactCollector::MarkObject(map);
obj->IterateBody(map->instance_type(), obj->SizeFromMap(map), this); obj->IterateBody(map->instance_type(), obj->SizeFromMap(map), this);
...@@ -380,13 +376,9 @@ class RootMarkingVisitor : public ObjectVisitor { ...@@ -380,13 +376,9 @@ class RootMarkingVisitor : public ObjectVisitor {
HeapObject* object = ShortCircuitConsString(p); HeapObject* object = ShortCircuitConsString(p);
if (object->IsMarked()) return; if (object->IsMarked()) return;
#ifdef DEBUG
MarkCompactCollector::UpdateLiveObjectCount(object);
#endif
Map* map = object->map(); Map* map = object->map();
// Mark the object. // Mark the object.
object->SetMark(); MarkCompactCollector::SetMark(object);
MarkCompactCollector::tracer()->increment_marked_count();
// Mark the map pointer and body, and push them on the marking stack. // Mark the map pointer and body, and push them on the marking stack.
MarkCompactCollector::MarkObject(map); MarkCompactCollector::MarkObject(map);
object->IterateBody(map->instance_type(), object->SizeFromMap(map), object->IterateBody(map->instance_type(), object->SizeFromMap(map),
...@@ -423,20 +415,14 @@ class SymbolTableCleaner : public ObjectVisitor { ...@@ -423,20 +415,14 @@ class SymbolTableCleaner : public ObjectVisitor {
void MarkCompactCollector::MarkUnmarkedObject(HeapObject* object) { void MarkCompactCollector::MarkUnmarkedObject(HeapObject* object) {
#ifdef DEBUG
UpdateLiveObjectCount(object);
#endif
ASSERT(!object->IsMarked()); ASSERT(!object->IsMarked());
if (object->IsJSGlobalObject()) Counters::global_objects.Increment();
tracer_->increment_marked_count();
ASSERT(Heap::Contains(object)); ASSERT(Heap::Contains(object));
if (object->IsMap()) { if (object->IsMap()) {
Map* map = Map::cast(object); Map* map = Map::cast(object);
if (FLAG_cleanup_caches_in_maps_at_gc) { if (FLAG_cleanup_caches_in_maps_at_gc) {
map->ClearCodeCache(); map->ClearCodeCache();
} }
map->SetMark(); SetMark(map);
if (FLAG_collect_maps && if (FLAG_collect_maps &&
map->instance_type() >= FIRST_JS_OBJECT_TYPE && map->instance_type() >= FIRST_JS_OBJECT_TYPE &&
map->instance_type() <= JS_FUNCTION_TYPE) { map->instance_type() <= JS_FUNCTION_TYPE) {
...@@ -445,7 +431,7 @@ void MarkCompactCollector::MarkUnmarkedObject(HeapObject* object) { ...@@ -445,7 +431,7 @@ void MarkCompactCollector::MarkUnmarkedObject(HeapObject* object) {
marking_stack.Push(map); marking_stack.Push(map);
} }
} else { } else {
object->SetMark(); SetMark(object);
marking_stack.Push(object); marking_stack.Push(object);
} }
} }
...@@ -469,12 +455,7 @@ void MarkCompactCollector::MarkDescriptorArray( ...@@ -469,12 +455,7 @@ void MarkCompactCollector::MarkDescriptorArray(
if (descriptors->IsMarked()) return; if (descriptors->IsMarked()) return;
// Empty descriptor array is marked as a root before any maps are marked. // Empty descriptor array is marked as a root before any maps are marked.
ASSERT(descriptors != Heap::empty_descriptor_array()); ASSERT(descriptors != Heap::empty_descriptor_array());
SetMark(descriptors);
tracer_->increment_marked_count();
#ifdef DEBUG
UpdateLiveObjectCount(descriptors);
#endif
descriptors->SetMark();
FixedArray* contents = reinterpret_cast<FixedArray*>( FixedArray* contents = reinterpret_cast<FixedArray*>(
descriptors->get(DescriptorArray::kContentArrayIndex)); descriptors->get(DescriptorArray::kContentArrayIndex));
...@@ -482,11 +463,7 @@ void MarkCompactCollector::MarkDescriptorArray( ...@@ -482,11 +463,7 @@ void MarkCompactCollector::MarkDescriptorArray(
ASSERT(!contents->IsMarked()); ASSERT(!contents->IsMarked());
ASSERT(contents->IsFixedArray()); ASSERT(contents->IsFixedArray());
ASSERT(contents->length() >= 2); ASSERT(contents->length() >= 2);
tracer_->increment_marked_count(); SetMark(contents);
#ifdef DEBUG
UpdateLiveObjectCount(contents);
#endif
contents->SetMark();
// Contents contains (value, details) pairs. If the details say // Contents contains (value, details) pairs. If the details say
// that the type of descriptor is MAP_TRANSITION, CONSTANT_TRANSITION, // that the type of descriptor is MAP_TRANSITION, CONSTANT_TRANSITION,
// or NULL_DESCRIPTOR, we don't mark the value as live. Only for // or NULL_DESCRIPTOR, we don't mark the value as live. Only for
...@@ -498,11 +475,7 @@ void MarkCompactCollector::MarkDescriptorArray( ...@@ -498,11 +475,7 @@ void MarkCompactCollector::MarkDescriptorArray(
if (details.type() < FIRST_PHANTOM_PROPERTY_TYPE) { if (details.type() < FIRST_PHANTOM_PROPERTY_TYPE) {
HeapObject* object = reinterpret_cast<HeapObject*>(contents->get(i)); HeapObject* object = reinterpret_cast<HeapObject*>(contents->get(i));
if (object->IsHeapObject() && !object->IsMarked()) { if (object->IsHeapObject() && !object->IsMarked()) {
tracer_->increment_marked_count(); SetMark(object);
#ifdef DEBUG
UpdateLiveObjectCount(object);
#endif
object->SetMark();
marking_stack.Push(object); marking_stack.Push(object);
} }
} }
...@@ -578,13 +551,9 @@ void MarkCompactCollector::ProcessRoots(RootMarkingVisitor* visitor) { ...@@ -578,13 +551,9 @@ void MarkCompactCollector::ProcessRoots(RootMarkingVisitor* visitor) {
SymbolTable* symbol_table = SymbolTable::cast(Heap::symbol_table()); SymbolTable* symbol_table = SymbolTable::cast(Heap::symbol_table());
// 1. Mark the prefix of the symbol table gray. // 1. Mark the prefix of the symbol table gray.
symbol_table->IteratePrefix(visitor); 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 // 2. Mark the symbol table black (ie, do not push it on the marking stack
// or mark it overflowed). // or mark it overflowed).
symbol_table->SetMark(); SetMark(symbol_table);
tracer_->increment_marked_count();
// There may be overflowed objects in the heap. Visit them now. // There may be overflowed objects in the heap. Visit them now.
while (marking_stack.overflowed()) { while (marking_stack.overflowed()) {
......
...@@ -152,7 +152,15 @@ class MarkCompactCollector : public AllStatic { ...@@ -152,7 +152,15 @@ class MarkCompactCollector : public AllStatic {
static void MarkUnmarkedObject(HeapObject* obj); static void MarkUnmarkedObject(HeapObject* obj);
static inline void MarkObject(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 // Creates back pointers for all map transitions, stores them in
......
...@@ -50,8 +50,6 @@ namespace v8 { namespace internal { ...@@ -50,8 +50,6 @@ namespace v8 { namespace internal {
#define STATS_COUNTER_LIST_1(SC) \ #define STATS_COUNTER_LIST_1(SC) \
/* Global Handle Count*/ \ /* Global Handle Count*/ \
SC(global_handles, V8.GlobalHandles) \ SC(global_handles, V8.GlobalHandles) \
/* Global Object Count */ \
SC(global_objects, V8.GlobalObjects) \
/* Mallocs from PCRE */ \ /* Mallocs from PCRE */ \
SC(pcre_mallocs, V8.PcreMallocCount) \ SC(pcre_mallocs, V8.PcreMallocCount) \
/* OS Memory allocated */ \ /* OS Memory allocated */ \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment