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

Side by Side Diff: src/incremental-marking.cc

Issue 9178021: When adjusting page's live bytes counter from the mutator adjust owners unswept free bytes counter. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 218 }
219 } 219 }
220 220
221 private: 221 private:
222 // Mark object pointed to by p. 222 // Mark object pointed to by p.
223 INLINE(void MarkObject(Object* obj)) { 223 INLINE(void MarkObject(Object* obj)) {
224 HeapObject* heap_object = HeapObject::cast(obj); 224 HeapObject* heap_object = HeapObject::cast(obj);
225 MarkBit mark_bit = Marking::MarkBitFrom(heap_object); 225 MarkBit mark_bit = Marking::MarkBitFrom(heap_object);
226 if (mark_bit.data_only()) { 226 if (mark_bit.data_only()) {
227 if (incremental_marking_->MarkBlackOrKeepGrey(mark_bit)) { 227 if (incremental_marking_->MarkBlackOrKeepGrey(mark_bit)) {
228 MemoryChunk::IncrementLiveBytes(heap_object->address(), 228 MemoryChunk::IncrementLiveBytesFromGC(heap_object->address(),
229 heap_object->Size()); 229 heap_object->Size());
230 } 230 }
231 } else if (Marking::IsWhite(mark_bit)) { 231 } else if (Marking::IsWhite(mark_bit)) {
232 incremental_marking_->WhiteToGreyAndPush(heap_object, mark_bit); 232 incremental_marking_->WhiteToGreyAndPush(heap_object, mark_bit);
233 } 233 }
234 } 234 }
235 235
236 Heap* heap_; 236 Heap* heap_;
237 IncrementalMarking* incremental_marking_; 237 IncrementalMarking* incremental_marking_;
238 }; 238 };
239 239
(...skipping 16 matching lines...) Expand all
256 256
257 private: 257 private:
258 void MarkObjectByPointer(Object** p) { 258 void MarkObjectByPointer(Object** p) {
259 Object* obj = *p; 259 Object* obj = *p;
260 if (!obj->IsHeapObject()) return; 260 if (!obj->IsHeapObject()) return;
261 261
262 HeapObject* heap_object = HeapObject::cast(obj); 262 HeapObject* heap_object = HeapObject::cast(obj);
263 MarkBit mark_bit = Marking::MarkBitFrom(heap_object); 263 MarkBit mark_bit = Marking::MarkBitFrom(heap_object);
264 if (mark_bit.data_only()) { 264 if (mark_bit.data_only()) {
265 if (incremental_marking_->MarkBlackOrKeepGrey(mark_bit)) { 265 if (incremental_marking_->MarkBlackOrKeepGrey(mark_bit)) {
266 MemoryChunk::IncrementLiveBytes(heap_object->address(), 266 MemoryChunk::IncrementLiveBytesFromGC(heap_object->address(),
267 heap_object->Size()); 267 heap_object->Size());
268 } 268 }
269 } else { 269 } else {
270 if (Marking::IsWhite(mark_bit)) { 270 if (Marking::IsWhite(mark_bit)) {
271 incremental_marking_->WhiteToGreyAndPush(heap_object, mark_bit); 271 incremental_marking_->WhiteToGreyAndPush(heap_object, mark_bit);
272 } 272 }
273 } 273 }
274 } 274 }
275 275
276 Heap* heap_; 276 Heap* heap_;
277 IncrementalMarking* incremental_marking_; 277 IncrementalMarking* incremental_marking_;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 484
485 heap_->new_space()->LowerInlineAllocationLimit(kAllocatedThreshold); 485 heap_->new_space()->LowerInlineAllocationLimit(kAllocatedThreshold);
486 } 486 }
487 487
488 488
489 static void MarkObjectGreyDoNotEnqueue(Object* obj) { 489 static void MarkObjectGreyDoNotEnqueue(Object* obj) {
490 if (obj->IsHeapObject()) { 490 if (obj->IsHeapObject()) {
491 HeapObject* heap_obj = HeapObject::cast(obj); 491 HeapObject* heap_obj = HeapObject::cast(obj);
492 MarkBit mark_bit = Marking::MarkBitFrom(HeapObject::cast(obj)); 492 MarkBit mark_bit = Marking::MarkBitFrom(HeapObject::cast(obj));
493 if (Marking::IsBlack(mark_bit)) { 493 if (Marking::IsBlack(mark_bit)) {
494 MemoryChunk::IncrementLiveBytes(heap_obj->address(), 494 MemoryChunk::IncrementLiveBytesFromGC(heap_obj->address(),
495 -heap_obj->Size()); 495 -heap_obj->Size());
496 } 496 }
497 Marking::AnyToGrey(mark_bit); 497 Marking::AnyToGrey(mark_bit);
498 } 498 }
499 } 499 }
500 500
501 501
502 void IncrementalMarking::StartMarking(CompactionFlag flag) { 502 void IncrementalMarking::StartMarking(CompactionFlag flag) {
503 if (FLAG_trace_incremental_marking) { 503 if (FLAG_trace_incremental_marking) {
504 PrintF("[IncrementalMarking] Start marking\n"); 504 PrintF("[IncrementalMarking] Start marking\n");
505 } 505 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 } else if (map == global_context_map) { 651 } else if (map == global_context_map) {
652 // Global contexts have weak fields. 652 // Global contexts have weak fields.
653 VisitGlobalContext(Context::cast(obj), &marking_visitor); 653 VisitGlobalContext(Context::cast(obj), &marking_visitor);
654 } else { 654 } else {
655 obj->Iterate(&marking_visitor); 655 obj->Iterate(&marking_visitor);
656 } 656 }
657 657
658 MarkBit mark_bit = Marking::MarkBitFrom(obj); 658 MarkBit mark_bit = Marking::MarkBitFrom(obj);
659 ASSERT(!Marking::IsBlack(mark_bit)); 659 ASSERT(!Marking::IsBlack(mark_bit));
660 Marking::MarkBlack(mark_bit); 660 Marking::MarkBlack(mark_bit);
661 MemoryChunk::IncrementLiveBytes(obj->address(), obj->Size()); 661 MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size());
662 } 662 }
663 state_ = COMPLETE; 663 state_ = COMPLETE;
664 if (FLAG_trace_incremental_marking) { 664 if (FLAG_trace_incremental_marking) {
665 double end = OS::TimeCurrentMillis(); 665 double end = OS::TimeCurrentMillis();
666 PrintF("[IncrementalMarking] Complete (hurry), spent %d ms.\n", 666 PrintF("[IncrementalMarking] Complete (hurry), spent %d ms.\n",
667 static_cast<int>(end - start)); 667 static_cast<int>(end - start));
668 } 668 }
669 } 669 }
670 670
671 if (FLAG_cleanup_code_caches_at_gc) { 671 if (FLAG_cleanup_code_caches_at_gc) {
672 PolymorphicCodeCache* poly_cache = heap_->polymorphic_code_cache(); 672 PolymorphicCodeCache* poly_cache = heap_->polymorphic_code_cache();
673 Marking::GreyToBlack(Marking::MarkBitFrom(poly_cache)); 673 Marking::GreyToBlack(Marking::MarkBitFrom(poly_cache));
674 MemoryChunk::IncrementLiveBytes(poly_cache->address(), 674 MemoryChunk::IncrementLiveBytesFromGC(poly_cache->address(),
675 PolymorphicCodeCache::kSize); 675 PolymorphicCodeCache::kSize);
676 } 676 }
677 677
678 Object* context = heap_->global_contexts_list(); 678 Object* context = heap_->global_contexts_list();
679 while (!context->IsUndefined()) { 679 while (!context->IsUndefined()) {
680 // GC can happen when the context is not fully initialized, 680 // GC can happen when the context is not fully initialized,
681 // so the cache can be undefined. 681 // so the cache can be undefined.
682 HeapObject* cache = HeapObject::cast( 682 HeapObject* cache = HeapObject::cast(
683 Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX)); 683 Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX));
684 if (!cache->IsUndefined()) { 684 if (!cache->IsUndefined()) {
685 MarkBit mark_bit = Marking::MarkBitFrom(cache); 685 MarkBit mark_bit = Marking::MarkBitFrom(cache);
686 if (Marking::IsGrey(mark_bit)) { 686 if (Marking::IsGrey(mark_bit)) {
687 Marking::GreyToBlack(mark_bit); 687 Marking::GreyToBlack(mark_bit);
688 MemoryChunk::IncrementLiveBytes(cache->address(), cache->Size()); 688 MemoryChunk::IncrementLiveBytesFromGC(cache->address(), cache->Size());
689 } 689 }
690 } 690 }
691 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); 691 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK);
692 } 692 }
693 } 693 }
694 694
695 695
696 void IncrementalMarking::Abort() { 696 void IncrementalMarking::Abort() {
697 if (IsStopped()) return; 697 if (IsStopped()) return;
698 if (FLAG_trace_incremental_marking) { 698 if (FLAG_trace_incremental_marking) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 812
813 VisitGlobalContext(ctx, &marking_visitor); 813 VisitGlobalContext(ctx, &marking_visitor);
814 } else { 814 } else {
815 obj->IterateBody(map->instance_type(), size, &marking_visitor); 815 obj->IterateBody(map->instance_type(), size, &marking_visitor);
816 } 816 }
817 817
818 MarkBit obj_mark_bit = Marking::MarkBitFrom(obj); 818 MarkBit obj_mark_bit = Marking::MarkBitFrom(obj);
819 SLOW_ASSERT(Marking::IsGrey(obj_mark_bit) || 819 SLOW_ASSERT(Marking::IsGrey(obj_mark_bit) ||
820 (obj->IsFiller() && Marking::IsWhite(obj_mark_bit))); 820 (obj->IsFiller() && Marking::IsWhite(obj_mark_bit)));
821 Marking::MarkBlack(obj_mark_bit); 821 Marking::MarkBlack(obj_mark_bit);
822 MemoryChunk::IncrementLiveBytes(obj->address(), size); 822 MemoryChunk::IncrementLiveBytesFromGC(obj->address(), size);
823 } 823 }
824 if (marking_deque_.IsEmpty()) MarkingComplete(); 824 if (marking_deque_.IsEmpty()) MarkingComplete();
825 } 825 }
826 826
827 allocated_ = 0; 827 allocated_ = 0;
828 828
829 steps_count_++; 829 steps_count_++;
830 steps_count_since_last_gc_++; 830 steps_count_since_last_gc_++;
831 831
832 bool speed_up = false; 832 bool speed_up = false;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 allocation_marking_factor_ = kInitialAllocationMarkingFactor; 916 allocation_marking_factor_ = kInitialAllocationMarkingFactor;
917 bytes_scanned_ = 0; 917 bytes_scanned_ = 0;
918 } 918 }
919 919
920 920
921 int64_t IncrementalMarking::SpaceLeftInOldSpace() { 921 int64_t IncrementalMarking::SpaceLeftInOldSpace() {
922 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSize(); 922 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSize();
923 } 923 }
924 924
925 } } // namespace v8::internal 925 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/incremental-marking-inl.h » ('j') | src/spaces.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698