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

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

Issue 1813963002: Add memory pressure notification API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 #ifndef V8_HEAP_HEAP_H_ 5 #ifndef V8_HEAP_HEAP_H_
6 #define V8_HEAP_HEAP_H_ 6 #define V8_HEAP_HEAP_H_
7 7
8 #include <cmath> 8 #include <cmath>
9 #include <map> 9 #include <map>
10 10
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 }; 405 };
406 406
407 407
408 enum ArrayStorageAllocationMode { 408 enum ArrayStorageAllocationMode {
409 DONT_INITIALIZE_ARRAY_ELEMENTS, 409 DONT_INITIALIZE_ARRAY_ELEMENTS,
410 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE 410 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE
411 }; 411 };
412 412
413 enum class ClearRecordedSlots { kYes, kNo }; 413 enum class ClearRecordedSlots { kYes, kNo };
414 414
415 enum class MemoryPressureLevel { kNone, kModerate, kCritical };
jochen (gone - plz use gerrit) 2016/03/17 19:33:39 why not just use the external class?
ulan 2016/03/18 12:49:41 Done.
416
415 class Heap { 417 class Heap {
416 public: 418 public:
417 // Declare all the root indices. This defines the root list order. 419 // Declare all the root indices. This defines the root list order.
418 enum RootListIndex { 420 enum RootListIndex {
419 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, 421 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex,
420 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) 422 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION)
421 #undef ROOT_INDEX_DECLARATION 423 #undef ROOT_INDEX_DECLARATION
422 424
423 #define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex, 425 #define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex,
424 INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION) 426 INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION)
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 // 731 //
730 // Support for the API. 732 // Support for the API.
731 // 733 //
732 734
733 void CreateApiObjects(); 735 void CreateApiObjects();
734 736
735 // Implements the corresponding V8 API function. 737 // Implements the corresponding V8 API function.
736 bool IdleNotification(double deadline_in_seconds); 738 bool IdleNotification(double deadline_in_seconds);
737 bool IdleNotification(int idle_time_in_ms); 739 bool IdleNotification(int idle_time_in_ms);
738 740
741 void MemoryPressureNotification(MemoryPressureLevel level,
742 bool is_isolate_locked);
743
739 double MonotonicallyIncreasingTimeInMs(); 744 double MonotonicallyIncreasingTimeInMs();
740 745
741 void RecordStats(HeapStats* stats, bool take_snapshot = false); 746 void RecordStats(HeapStats* stats, bool take_snapshot = false);
742 747
743 // Check new space expansion criteria and expand semispaces if it was hit. 748 // Check new space expansion criteria and expand semispaces if it was hit.
744 void CheckNewSpaceExpansionCriteria(); 749 void CheckNewSpaceExpansionCriteria();
745 750
746 inline bool HeapIsFullEnoughToStartIncrementalMarking(intptr_t limit) { 751 inline bool HeapIsFullEnoughToStartIncrementalMarking(intptr_t limit) {
747 if (FLAG_stress_compaction && (gc_count_ & 1) != 0) return true; 752 if (FLAG_stress_compaction && (gc_count_ & 1) != 0) return true;
748 753
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 int size_in_bytes); 831 int size_in_bytes);
827 832
828 bool deserialization_complete() const { return deserialization_complete_; } 833 bool deserialization_complete() const { return deserialization_complete_; }
829 834
830 bool HasLowAllocationRate(); 835 bool HasLowAllocationRate();
831 bool HasHighFragmentation(); 836 bool HasHighFragmentation();
832 bool HasHighFragmentation(intptr_t used, intptr_t committed); 837 bool HasHighFragmentation(intptr_t used, intptr_t committed);
833 838
834 void SetOptimizeForLatency() { optimize_for_memory_usage_ = false; } 839 void SetOptimizeForLatency() { optimize_for_memory_usage_ = false; }
835 void SetOptimizeForMemoryUsage(); 840 void SetOptimizeForMemoryUsage();
836 bool ShouldOptimizeForMemoryUsage() { return optimize_for_memory_usage_; } 841 bool ShouldOptimizeForMemoryUsage() {
842 return optimize_for_memory_usage_ ||
843 memory_pressure_level_.Value() != MemoryPressureLevel::kNone;
844 }
837 845
838 // =========================================================================== 846 // ===========================================================================
839 // Initialization. =========================================================== 847 // Initialization. ===========================================================
840 // =========================================================================== 848 // ===========================================================================
841 849
842 // Configure heap size in MB before setup. Return false if the heap has been 850 // Configure heap size in MB before setup. Return false if the heap has been
843 // set up already. 851 // set up already.
844 bool ConfigureHeap(int max_semi_space_size, int max_old_space_size, 852 bool ConfigureHeap(int max_semi_space_size, int max_old_space_size,
845 int max_executable_size, size_t code_range_size); 853 int max_executable_size, size_t code_range_size);
846 bool ConfigureHeapDefault(); 854 bool ConfigureHeapDefault();
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 // scavenge since last new space expansion. 1997 // scavenge since last new space expansion.
1990 intptr_t survived_since_last_expansion_; 1998 intptr_t survived_since_last_expansion_;
1991 1999
1992 // ... and since the last scavenge. 2000 // ... and since the last scavenge.
1993 intptr_t survived_last_scavenge_; 2001 intptr_t survived_last_scavenge_;
1994 2002
1995 // This is not the depth of nested AlwaysAllocateScope's but rather a single 2003 // This is not the depth of nested AlwaysAllocateScope's but rather a single
1996 // count, as scopes can be acquired from multiple tasks (read: threads). 2004 // count, as scopes can be acquired from multiple tasks (read: threads).
1997 AtomicNumber<size_t> always_allocate_scope_count_; 2005 AtomicNumber<size_t> always_allocate_scope_count_;
1998 2006
2007 AtomicValue<MemoryPressureLevel> memory_pressure_level_;
2008
1999 // For keeping track of context disposals. 2009 // For keeping track of context disposals.
2000 int contexts_disposed_; 2010 int contexts_disposed_;
2001 2011
2002 // The length of the retained_maps array at the time of context disposal. 2012 // The length of the retained_maps array at the time of context disposal.
2003 // This separates maps in the retained_maps array that were created before 2013 // This separates maps in the retained_maps array that were created before
2004 // and after context disposal. 2014 // and after context disposal.
2005 int number_of_disposed_maps_; 2015 int number_of_disposed_maps_;
2006 2016
2007 int global_ic_age_; 2017 int global_ic_age_;
2008 2018
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
2634 friend class LargeObjectSpace; 2644 friend class LargeObjectSpace;
2635 friend class NewSpace; 2645 friend class NewSpace;
2636 friend class PagedSpace; 2646 friend class PagedSpace;
2637 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); 2647 DISALLOW_COPY_AND_ASSIGN(AllocationObserver);
2638 }; 2648 };
2639 2649
2640 } // namespace internal 2650 } // namespace internal
2641 } // namespace v8 2651 } // namespace v8
2642 2652
2643 #endif // V8_HEAP_HEAP_H_ 2653 #endif // V8_HEAP_HEAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698