Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Unified Diff: src/incremental-marking.cc

Issue 11029023: Revert "Allow partial scanning of large arrays in order to avoid" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap.cc ('k') | src/mark-compact.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/incremental-marking.cc
diff --git a/src/incremental-marking.cc b/src/incremental-marking.cc
index 4aec1e909123bbb366dd24daef25f5e245c746eb..32a084dc2d79f5dc89c2ac3d0a3e5f7bbd8ade04 100644
--- a/src/incremental-marking.cc
+++ b/src/incremental-marking.cc
@@ -190,11 +190,8 @@ class IncrementalMarkingMarkingVisitor
static void VisitJSWeakMap(Map* map, HeapObject* object) {
Heap* heap = map->GetHeap();
- Object** start_slot =
- HeapObject::RawField(object, JSWeakMap::kPropertiesOffset);
VisitPointers(heap,
- start_slot,
- start_slot,
+ HeapObject::RawField(object, JSWeakMap::kPropertiesOffset),
HeapObject::RawField(object, JSWeakMap::kSize));
}
@@ -209,54 +206,15 @@ class IncrementalMarkingMarkingVisitor
void>::Visit(map, object);
}
- static const int kScanningChunk = 32 * 1024;
-
- static int VisitHugeArray(FixedArray* array) {
- Heap* heap = array->GetHeap();
- MemoryChunk* chunk = MemoryChunk::FromAddress(array->address());
- Object** start_slot = array->data_start();
- int length = array->length();
-
- if (chunk->owner()->identity() != LO_SPACE) {
- VisitPointers(heap, start_slot, start_slot, start_slot + length);
- return length;
- }
-
- int from =
- chunk->IsPartiallyScanned() ? chunk->PartiallyScannedProgress() : 0;
- int to = Min(from + kScanningChunk, length);
-
- VisitPointers(heap, start_slot, start_slot + from, start_slot + to);
-
- if (to == length) {
- // If it went from black to grey while it was waiting for the next bit to
- // be scanned then we have to start the scan again.
- MarkBit mark_bit = Marking::MarkBitFrom(array);
- if (!Marking::IsBlack(mark_bit)) {
- ASSERT(Marking::IsGrey(mark_bit));
- chunk->SetPartiallyScannedProgress(0);
- } else {
- chunk->SetCompletelyScanned();
- }
- } else {
- chunk->SetPartiallyScannedProgress(to);
- }
- return to - from;
- }
-
static inline void VisitJSFunction(Map* map, HeapObject* object) {
Heap* heap = map->GetHeap();
// Iterate over all fields in the body but take care in dealing with
// the code entry and skip weak fields.
- Object** start_slot =
- HeapObject::RawField(object, JSFunction::kPropertiesOffset);
VisitPointers(heap,
- start_slot,
- start_slot,
+ HeapObject::RawField(object, JSFunction::kPropertiesOffset),
HeapObject::RawField(object, JSFunction::kCodeEntryOffset));
VisitCodeEntry(heap, object->address() + JSFunction::kCodeEntryOffset);
VisitPointers(heap,
- start_slot,
HeapObject::RawField(object,
JSFunction::kCodeEntryOffset + kPointerSize),
HeapObject::RawField(object,
@@ -271,14 +229,11 @@ class IncrementalMarkingMarkingVisitor
}
}
- INLINE(static void VisitPointers(Heap* heap,
- Object** anchor,
- Object** start,
- Object** end)) {
+ INLINE(static void VisitPointers(Heap* heap, Object** start, Object** end)) {
for (Object** p = start; p < end; p++) {
Object* obj = *p;
if (obj->NonFailureIsHeapObject()) {
- heap->mark_compact_collector()->RecordSlot(anchor, p, obj);
+ heap->mark_compact_collector()->RecordSlot(start, p, obj);
MarkObject(heap, obj);
}
}
@@ -680,8 +635,7 @@ void IncrementalMarking::UpdateMarkingDequeAfterScavenge() {
#ifdef DEBUG
MarkBit mark_bit = Marking::MarkBitFrom(obj);
ASSERT(Marking::IsGrey(mark_bit) ||
- (obj->IsFiller() && Marking::IsWhite(mark_bit)) ||
- MemoryChunk::FromAddress(obj->address())->IsPartiallyScanned());
+ (obj->IsFiller() && Marking::IsWhite(mark_bit)));
#endif
}
}
@@ -704,57 +658,36 @@ void IncrementalMarking::Hurry() {
// was stopped.
Map* filler_map = heap_->one_pointer_filler_map();
Map* native_context_map = heap_->native_context_map();
- do {
- while (!marking_deque_.IsEmpty()) {
- HeapObject* obj = marking_deque_.Pop();
-
- // Explicitly skip one word fillers. Incremental markbit patterns are
- // correct only for objects that occupy at least two words.
- Map* map = obj->map();
- if (map == filler_map) {
- continue;
- } else if (map == native_context_map) {
- // Native contexts have weak fields.
- IncrementalMarkingMarkingVisitor::VisitNativeContext(map, obj);
- ASSERT(!Marking::IsBlack(Marking::MarkBitFrom(obj)));
- MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size());
- } else if (map->instance_type() == FIXED_ARRAY_TYPE &&
- FixedArray::cast(obj)->length() >
- IncrementalMarkingMarkingVisitor::kScanningChunk) {
- MarkBit map_mark_bit = Marking::MarkBitFrom(map);
- if (Marking::IsWhite(map_mark_bit)) {
- WhiteToGreyAndPush(map, map_mark_bit);
- }
- MarkBit mark_bit = Marking::MarkBitFrom(obj);
- if (!Marking::IsBlack(mark_bit)) {
- MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size());
- } else {
- ASSERT(
- MemoryChunk::FromAddress(obj->address())->IsPartiallyScanned());
- }
- IncrementalMarkingMarkingVisitor::VisitHugeArray(
- FixedArray::cast(obj));
- } else {
- MarkBit map_mark_bit = Marking::MarkBitFrom(map);
- if (Marking::IsWhite(map_mark_bit)) {
- WhiteToGreyAndPush(map, map_mark_bit);
- }
- IncrementalMarkingMarkingVisitor::IterateBody(map, obj);
- ASSERT(!Marking::IsBlack(Marking::MarkBitFrom(obj)));
- MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size());
+ while (!marking_deque_.IsEmpty()) {
+ HeapObject* obj = marking_deque_.Pop();
+
+ // Explicitly skip one word fillers. Incremental markbit patterns are
+ // correct only for objects that occupy at least two words.
+ Map* map = obj->map();
+ if (map == filler_map) {
+ continue;
+ } else if (map == native_context_map) {
+ // Native contexts have weak fields.
+ IncrementalMarkingMarkingVisitor::VisitNativeContext(map, obj);
+ } else {
+ MarkBit map_mark_bit = Marking::MarkBitFrom(map);
+ if (Marking::IsWhite(map_mark_bit)) {
+ WhiteToGreyAndPush(map, map_mark_bit);
}
-
- MarkBit mark_bit = Marking::MarkBitFrom(obj);
- Marking::MarkBlack(mark_bit);
+ IncrementalMarkingMarkingVisitor::IterateBody(map, obj);
}
- state_ = COMPLETE;
- if (FLAG_trace_incremental_marking) {
- double end = OS::TimeCurrentMillis();
- PrintF("[IncrementalMarking] Complete (hurry), spent %d ms.\n",
- static_cast<int>(end - start));
- }
- MarkCompactCollector::ProcessLargePostponedArrays(heap_, &marking_deque_);
- } while (!marking_deque_.IsEmpty());
+
+ MarkBit mark_bit = Marking::MarkBitFrom(obj);
+ ASSERT(!Marking::IsBlack(mark_bit));
+ Marking::MarkBlack(mark_bit);
+ MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size());
+ }
+ state_ = COMPLETE;
+ if (FLAG_trace_incremental_marking) {
+ double end = OS::TimeCurrentMillis();
+ PrintF("[IncrementalMarking] Complete (hurry), spent %d ms.\n",
+ static_cast<int>(end - start));
+ }
}
if (FLAG_cleanup_code_caches_at_gc) {
@@ -889,71 +822,42 @@ void IncrementalMarking::Step(intptr_t allocated_bytes,
} else if (state_ == MARKING) {
Map* filler_map = heap_->one_pointer_filler_map();
Map* native_context_map = heap_->native_context_map();
- while (true) {
- while (!marking_deque_.IsEmpty() && bytes_to_process > 0) {
- HeapObject* obj = marking_deque_.Pop();
-
- // Explicitly skip one word fillers. Incremental markbit patterns are
- // correct only for objects that occupy at least two words.
- Map* map = obj->map();
- if (map == filler_map) continue;
+ while (!marking_deque_.IsEmpty() && bytes_to_process > 0) {
+ HeapObject* obj = marking_deque_.Pop();
+
+ // Explicitly skip one word fillers. Incremental markbit patterns are
+ // correct only for objects that occupy at least two words.
+ Map* map = obj->map();
+ if (map == filler_map) continue;
+
+ int size = obj->SizeFromMap(map);
+ bytes_to_process -= size;
+ MarkBit map_mark_bit = Marking::MarkBitFrom(map);
+ if (Marking::IsWhite(map_mark_bit)) {
+ WhiteToGreyAndPush(map, map_mark_bit);
+ }
- int size = obj->SizeFromMap(map);
- MarkBit map_mark_bit = Marking::MarkBitFrom(map);
- if (Marking::IsWhite(map_mark_bit)) {
- WhiteToGreyAndPush(map, map_mark_bit);
- }
+ // TODO(gc) switch to static visitor instead of normal visitor.
+ if (map == native_context_map) {
+ // Native contexts have weak fields.
+ Context* ctx = Context::cast(obj);
- // TODO(gc) switch to static visitor instead of normal visitor.
- if (map == native_context_map) {
- // Native contexts have weak fields.
- Context* ctx = Context::cast(obj);
-
- // We will mark cache black with a separate pass
- // when we finish marking.
- MarkObjectGreyDoNotEnqueue(ctx->normalized_map_cache());
-
- IncrementalMarkingMarkingVisitor::VisitNativeContext(map, ctx);
- bytes_to_process -= size;
- SLOW_ASSERT(Marking::IsGrey(Marking::MarkBitFrom(obj)));
- MemoryChunk::IncrementLiveBytesFromGC(obj->address(), size);
- } else if (map->instance_type() == FIXED_ARRAY_TYPE &&
- FixedArray::cast(obj)->length() >
- IncrementalMarkingMarkingVisitor::kScanningChunk) {
- SLOW_ASSERT(
- Marking::IsGrey(Marking::MarkBitFrom(obj)) ||
- MemoryChunk::FromAddress(obj->address())->IsPartiallyScanned());
- bytes_to_process -=
- IncrementalMarkingMarkingVisitor::VisitHugeArray(
- FixedArray::cast(obj));
- MarkBit obj_mark_bit = Marking::MarkBitFrom(obj);
- if (!Marking::IsBlack(obj_mark_bit)) {
- MemoryChunk::IncrementLiveBytesFromGC(obj->address(), size);
- }
- } else {
- IncrementalMarkingMarkingVisitor::IterateBody(map, obj);
- bytes_to_process -= size;
- SLOW_ASSERT(
- Marking::IsGrey(Marking::MarkBitFrom(obj)) ||
- (obj->IsFiller() && Marking::IsWhite(Marking::MarkBitFrom(obj))));
- MemoryChunk::IncrementLiveBytesFromGC(obj->address(), size);
- }
+ // We will mark cache black with a separate pass
+ // when we finish marking.
+ MarkObjectGreyDoNotEnqueue(ctx->normalized_map_cache());
- MarkBit obj_mark_bit = Marking::MarkBitFrom(obj);
- Marking::MarkBlack(obj_mark_bit);
+ IncrementalMarkingMarkingVisitor::VisitNativeContext(map, ctx);
+ } else {
+ IncrementalMarkingMarkingVisitor::IterateBody(map, obj);
}
- if (marking_deque_.IsEmpty()) {
- MarkCompactCollector::ProcessLargePostponedArrays(heap_,
- &marking_deque_);
- if (marking_deque_.IsEmpty()) {
- MarkingComplete(action);
- break;
- }
- } else {
- ASSERT(bytes_to_process <= 0);
- break;
- }
+
+ MarkBit obj_mark_bit = Marking::MarkBitFrom(obj);
+ SLOW_ASSERT(Marking::IsGrey(obj_mark_bit) ||
+ (obj->IsFiller() && Marking::IsWhite(obj_mark_bit)));
+ Marking::MarkBlack(obj_mark_bit);
+ MemoryChunk::IncrementLiveBytesFromGC(obj->address(), size);
}
+ if (marking_deque_.IsEmpty()) MarkingComplete(action);
}
steps_count_++;
« no previous file with comments | « src/heap.cc ('k') | src/mark-compact.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698