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

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

Issue 1577853007: [heap] Parallel newspace evacuation, semispace copy, and compaction \o/ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Various non-functional changes Created 4 years, 11 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 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 void PrintShortHeapStatistics(); 921 void PrintShortHeapStatistics();
922 922
923 inline HeapState gc_state() { return gc_state_; } 923 inline HeapState gc_state() { return gc_state_; }
924 924
925 inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; } 925 inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; }
926 926
927 // If an object has an AllocationMemento trailing it, return it, otherwise 927 // If an object has an AllocationMemento trailing it, return it, otherwise
928 // return NULL; 928 // return NULL;
929 inline AllocationMemento* FindAllocationMemento(HeapObject* object); 929 inline AllocationMemento* FindAllocationMemento(HeapObject* object);
930 930
931 inline AllocationMemento* FindAllocationMementoCandidate(HeapObject* object);
932
931 // Returns false if not able to reserve. 933 // Returns false if not able to reserve.
932 bool ReserveSpace(Reservation* reservations); 934 bool ReserveSpace(Reservation* reservations);
933 935
934 // 936 //
935 // Support for the API. 937 // Support for the API.
936 // 938 //
937 939
938 void CreateApiObjects(); 940 void CreateApiObjects();
939 941
940 // Implements the corresponding V8 API function. 942 // Implements the corresponding V8 API function.
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 // Returns the available bytes in space w/o growing. 1402 // Returns the available bytes in space w/o growing.
1401 // Heap doesn't guarantee that it can allocate an object that requires 1403 // Heap doesn't guarantee that it can allocate an object that requires
1402 // all available bytes. Check MaxHeapObjectSize() instead. 1404 // all available bytes. Check MaxHeapObjectSize() instead.
1403 intptr_t Available(); 1405 intptr_t Available();
1404 1406
1405 // Returns of size of all objects residing in the heap. 1407 // Returns of size of all objects residing in the heap.
1406 intptr_t SizeOfObjects(); 1408 intptr_t SizeOfObjects();
1407 1409
1408 void UpdateSurvivalStatistics(int start_new_space_size); 1410 void UpdateSurvivalStatistics(int start_new_space_size);
1409 1411
1410 inline void IncrementPromotedObjectsSize(int object_size) { 1412 inline void IncrementPromotedObjectsSize(intptr_t object_size) {
1411 DCHECK_GE(object_size, 0); 1413 DCHECK_GE(object_size, 0);
1412 promoted_objects_size_ += object_size; 1414 promoted_objects_size_.Increment(object_size);
1413 } 1415 }
1414 inline intptr_t promoted_objects_size() { return promoted_objects_size_; }
1415 1416
1416 inline void IncrementSemiSpaceCopiedObjectSize(int object_size) { 1417 inline intptr_t promoted_objects_size() {
1418 return promoted_objects_size_.Value();
1419 }
1420
1421 inline void IncrementSemiSpaceCopiedObjectSize(intptr_t object_size) {
1417 DCHECK_GE(object_size, 0); 1422 DCHECK_GE(object_size, 0);
1418 semi_space_copied_object_size_ += object_size; 1423 semi_space_copied_object_size_.Increment(object_size);
1419 } 1424 }
1425
1420 inline intptr_t semi_space_copied_object_size() { 1426 inline intptr_t semi_space_copied_object_size() {
1421 return semi_space_copied_object_size_; 1427 return semi_space_copied_object_size_.Value();
1422 } 1428 }
1423 1429
1424 inline intptr_t SurvivedNewSpaceObjectSize() { 1430 inline intptr_t SurvivedNewSpaceObjectSize() {
1425 return promoted_objects_size_ + semi_space_copied_object_size_; 1431 return promoted_objects_size() + semi_space_copied_object_size();
1426 } 1432 }
1427 1433
1428 inline void IncrementNodesDiedInNewSpace() { nodes_died_in_new_space_++; } 1434 inline void IncrementNodesDiedInNewSpace() { nodes_died_in_new_space_++; }
1429 1435
1430 inline void IncrementNodesCopiedInNewSpace() { nodes_copied_in_new_space_++; } 1436 inline void IncrementNodesCopiedInNewSpace() { nodes_copied_in_new_space_++; }
1431 1437
1432 inline void IncrementNodesPromoted() { nodes_promoted_++; } 1438 inline void IncrementNodesPromoted() { nodes_promoted_++; }
1433 1439
1434 inline void IncrementYoungSurvivorsCounter(int survived) { 1440 inline void IncrementYoungSurvivorsCounter(intptr_t survived) {
1435 DCHECK(survived >= 0); 1441 DCHECK(survived >= 0);
1436 survived_last_scavenge_ = survived; 1442 survived_last_scavenge_.SetValue(survived);
1437 survived_since_last_expansion_ += survived; 1443 survived_since_last_expansion_.Increment(survived);
1444 }
1445
1446 intptr_t survived_last_scavenge() { return survived_last_scavenge_.Value(); }
1447
1448 intptr_t survived_since_last_expansion() {
1449 return survived_since_last_expansion_.Value();
1438 } 1450 }
1439 1451
1440 inline intptr_t PromotedTotalSize() { 1452 inline intptr_t PromotedTotalSize() {
1441 int64_t total = PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize(); 1453 int64_t total = PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize();
1442 if (total > std::numeric_limits<intptr_t>::max()) { 1454 if (total > std::numeric_limits<intptr_t>::max()) {
1443 // TODO(erikcorry): Use uintptr_t everywhere we do heap size calculations. 1455 // TODO(erikcorry): Use uintptr_t everywhere we do heap size calculations.
1444 return std::numeric_limits<intptr_t>::max(); 1456 return std::numeric_limits<intptr_t>::max();
1445 } 1457 }
1446 if (total < 0) return 0; 1458 if (total < 0) return 0;
1447 return static_cast<intptr_t>(total); 1459 return static_cast<intptr_t>(total);
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 int initial_semispace_size_; 2186 int initial_semispace_size_;
2175 int target_semispace_size_; 2187 int target_semispace_size_;
2176 intptr_t max_old_generation_size_; 2188 intptr_t max_old_generation_size_;
2177 intptr_t initial_old_generation_size_; 2189 intptr_t initial_old_generation_size_;
2178 bool old_generation_size_configured_; 2190 bool old_generation_size_configured_;
2179 intptr_t max_executable_size_; 2191 intptr_t max_executable_size_;
2180 intptr_t maximum_committed_; 2192 intptr_t maximum_committed_;
2181 2193
2182 // For keeping track of how much data has survived 2194 // For keeping track of how much data has survived
2183 // scavenge since last new space expansion. 2195 // scavenge since last new space expansion.
2184 int survived_since_last_expansion_; 2196 AtomicNumber<intptr_t> survived_since_last_expansion_;
2185 2197
2186 // ... and since the last scavenge. 2198 // ... and since the last scavenge.
2187 int survived_last_scavenge_; 2199 AtomicNumber<intptr_t> survived_last_scavenge_;
2188 2200
2189 // This is not the depth of nested AlwaysAllocateScope's but rather a single 2201 // This is not the depth of nested AlwaysAllocateScope's but rather a single
2190 // count, as scopes can be acquired from multiple tasks (read: threads). 2202 // count, as scopes can be acquired from multiple tasks (read: threads).
2191 AtomicNumber<size_t> always_allocate_scope_count_; 2203 AtomicNumber<size_t> always_allocate_scope_count_;
2192 2204
2193 // For keeping track of context disposals. 2205 // For keeping track of context disposals.
2194 int contexts_disposed_; 2206 int contexts_disposed_;
2195 2207
2196 // The length of the retained_maps array at the time of context disposal. 2208 // The length of the retained_maps array at the time of context disposal.
2197 // This separates maps in the retained_maps array that were created before 2209 // This separates maps in the retained_maps array that were created before
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 List<GCCallbackPair> gc_prologue_callbacks_; 2287 List<GCCallbackPair> gc_prologue_callbacks_;
2276 2288
2277 // Total RegExp code ever generated 2289 // Total RegExp code ever generated
2278 double total_regexp_code_generated_; 2290 double total_regexp_code_generated_;
2279 2291
2280 int deferred_counters_[v8::Isolate::kUseCounterFeatureCount]; 2292 int deferred_counters_[v8::Isolate::kUseCounterFeatureCount];
2281 2293
2282 GCTracer* tracer_; 2294 GCTracer* tracer_;
2283 2295
2284 int high_survival_rate_period_length_; 2296 int high_survival_rate_period_length_;
2285 intptr_t promoted_objects_size_; 2297 AtomicNumber<intptr_t> promoted_objects_size_;
2286 double promotion_ratio_; 2298 double promotion_ratio_;
2287 double promotion_rate_; 2299 double promotion_rate_;
2288 intptr_t semi_space_copied_object_size_; 2300 AtomicNumber<intptr_t> semi_space_copied_object_size_;
2289 intptr_t previous_semi_space_copied_object_size_; 2301 intptr_t previous_semi_space_copied_object_size_;
2290 double semi_space_copied_rate_; 2302 double semi_space_copied_rate_;
2291 int nodes_died_in_new_space_; 2303 int nodes_died_in_new_space_;
2292 int nodes_copied_in_new_space_; 2304 int nodes_copied_in_new_space_;
2293 int nodes_promoted_; 2305 int nodes_promoted_;
2294 2306
2295 // This is the pretenuring trigger for allocation sites that are in maybe 2307 // This is the pretenuring trigger for allocation sites that are in maybe
2296 // tenure state. When we switched to the maximum new space size we deoptimize 2308 // tenure state. When we switched to the maximum new space size we deoptimize
2297 // the code that belongs to the allocation site and derive the lifetime 2309 // the code that belongs to the allocation site and derive the lifetime
2298 // of the allocation site. 2310 // of the allocation site.
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2725 public: 2737 public:
2726 virtual ~WeakObjectRetainer() {} 2738 virtual ~WeakObjectRetainer() {}
2727 2739
2728 // Return whether this object should be retained. If NULL is returned the 2740 // Return whether this object should be retained. If NULL is returned the
2729 // object has no references. Otherwise the address of the retained object 2741 // object has no references. Otherwise the address of the retained object
2730 // should be returned as in some GC situations the object has been moved. 2742 // should be returned as in some GC situations the object has been moved.
2731 virtual Object* RetainAs(Object* object) = 0; 2743 virtual Object* RetainAs(Object* object) = 0;
2732 }; 2744 };
2733 2745
2734 2746
2747 class TimedScope {
2748 public:
2749 TimedScope(Heap* heap, double* result)
2750 : heap_(heap),
2751 start_(heap->MonotonicallyIncreasingTimeInMs()),
2752 result_(result) {}
2753
2754 ~TimedScope() {
2755 *result_ = heap_->MonotonicallyIncreasingTimeInMs() - start_;
2756 }
2757
2758 private:
2759 Heap* heap_;
2760 double start_;
2761 double* result_;
2762 };
2763
2764
2735 #ifdef DEBUG 2765 #ifdef DEBUG
2736 // Helper class for tracing paths to a search target Object from all roots. 2766 // Helper class for tracing paths to a search target Object from all roots.
2737 // The TracePathFrom() method can be used to trace paths from a specific 2767 // The TracePathFrom() method can be used to trace paths from a specific
2738 // object to the search target object. 2768 // object to the search target object.
2739 class PathTracer : public ObjectVisitor { 2769 class PathTracer : public ObjectVisitor {
2740 public: 2770 public:
2741 enum WhatToFind { 2771 enum WhatToFind {
2742 FIND_ALL, // Will find all matches. 2772 FIND_ALL, // Will find all matches.
2743 FIND_FIRST // Will stop the search after first match. 2773 FIND_FIRST // Will stop the search after first match.
2744 }; 2774 };
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2786 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. 2816 DisallowHeapAllocation no_allocation; // i.e. no gc allowed.
2787 2817
2788 private: 2818 private:
2789 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 2819 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
2790 }; 2820 };
2791 #endif // DEBUG 2821 #endif // DEBUG
2792 } // namespace internal 2822 } // namespace internal
2793 } // namespace v8 2823 } // namespace v8
2794 2824
2795 #endif // V8_HEAP_HEAP_H_ 2825 #endif // V8_HEAP_HEAP_H_
OLDNEW
« no previous file with comments | « src/heap/array-buffer-tracker.cc ('k') | src/heap/heap.cc » ('j') | src/heap/heap-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698