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

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

Issue 8194012: Merge revision 9585 and revision 9580 to trunk. (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/incremental-marking.h ('k') | src/spaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 if (FLAG_trace_incremental_marking) { 403 if (FLAG_trace_incremental_marking) {
404 PrintF("[IncrementalMarking] Start\n"); 404 PrintF("[IncrementalMarking] Start\n");
405 } 405 }
406 ASSERT(FLAG_incremental_marking); 406 ASSERT(FLAG_incremental_marking);
407 ASSERT(state_ == STOPPED); 407 ASSERT(state_ == STOPPED);
408 408
409 ResetStepCounters(); 409 ResetStepCounters();
410 410
411 if (heap_->old_pointer_space()->IsSweepingComplete() && 411 if (heap_->old_pointer_space()->IsSweepingComplete() &&
412 heap_->old_data_space()->IsSweepingComplete()) { 412 heap_->old_data_space()->IsSweepingComplete()) {
413 StartMarking(); 413 StartMarking(ALLOW_COMPACTION);
414 } else { 414 } else {
415 if (FLAG_trace_incremental_marking) { 415 if (FLAG_trace_incremental_marking) {
416 PrintF("[IncrementalMarking] Start sweeping.\n"); 416 PrintF("[IncrementalMarking] Start sweeping.\n");
417 } 417 }
418 state_ = SWEEPING; 418 state_ = SWEEPING;
419 } 419 }
420 420
421 heap_->new_space()->LowerInlineAllocationLimit(kAllocatedThreshold); 421 heap_->new_space()->LowerInlineAllocationLimit(kAllocatedThreshold);
422 } 422 }
423 423
424 424
425 static void MarkObjectGreyDoNotEnqueue(Object* obj) { 425 static void MarkObjectGreyDoNotEnqueue(Object* obj) {
426 if (obj->IsHeapObject()) { 426 if (obj->IsHeapObject()) {
427 HeapObject* heap_obj = HeapObject::cast(obj); 427 HeapObject* heap_obj = HeapObject::cast(obj);
428 MarkBit mark_bit = Marking::MarkBitFrom(HeapObject::cast(obj)); 428 MarkBit mark_bit = Marking::MarkBitFrom(HeapObject::cast(obj));
429 if (Marking::IsBlack(mark_bit)) { 429 if (Marking::IsBlack(mark_bit)) {
430 MemoryChunk::IncrementLiveBytes(heap_obj->address(), 430 MemoryChunk::IncrementLiveBytes(heap_obj->address(),
431 -heap_obj->Size()); 431 -heap_obj->Size());
432 } 432 }
433 Marking::AnyToGrey(mark_bit); 433 Marking::AnyToGrey(mark_bit);
434 } 434 }
435 } 435 }
436 436
437 437
438 void IncrementalMarking::StartMarking() { 438 void IncrementalMarking::StartMarking(CompactionFlag flag) {
439 if (FLAG_trace_incremental_marking) { 439 if (FLAG_trace_incremental_marking) {
440 PrintF("[IncrementalMarking] Start marking\n"); 440 PrintF("[IncrementalMarking] Start marking\n");
441 } 441 }
442 442
443 is_compacting_ = !FLAG_never_compact && 443 is_compacting_ = !FLAG_never_compact && (flag == ALLOW_COMPACTION) &&
444 heap_->mark_compact_collector()->StartCompaction(); 444 heap_->mark_compact_collector()->StartCompaction();
445 445
446 state_ = MARKING; 446 state_ = MARKING;
447 447
448 RecordWriteStub::Mode mode = is_compacting_ ? 448 RecordWriteStub::Mode mode = is_compacting_ ?
449 RecordWriteStub::INCREMENTAL_COMPACTION : RecordWriteStub::INCREMENTAL; 449 RecordWriteStub::INCREMENTAL_COMPACTION : RecordWriteStub::INCREMENTAL;
450 450
451 PatchIncrementalMarkingRecordWriteStubs(heap_, mode); 451 PatchIncrementalMarkingRecordWriteStubs(heap_, mode);
452 452
453 EnsureMarkingDequeIsCommitted(); 453 EnsureMarkingDequeIsCommitted();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 HeapObject* obj = array[current]; 510 HeapObject* obj = array[current];
511 ASSERT(obj->IsHeapObject()); 511 ASSERT(obj->IsHeapObject());
512 current = ((current + 1) & mask); 512 current = ((current + 1) & mask);
513 if (heap_->InNewSpace(obj)) { 513 if (heap_->InNewSpace(obj)) {
514 MapWord map_word = obj->map_word(); 514 MapWord map_word = obj->map_word();
515 if (map_word.IsForwardingAddress()) { 515 if (map_word.IsForwardingAddress()) {
516 HeapObject* dest = map_word.ToForwardingAddress(); 516 HeapObject* dest = map_word.ToForwardingAddress();
517 array[new_top] = dest; 517 array[new_top] = dest;
518 new_top = ((new_top + 1) & mask); 518 new_top = ((new_top + 1) & mask);
519 ASSERT(new_top != marking_deque_.bottom()); 519 ASSERT(new_top != marking_deque_.bottom());
520 ASSERT(Marking::IsGrey(Marking::MarkBitFrom(obj))); 520 #ifdef DEBUG
521 MarkBit mark_bit = Marking::MarkBitFrom(obj);
522 ASSERT(Marking::IsGrey(mark_bit) ||
523 (obj->IsFiller() && Marking::IsWhite(mark_bit)));
524 #endif
521 } 525 }
522 } else if (obj->map() != filler_map) { 526 } else if (obj->map() != filler_map) {
523 // Skip one word filler objects that appear on the 527 // Skip one word filler objects that appear on the
524 // stack when we perform in place array shift. 528 // stack when we perform in place array shift.
525 array[new_top] = obj; 529 array[new_top] = obj;
526 new_top = ((new_top + 1) & mask); 530 new_top = ((new_top + 1) & mask);
527 ASSERT(new_top != marking_deque_.bottom()); 531 ASSERT(new_top != marking_deque_.bottom());
528 ASSERT(Marking::IsGrey(Marking::MarkBitFrom(obj))); 532 #ifdef DEBUG
533 MarkBit mark_bit = Marking::MarkBitFrom(obj);
534 ASSERT(Marking::IsGrey(mark_bit) ||
535 (obj->IsFiller() && Marking::IsWhite(mark_bit)));
536 #endif
529 } 537 }
530 } 538 }
531 marking_deque_.set_top(new_top); 539 marking_deque_.set_top(new_top);
532 540
533 steps_took_since_last_gc_ = 0; 541 steps_took_since_last_gc_ = 0;
534 steps_count_since_last_gc_ = 0; 542 steps_count_since_last_gc_ = 0;
535 longest_step_ = 0.0; 543 longest_step_ = 0.0;
536 } 544 }
537 545
538 546
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 697
690 double start = 0; 698 double start = 0;
691 699
692 if (FLAG_trace_incremental_marking || FLAG_trace_gc) { 700 if (FLAG_trace_incremental_marking || FLAG_trace_gc) {
693 start = OS::TimeCurrentMillis(); 701 start = OS::TimeCurrentMillis();
694 } 702 }
695 703
696 if (state_ == SWEEPING) { 704 if (state_ == SWEEPING) {
697 if (heap_->old_pointer_space()->AdvanceSweeper(bytes_to_process) && 705 if (heap_->old_pointer_space()->AdvanceSweeper(bytes_to_process) &&
698 heap_->old_data_space()->AdvanceSweeper(bytes_to_process)) { 706 heap_->old_data_space()->AdvanceSweeper(bytes_to_process)) {
699 StartMarking(); 707 StartMarking(PREVENT_COMPACTION);
700 } 708 }
701 } else if (state_ == MARKING) { 709 } else if (state_ == MARKING) {
702 Map* filler_map = heap_->one_pointer_filler_map(); 710 Map* filler_map = heap_->one_pointer_filler_map();
703 Map* global_context_map = heap_->global_context_map(); 711 Map* global_context_map = heap_->global_context_map();
704 IncrementalMarkingMarkingVisitor marking_visitor(heap_, this); 712 IncrementalMarkingMarkingVisitor marking_visitor(heap_, this);
705 while (!marking_deque_.IsEmpty() && bytes_to_process > 0) { 713 while (!marking_deque_.IsEmpty() && bytes_to_process > 0) {
706 HeapObject* obj = marking_deque_.Pop(); 714 HeapObject* obj = marking_deque_.Pop();
707 715
708 // Explicitly skip one word fillers. Incremental markbit patterns are 716 // Explicitly skip one word fillers. Incremental markbit patterns are
709 // correct only for objects that occupy at least two words. 717 // correct only for objects that occupy at least two words.
710 Map* map = obj->map(); 718 Map* map = obj->map();
711 if (map == filler_map) continue; 719 if (map == filler_map) continue;
712 720
713 ASSERT(Marking::IsGrey(Marking::MarkBitFrom(obj)));
714 int size = obj->SizeFromMap(map); 721 int size = obj->SizeFromMap(map);
715 bytes_to_process -= size; 722 bytes_to_process -= size;
716 MarkBit map_mark_bit = Marking::MarkBitFrom(map); 723 MarkBit map_mark_bit = Marking::MarkBitFrom(map);
717 if (Marking::IsWhite(map_mark_bit)) { 724 if (Marking::IsWhite(map_mark_bit)) {
718 WhiteToGreyAndPush(map, map_mark_bit); 725 WhiteToGreyAndPush(map, map_mark_bit);
719 } 726 }
720 727
721 // TODO(gc) switch to static visitor instead of normal visitor. 728 // TODO(gc) switch to static visitor instead of normal visitor.
722 if (map == global_context_map) { 729 if (map == global_context_map) {
723 // Global contexts have weak fields. 730 // Global contexts have weak fields.
724 Context* ctx = Context::cast(obj); 731 Context* ctx = Context::cast(obj);
725 732
726 // We will mark cache black with a separate pass 733 // We will mark cache black with a separate pass
727 // when we finish marking. 734 // when we finish marking.
728 MarkObjectGreyDoNotEnqueue(ctx->normalized_map_cache()); 735 MarkObjectGreyDoNotEnqueue(ctx->normalized_map_cache());
729 736
730 VisitGlobalContext(ctx, &marking_visitor); 737 VisitGlobalContext(ctx, &marking_visitor);
731 } else { 738 } else {
732 obj->IterateBody(map->instance_type(), size, &marking_visitor); 739 obj->IterateBody(map->instance_type(), size, &marking_visitor);
733 } 740 }
734 741
735 MarkBit obj_mark_bit = Marking::MarkBitFrom(obj); 742 MarkBit obj_mark_bit = Marking::MarkBitFrom(obj);
736 ASSERT(!Marking::IsBlack(obj_mark_bit)); 743 ASSERT(Marking::IsGrey(obj_mark_bit) ||
744 (obj->IsFiller() && Marking::IsWhite(obj_mark_bit)));
737 Marking::MarkBlack(obj_mark_bit); 745 Marking::MarkBlack(obj_mark_bit);
738 MemoryChunk::IncrementLiveBytes(obj->address(), size); 746 MemoryChunk::IncrementLiveBytes(obj->address(), size);
739 } 747 }
740 if (marking_deque_.IsEmpty()) MarkingComplete(); 748 if (marking_deque_.IsEmpty()) MarkingComplete();
741 } 749 }
742 750
743 allocated_ = 0; 751 allocated_ = 0;
744 752
745 steps_count_++; 753 steps_count_++;
746 steps_count_since_last_gc_++; 754 steps_count_since_last_gc_++;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 bytes_rescanned_ = 0; 810 bytes_rescanned_ = 0;
803 allocation_marking_factor_ = kInitialAllocationMarkingFactor; 811 allocation_marking_factor_ = kInitialAllocationMarkingFactor;
804 } 812 }
805 813
806 814
807 int64_t IncrementalMarking::SpaceLeftInOldSpace() { 815 int64_t IncrementalMarking::SpaceLeftInOldSpace() {
808 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSize(); 816 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSize();
809 } 817 }
810 818
811 } } // namespace v8::internal 819 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/incremental-marking.h ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698