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

Side by Side Diff: src/heap/heap.cc

Issue 894703002: Add a flag to over approximate the weak closure during GC (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 #ifdef DEBUG 728 #ifdef DEBUG
729 ReportStatisticsAfterGC(); 729 ReportStatisticsAfterGC();
730 #endif // DEBUG 730 #endif // DEBUG
731 731
732 // Remember the last top pointer so that we can later find out 732 // Remember the last top pointer so that we can later find out
733 // whether we allocated in new space since the last GC. 733 // whether we allocated in new space since the last GC.
734 new_space_top_after_last_gc_ = new_space()->top(); 734 new_space_top_after_last_gc_ = new_space()->top();
735 } 735 }
736 736
737 737
738 void Heap::HandleGCRequest() {
739 if (incremental_marking()->IsComplete()) {
740 CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt");
741 return;
742 }
743 DCHECK(FLAG_overapproximate_weak_closure);
744 DCHECK(!incremental_marking()->weak_closure_was_overapproximated());
745 OverApproximateWeakClosure("GC interrupt");
746 }
747
748
749 void Heap::OverApproximateWeakClosure(const char* gc_reason) {
750 if (FLAG_trace_incremental_marking) {
751 PrintF("[IncrementalMarking] Overapproximate weak closure (%s).\n",
752 gc_reason);
753 }
754 {
755 GCCallbacksScope scope(this);
756 if (scope.CheckReenter()) {
757 AllowHeapAllocation allow_allocation;
758 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL);
759 VMState<EXTERNAL> state(isolate_);
760 HandleScope handle_scope(isolate_);
761 CallGCPrologueCallbacks(kGCTypeMarkSweepCompact, kNoGCCallbackFlags);
762 }
763 }
764 mark_compact_collector()->OverApproximateWeakClosure();
765 incremental_marking()->set_should_hurry(false);
766 incremental_marking()->set_weak_closure_was_overapproximated(true);
767 {
768 GCCallbacksScope scope(this);
769 if (scope.CheckReenter()) {
770 AllowHeapAllocation allow_allocation;
771 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL);
772 VMState<EXTERNAL> state(isolate_);
773 HandleScope handle_scope(isolate_);
774 CallGCEpilogueCallbacks(kGCTypeMarkSweepCompact, kNoGCCallbackFlags);
775 }
776 }
777 }
778
779
738 void Heap::CollectAllGarbage(int flags, const char* gc_reason, 780 void Heap::CollectAllGarbage(int flags, const char* gc_reason,
739 const v8::GCCallbackFlags gc_callback_flags) { 781 const v8::GCCallbackFlags gc_callback_flags) {
740 // Since we are ignoring the return value, the exact choice of space does 782 // Since we are ignoring the return value, the exact choice of space does
741 // not matter, so long as we do not specify NEW_SPACE, which would not 783 // not matter, so long as we do not specify NEW_SPACE, which would not
742 // cause a full GC. 784 // cause a full GC.
743 mark_compact_collector_.SetFlags(flags); 785 mark_compact_collector_.SetFlags(flags);
744 CollectGarbage(OLD_POINTER_SPACE, gc_reason, gc_callback_flags); 786 CollectGarbage(OLD_POINTER_SPACE, gc_reason, gc_callback_flags);
745 mark_compact_collector_.SetFlags(kNoGCFlags); 787 mark_compact_collector_.SetFlags(kNoGCFlags);
746 } 788 }
747 789
(...skipping 5702 matching lines...) Expand 10 before | Expand all | Expand 10 after
6450 static_cast<int>(object_sizes_last_time_[index])); 6492 static_cast<int>(object_sizes_last_time_[index]));
6451 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6493 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6452 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6494 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6453 6495
6454 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6496 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6455 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6497 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6456 ClearObjectStats(); 6498 ClearObjectStats();
6457 } 6499 }
6458 } 6500 }
6459 } // namespace v8::internal 6501 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698