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

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

Issue 1213313004: Start incremental marking in long idle notification for background tab (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 5 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
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/memory-reducer.h » ('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 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 4938 matching lines...) Expand 10 before | Expand all | Expand 10 after
4949 if (FLAG_trace_idle_notification_verbose) { 4949 if (FLAG_trace_idle_notification_verbose) {
4950 PrintF("["); 4950 PrintF("[");
4951 heap_state.Print(); 4951 heap_state.Print();
4952 PrintF("]"); 4952 PrintF("]");
4953 } 4953 }
4954 PrintF("\n"); 4954 PrintF("\n");
4955 } 4955 }
4956 } 4956 }
4957 4957
4958 4958
4959 void Heap::CheckAndNotifyBackgroundIdleNotification(double idle_time_in_ms,
4960 double now_ms) {
4961 if (idle_time_in_ms >= GCIdleTimeHandler::kMinBackgroundIdleTime) {
4962 MemoryReducer::Event event;
4963 event.type = MemoryReducer::kBackgroundIdleNotification;
4964 event.time_ms = now_ms;
4965 event.can_start_incremental_gc = incremental_marking()->IsStopped() &&
4966 incremental_marking()->CanBeActivated();
4967 memory_reducer_.NotifyBackgroundIdleNotification(event);
4968 }
4969 }
4970
4971
4959 double Heap::MonotonicallyIncreasingTimeInMs() { 4972 double Heap::MonotonicallyIncreasingTimeInMs() {
4960 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * 4973 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() *
4961 static_cast<double>(base::Time::kMillisecondsPerSecond); 4974 static_cast<double>(base::Time::kMillisecondsPerSecond);
4962 } 4975 }
4963 4976
4964 4977
4965 bool Heap::IdleNotification(int idle_time_in_ms) { 4978 bool Heap::IdleNotification(int idle_time_in_ms) {
4966 return IdleNotification( 4979 return IdleNotification(
4967 V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() + 4980 V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() +
4968 (static_cast<double>(idle_time_in_ms) / 4981 (static_cast<double>(idle_time_in_ms) /
4969 static_cast<double>(base::Time::kMillisecondsPerSecond))); 4982 static_cast<double>(base::Time::kMillisecondsPerSecond)));
4970 } 4983 }
4971 4984
4972 4985
4973 bool Heap::IdleNotification(double deadline_in_seconds) { 4986 bool Heap::IdleNotification(double deadline_in_seconds) {
4974 CHECK(HasBeenSetUp()); 4987 CHECK(HasBeenSetUp());
4975 double deadline_in_ms = 4988 double deadline_in_ms =
4976 deadline_in_seconds * 4989 deadline_in_seconds *
4977 static_cast<double>(base::Time::kMillisecondsPerSecond); 4990 static_cast<double>(base::Time::kMillisecondsPerSecond);
4978 HistogramTimerScope idle_notification_scope( 4991 HistogramTimerScope idle_notification_scope(
4979 isolate_->counters()->gc_idle_notification()); 4992 isolate_->counters()->gc_idle_notification());
4980 double start_ms = MonotonicallyIncreasingTimeInMs(); 4993 double start_ms = MonotonicallyIncreasingTimeInMs();
4981 double idle_time_in_ms = deadline_in_ms - start_ms; 4994 double idle_time_in_ms = deadline_in_ms - start_ms;
4982 4995
4996 CheckAndNotifyBackgroundIdleNotification(idle_time_in_ms, start_ms);
4997
4983 tracer()->SampleAllocation(start_ms, NewSpaceAllocationCounter(), 4998 tracer()->SampleAllocation(start_ms, NewSpaceAllocationCounter(),
4984 OldGenerationAllocationCounter()); 4999 OldGenerationAllocationCounter());
4985 5000
4986 GCIdleTimeHandler::HeapState heap_state = ComputeHeapState(); 5001 GCIdleTimeHandler::HeapState heap_state = ComputeHeapState();
4987 5002
4988 GCIdleTimeAction action = 5003 GCIdleTimeAction action =
4989 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); 5004 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state);
4990 5005
4991 bool result = PerformIdleTimeAction(action, heap_state, deadline_in_ms); 5006 bool result = PerformIdleTimeAction(action, heap_state, deadline_in_ms);
4992 5007
(...skipping 1884 matching lines...) Expand 10 before | Expand all | Expand 10 after
6877 *object_type = "CODE_TYPE"; \ 6892 *object_type = "CODE_TYPE"; \
6878 *object_sub_type = "CODE_AGE/" #name; \ 6893 *object_sub_type = "CODE_AGE/" #name; \
6879 return true; 6894 return true;
6880 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6895 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6881 #undef COMPARE_AND_RETURN_NAME 6896 #undef COMPARE_AND_RETURN_NAME
6882 } 6897 }
6883 return false; 6898 return false;
6884 } 6899 }
6885 } // namespace internal 6900 } // namespace internal
6886 } // namespace v8 6901 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/memory-reducer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698