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

Unified Diff: src/heap/heap.h

Issue 2490523003: [heap] Use size_t for heap and space counters. (Closed)
Patch Set: more fixes Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/gc-tracer.cc ('k') | src/heap/heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index c77902f0f634f4a8055df8f9c6b254fd63ad5ac6..75238054ea5f295c2f3f1f9e1db2cc6f0a66bfe2 100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -928,7 +928,7 @@ class Heap {
bool HasLowAllocationRate();
bool HasHighFragmentation();
- bool HasHighFragmentation(intptr_t used, intptr_t committed);
+ bool HasHighFragmentation(size_t used, size_t committed);
void ActivateMemoryReducerIfNeeded();
@@ -952,8 +952,8 @@ class Heap {
// Configure heap size in MB before setup. Return false if the heap has been
// set up already.
- bool ConfigureHeap(int max_semi_space_size, int max_old_space_size,
- int max_executable_size, size_t code_range_size);
+ bool ConfigureHeap(size_t max_semi_space_size, size_t max_old_space_size,
+ size_t max_executable_size, size_t code_range_size);
bool ConfigureHeapDefault();
// Prepares the heap, setting up memory areas that are needed in the isolate
@@ -1293,20 +1293,20 @@ class Heap {
// ===========================================================================
// Returns the maximum amount of memory reserved for the heap.
- intptr_t MaxReserved() {
+ size_t MaxReserved() {
return 2 * max_semi_space_size_ + max_old_generation_size_;
}
- int MaxSemiSpaceSize() { return max_semi_space_size_; }
- int InitialSemiSpaceSize() { return initial_semispace_size_; }
- intptr_t MaxOldGenerationSize() { return max_old_generation_size_; }
- intptr_t MaxExecutableSize() { return max_executable_size_; }
+ size_t MaxSemiSpaceSize() { return max_semi_space_size_; }
+ size_t InitialSemiSpaceSize() { return initial_semispace_size_; }
+ size_t MaxOldGenerationSize() { return max_old_generation_size_; }
+ size_t MaxExecutableSize() { return max_executable_size_; }
// Returns the capacity of the heap in bytes w/o growing. Heap grows when
// more spaces are needed until it reaches the limit.
- intptr_t Capacity();
+ size_t Capacity();
// Returns the capacity of the old generation.
- intptr_t OldGenerationCapacity();
+ size_t OldGenerationCapacity();
// Returns the amount of memory currently committed for the heap.
size_t CommittedMemory();
@@ -1330,28 +1330,26 @@ class Heap {
// Returns the available bytes in space w/o growing.
// Heap doesn't guarantee that it can allocate an object that requires
// all available bytes. Check MaxHeapObjectSize() instead.
- intptr_t Available();
+ size_t Available();
// Returns of size of all objects residing in the heap.
- intptr_t SizeOfObjects();
+ size_t SizeOfObjects();
void UpdateSurvivalStatistics(int start_new_space_size);
- inline void IncrementPromotedObjectsSize(intptr_t object_size) {
- DCHECK_GE(object_size, 0);
+ inline void IncrementPromotedObjectsSize(size_t object_size) {
promoted_objects_size_ += object_size;
}
- inline intptr_t promoted_objects_size() { return promoted_objects_size_; }
+ inline size_t promoted_objects_size() { return promoted_objects_size_; }
- inline void IncrementSemiSpaceCopiedObjectSize(intptr_t object_size) {
- DCHECK_GE(object_size, 0);
+ inline void IncrementSemiSpaceCopiedObjectSize(size_t object_size) {
semi_space_copied_object_size_ += object_size;
}
- inline intptr_t semi_space_copied_object_size() {
+ inline size_t semi_space_copied_object_size() {
return semi_space_copied_object_size_;
}
- inline intptr_t SurvivedNewSpaceObjectSize() {
+ inline size_t SurvivedNewSpaceObjectSize() {
return promoted_objects_size_ + semi_space_copied_object_size_;
}
@@ -1361,20 +1359,13 @@ class Heap {
inline void IncrementNodesPromoted() { nodes_promoted_++; }
- inline void IncrementYoungSurvivorsCounter(intptr_t survived) {
- DCHECK_GE(survived, 0);
+ inline void IncrementYoungSurvivorsCounter(size_t survived) {
survived_last_scavenge_ = survived;
survived_since_last_expansion_ += survived;
}
- inline intptr_t PromotedTotalSize() {
- int64_t total = PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize();
- if (total > std::numeric_limits<intptr_t>::max()) {
- // TODO(erikcorry): Use uintptr_t everywhere we do heap size calculations.
- return std::numeric_limits<intptr_t>::max();
- }
- if (total < 0) return 0;
- return static_cast<intptr_t>(total);
+ inline uint64_t PromotedTotalSize() {
+ return PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize();
}
inline void UpdateNewSpaceAllocationCounter();
@@ -1408,7 +1399,7 @@ class Heap {
int gc_count() const { return gc_count_; }
// Returns the size of objects residing in non new spaces.
- intptr_t PromotedSpaceSizeOfObjects();
+ size_t PromotedSpaceSizeOfObjects();
double total_regexp_code_generated() { return total_regexp_code_generated_; }
void IncreaseTotalRegexpCodeGenerated(int size) {
@@ -1821,8 +1812,10 @@ class Heap {
// GC statistics. ============================================================
// ===========================================================================
- inline intptr_t OldGenerationSpaceAvailable() {
- return old_generation_allocation_limit_ - PromotedTotalSize();
+ inline size_t OldGenerationSpaceAvailable() {
+ if (old_generation_allocation_limit_ <= PromotedTotalSize()) return 0;
+ return old_generation_allocation_limit_ -
+ static_cast<size_t>(PromotedTotalSize());
}
void UpdateTotalGCTime(double duration);
@@ -1835,23 +1828,21 @@ class Heap {
// Decrease the allocation limit if the new limit based on the given
// parameters is lower than the current limit.
- void DampenOldGenerationAllocationLimit(intptr_t old_gen_size,
- double gc_speed,
+ void DampenOldGenerationAllocationLimit(size_t old_gen_size, double gc_speed,
double mutator_speed);
-
// Calculates the allocation limit based on a given growing factor and a
// given old generation size.
- intptr_t CalculateOldGenerationAllocationLimit(double factor,
- intptr_t old_gen_size);
+ size_t CalculateOldGenerationAllocationLimit(double factor,
+ size_t old_gen_size);
// Sets the allocation limit to trigger the next full garbage collection.
- void SetOldGenerationAllocationLimit(intptr_t old_gen_size, double gc_speed,
+ void SetOldGenerationAllocationLimit(size_t old_gen_size, double gc_speed,
double mutator_speed);
- intptr_t MinimumAllocationLimitGrowingStep();
+ size_t MinimumAllocationLimitGrowingStep();
- intptr_t old_generation_allocation_limit() const {
+ size_t old_generation_allocation_limit() const {
return old_generation_allocation_limit_;
}
@@ -2116,20 +2107,20 @@ class Heap {
Object* roots_[kRootListLength];
size_t code_range_size_;
- int max_semi_space_size_;
- int initial_semispace_size_;
- intptr_t max_old_generation_size_;
- intptr_t initial_old_generation_size_;
+ size_t max_semi_space_size_;
+ size_t initial_semispace_size_;
+ size_t max_old_generation_size_;
+ size_t initial_old_generation_size_;
bool old_generation_size_configured_;
- intptr_t max_executable_size_;
+ size_t max_executable_size_;
size_t maximum_committed_;
// For keeping track of how much data has survived
// scavenge since last new space expansion.
- intptr_t survived_since_last_expansion_;
+ size_t survived_since_last_expansion_;
// ... and since the last scavenge.
- intptr_t survived_last_scavenge_;
+ size_t survived_last_scavenge_;
// This is not the depth of nested AlwaysAllocateScope's but rather a single
// count, as scopes can be acquired from multiple tasks (read: threads).
@@ -2161,7 +2152,7 @@ class Heap {
Address new_space_top_after_last_gc_;
// Returns the amount of external memory registered since last global gc.
- int64_t PromotedExternalMemorySize();
+ uint64_t PromotedExternalMemorySize();
// How many "runtime allocations" happened.
uint32_t allocations_count_;
@@ -2190,7 +2181,7 @@ class Heap {
// is checked when we have already decided to do a GC to help determine
// which collector to invoke, before expanding a paged space in the old
// generation and on every allocation in large object space.
- intptr_t old_generation_allocation_limit_;
+ size_t old_generation_allocation_limit_;
// Indicates that inline bump-pointer allocation has been globally disabled
// for all spaces. This is used to disable allocations in generated code.
@@ -2220,11 +2211,11 @@ class Heap {
GCTracer* tracer_;
- intptr_t promoted_objects_size_;
+ size_t promoted_objects_size_;
double promotion_ratio_;
double promotion_rate_;
- intptr_t semi_space_copied_object_size_;
- intptr_t previous_semi_space_copied_object_size_;
+ size_t semi_space_copied_object_size_;
+ size_t previous_semi_space_copied_object_size_;
double semi_space_copied_rate_;
int nodes_died_in_new_space_;
int nodes_copied_in_new_space_;
« no previous file with comments | « src/heap/gc-tracer.cc ('k') | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698