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

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

Issue 1323993004: [heap] Separate scavenger functionality into own file. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 5 years, 3 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 | « BUILD.gn ('k') | src/heap/heap.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 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
11 #include "src/allocation.h" 11 #include "src/allocation.h"
12 #include "src/assert-scope.h" 12 #include "src/assert-scope.h"
13 #include "src/atomic-utils.h" 13 #include "src/atomic-utils.h"
14 #include "src/globals.h" 14 #include "src/globals.h"
15 #include "src/heap/gc-idle-time-handler.h" 15 #include "src/heap/gc-idle-time-handler.h"
16 #include "src/heap/incremental-marking.h" 16 #include "src/heap/incremental-marking.h"
17 #include "src/heap/mark-compact.h" 17 #include "src/heap/mark-compact.h"
18 #include "src/heap/objects-visiting.h"
19 #include "src/heap/spaces.h" 18 #include "src/heap/spaces.h"
20 #include "src/heap/store-buffer.h" 19 #include "src/heap/store-buffer.h"
21 #include "src/list.h" 20 #include "src/list.h"
22 21
23 namespace v8 { 22 namespace v8 {
24 namespace internal { 23 namespace internal {
25 24
26 // Defines all the roots in Heap. 25 // Defines all the roots in Heap.
27 #define STRONG_ROOT_LIST(V) \ 26 #define STRONG_ROOT_LIST(V) \
28 V(Map, byte_array_map, ByteArrayMap) \ 27 V(Map, byte_array_map, ByteArrayMap) \
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 V(empty_string) \ 419 V(empty_string) \
421 PRIVATE_SYMBOL_LIST(V) 420 PRIVATE_SYMBOL_LIST(V)
422 421
423 // Forward declarations. 422 // Forward declarations.
424 class ArrayBufferTracker; 423 class ArrayBufferTracker;
425 class HeapObjectsFilter; 424 class HeapObjectsFilter;
426 class HeapStats; 425 class HeapStats;
427 class Isolate; 426 class Isolate;
428 class MemoryReducer; 427 class MemoryReducer;
429 class ObjectStats; 428 class ObjectStats;
429 class Scavenger;
430 class WeakObjectRetainer; 430 class WeakObjectRetainer;
431 431
432 432
433 // A queue of objects promoted during scavenge. Each object is accompanied 433 // A queue of objects promoted during scavenge. Each object is accompanied
434 // by it's size to avoid dereferencing a map pointer for scanning. 434 // by it's size to avoid dereferencing a map pointer for scanning.
435 // The last page in to-space is used for the promotion queue. On conflict 435 // The last page in to-space is used for the promotion queue. On conflict
436 // during scavenge, the promotion queue is allocated externally and all 436 // during scavenge, the promotion queue is allocated externally and all
437 // entries are copied to the external queue. 437 // entries are copied to the external queue.
438 class PromotionQueue { 438 class PromotionQueue {
439 public: 439 public:
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 List<Entry>* emergency_stack_; 528 List<Entry>* emergency_stack_;
529 529
530 Heap* heap_; 530 Heap* heap_;
531 531
532 void RelocateQueueHead(); 532 void RelocateQueueHead();
533 533
534 DISALLOW_COPY_AND_ASSIGN(PromotionQueue); 534 DISALLOW_COPY_AND_ASSIGN(PromotionQueue);
535 }; 535 };
536 536
537 537
538 typedef void (*ScavengingCallback)(Map* map, HeapObject** slot,
539 HeapObject* object);
540
541
542 enum ArrayStorageAllocationMode { 538 enum ArrayStorageAllocationMode {
543 DONT_INITIALIZE_ARRAY_ELEMENTS, 539 DONT_INITIALIZE_ARRAY_ELEMENTS,
544 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE 540 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE
545 }; 541 };
546 542
547 543
548 class Heap { 544 class Heap {
549 public: 545 public:
550 // Declare all the root indices. This defines the root list order. 546 // Declare all the root indices. This defines the root list order.
551 enum RootListIndex { 547 enum RootListIndex {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 // Calculates the maximum amount of filler that could be required by the 708 // Calculates the maximum amount of filler that could be required by the
713 // given alignment. 709 // given alignment.
714 static int GetMaximumFillToAlign(AllocationAlignment alignment); 710 static int GetMaximumFillToAlign(AllocationAlignment alignment);
715 // Calculates the actual amount of filler required for a given address at the 711 // Calculates the actual amount of filler required for a given address at the
716 // given alignment. 712 // given alignment.
717 static int GetFillToAlign(Address address, AllocationAlignment alignment); 713 static int GetFillToAlign(Address address, AllocationAlignment alignment);
718 714
719 template <typename T> 715 template <typename T>
720 static inline bool IsOneByte(T t, int chars); 716 static inline bool IsOneByte(T t, int chars);
721 717
722 // Callback function passed to Heap::Iterate etc. Copies an object if
723 // necessary, the object might be promoted to an old space. The caller must
724 // ensure the precondition that the object is (a) a heap object and (b) in
725 // the heap's from space.
726 static inline void ScavengePointer(HeapObject** p);
727 static inline void ScavengeObject(HeapObject** p, HeapObject* object);
728
729 // Slow part of scavenge object.
730 static void ScavengeObjectSlow(HeapObject** p, HeapObject* object);
731
732 static void FatalProcessOutOfMemory(const char* location, 718 static void FatalProcessOutOfMemory(const char* location,
733 bool take_snapshot = false); 719 bool take_snapshot = false);
734 720
735 static bool RootIsImmortalImmovable(int root_index); 721 static bool RootIsImmortalImmovable(int root_index);
736 722
737 // Checks whether the space is valid. 723 // Checks whether the space is valid.
738 static bool IsValidAllocationSpace(AllocationSpace space); 724 static bool IsValidAllocationSpace(AllocationSpace space);
739 725
740 // An object may have an AllocationSite associated with it through a trailing 726 // An object may have an AllocationSite associated with it through a trailing
741 // AllocationMemento. Its feedback should be updated when objects are found 727 // AllocationMemento. Its feedback should be updated when objects are found
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 // Adds an allocation site to the scratchpad if there is space left. 1755 // Adds an allocation site to the scratchpad if there is space left.
1770 void AddAllocationSiteToScratchpad(AllocationSite* site, 1756 void AddAllocationSiteToScratchpad(AllocationSite* site,
1771 ScratchpadSlotMode mode); 1757 ScratchpadSlotMode mode);
1772 1758
1773 // TODO(hpayer): Allocation site pretenuring may make this method obsolete. 1759 // TODO(hpayer): Allocation site pretenuring may make this method obsolete.
1774 // Re-visit incremental marking heuristics. 1760 // Re-visit incremental marking heuristics.
1775 bool IsHighSurvivalRate() { return high_survival_rate_period_length_ > 0; } 1761 bool IsHighSurvivalRate() { return high_survival_rate_period_length_ > 0; }
1776 1762
1777 void ConfigureInitialOldGenerationSize(); 1763 void ConfigureInitialOldGenerationSize();
1778 1764
1779 void SelectScavengingVisitorsTable();
1780
1781 bool HasLowYoungGenerationAllocationRate(); 1765 bool HasLowYoungGenerationAllocationRate();
1782 bool HasLowOldGenerationAllocationRate(); 1766 bool HasLowOldGenerationAllocationRate();
1783 double YoungGenerationMutatorUtilization(); 1767 double YoungGenerationMutatorUtilization();
1784 double OldGenerationMutatorUtilization(); 1768 double OldGenerationMutatorUtilization();
1785 1769
1786 void ReduceNewSpaceSize(); 1770 void ReduceNewSpaceSize();
1787 1771
1788 bool TryFinalizeIdleIncrementalMarking( 1772 bool TryFinalizeIdleIncrementalMarking(
1789 double idle_time_in_ms, size_t size_of_objects, 1773 double idle_time_in_ms, size_t size_of_objects,
1790 size_t mark_compact_speed_in_bytes_per_ms); 1774 size_t mark_compact_speed_in_bytes_per_ms);
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
2252 2236
2253 // Cumulative GC time spent in sweeping. 2237 // Cumulative GC time spent in sweeping.
2254 double sweeping_time_; 2238 double sweeping_time_;
2255 2239
2256 // Last time an idle notification happened. 2240 // Last time an idle notification happened.
2257 double last_idle_notification_time_; 2241 double last_idle_notification_time_;
2258 2242
2259 // Last time a garbage collection happened. 2243 // Last time a garbage collection happened.
2260 double last_gc_time_; 2244 double last_gc_time_;
2261 2245
2246 Scavenger* scavenge_collector_;
2247
2262 MarkCompactCollector mark_compact_collector_; 2248 MarkCompactCollector mark_compact_collector_;
2263 2249
2264 StoreBuffer store_buffer_; 2250 StoreBuffer store_buffer_;
2265 2251
2266 IncrementalMarking incremental_marking_; 2252 IncrementalMarking incremental_marking_;
2267 2253
2268 GCIdleTimeHandler gc_idle_time_handler_; 2254 GCIdleTimeHandler gc_idle_time_handler_;
2269 2255
2270 MemoryReducer* memory_reducer_; 2256 MemoryReducer* memory_reducer_;
2271 2257
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 2297
2312 // Currently set GC flags that are respected by all GC components. 2298 // Currently set GC flags that are respected by all GC components.
2313 int current_gc_flags_; 2299 int current_gc_flags_;
2314 2300
2315 // Currently set GC callback flags that are used to pass information between 2301 // Currently set GC callback flags that are used to pass information between
2316 // the embedder and V8's GC. 2302 // the embedder and V8's GC.
2317 GCCallbackFlags current_gc_callback_flags_; 2303 GCCallbackFlags current_gc_callback_flags_;
2318 2304
2319 ExternalStringTable external_string_table_; 2305 ExternalStringTable external_string_table_;
2320 2306
2321 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_;
2322
2323 MemoryChunk* chunks_queued_for_free_; 2307 MemoryChunk* chunks_queued_for_free_;
2324 2308
2325 size_t concurrent_unmapping_tasks_active_; 2309 size_t concurrent_unmapping_tasks_active_;
2326 2310
2327 base::Semaphore pending_unmapping_tasks_semaphore_; 2311 base::Semaphore pending_unmapping_tasks_semaphore_;
2328 2312
2329 base::Mutex relocation_mutex_; 2313 base::Mutex relocation_mutex_;
2330 2314
2331 int gc_callbacks_depth_; 2315 int gc_callbacks_depth_;
2332 2316
2333 bool deserialization_complete_; 2317 bool deserialization_complete_;
2334 2318
2335 bool concurrent_sweeping_enabled_; 2319 bool concurrent_sweeping_enabled_;
2336 2320
2337 StrongRootsList* strong_roots_list_; 2321 StrongRootsList* strong_roots_list_;
2338 2322
2339 ArrayBufferTracker* array_buffer_tracker_; 2323 ArrayBufferTracker* array_buffer_tracker_;
2340 2324
2341 // Classes in "heap" can be friends. 2325 // Classes in "heap" can be friends.
2342 friend class AlwaysAllocateScope; 2326 friend class AlwaysAllocateScope;
2343 friend class GCCallbacksScope; 2327 friend class GCCallbacksScope;
2344 friend class GCTracer; 2328 friend class GCTracer;
2345 friend class HeapIterator; 2329 friend class HeapIterator;
2346 friend class IncrementalMarking; 2330 friend class IncrementalMarking;
2347 friend class MarkCompactCollector; 2331 friend class MarkCompactCollector;
2348 friend class MarkCompactMarkingVisitor; 2332 friend class MarkCompactMarkingVisitor;
2349 friend class ObjectStatsVisitor; 2333 friend class ObjectStatsVisitor;
2350 friend class Page; 2334 friend class Page;
2335 friend class Scavenger;
2351 friend class StoreBuffer; 2336 friend class StoreBuffer;
2352 2337
2353 // The allocator interface. 2338 // The allocator interface.
2354 friend class Factory; 2339 friend class Factory;
2355 2340
2356 // The Isolate constructs us. 2341 // The Isolate constructs us.
2357 friend class Isolate; 2342 friend class Isolate;
2358 2343
2359 // Used in cctest. 2344 // Used in cctest.
2360 friend class HeapTester; 2345 friend class HeapTester;
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
2706 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. 2691 DisallowHeapAllocation no_allocation; // i.e. no gc allowed.
2707 2692
2708 private: 2693 private:
2709 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 2694 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
2710 }; 2695 };
2711 #endif // DEBUG 2696 #endif // DEBUG
2712 } 2697 }
2713 } // namespace v8::internal 2698 } // namespace v8::internal
2714 2699
2715 #endif // V8_HEAP_HEAP_H_ 2700 #endif // V8_HEAP_HEAP_H_
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698