summaryrefslogtreecommitdiff
path: root/deps/v8/src/heap/spaces.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/heap/spaces.h')
-rw-r--r--deps/v8/src/heap/spaces.h101
1 files changed, 48 insertions, 53 deletions
diff --git a/deps/v8/src/heap/spaces.h b/deps/v8/src/heap/spaces.h
index 312d75f52e..ef55357163 100644
--- a/deps/v8/src/heap/spaces.h
+++ b/deps/v8/src/heap/spaces.h
@@ -7,6 +7,7 @@
#include "src/allocation.h"
#include "src/base/atomicops.h"
+#include "src/base/bits.h"
#include "src/base/platform/mutex.h"
#include "src/hashmap.h"
#include "src/list.h"
@@ -373,12 +374,9 @@ class MemoryChunk {
EVACUATION_CANDIDATE,
RESCAN_ON_EVACUATION,
- // Pages swept precisely can be iterated, hitting only the live objects.
- // Whereas those swept conservatively cannot be iterated over. Both flags
- // indicate that marking bits have been cleared by the sweeper, otherwise
- // marking bits are still intact.
- WAS_SWEPT_PRECISELY,
- WAS_SWEPT_CONSERVATIVELY,
+ // WAS_SWEPT indicates that marking bits have been cleared by the sweeper,
+ // otherwise marking bits are still intact.
+ WAS_SWEPT,
// Large objects can have a progress bar in their page header. These object
// are scanned in increments and will be kept black while being scanned.
@@ -765,15 +763,9 @@ class Page : public MemoryChunk {
void InitializeAsAnchor(PagedSpace* owner);
- bool WasSweptPrecisely() { return IsFlagSet(WAS_SWEPT_PRECISELY); }
- bool WasSweptConservatively() { return IsFlagSet(WAS_SWEPT_CONSERVATIVELY); }
- bool WasSwept() { return WasSweptPrecisely() || WasSweptConservatively(); }
-
- void MarkSweptPrecisely() { SetFlag(WAS_SWEPT_PRECISELY); }
- void MarkSweptConservatively() { SetFlag(WAS_SWEPT_CONSERVATIVELY); }
-
- void ClearSweptPrecisely() { ClearFlag(WAS_SWEPT_PRECISELY); }
- void ClearSweptConservatively() { ClearFlag(WAS_SWEPT_CONSERVATIVELY); }
+ bool WasSwept() { return IsFlagSet(WAS_SWEPT); }
+ void SetWasSwept() { SetFlag(WAS_SWEPT); }
+ void ClearWasSwept() { ClearFlag(WAS_SWEPT); }
void ResetFreeListStatistics();
@@ -888,6 +880,10 @@ class CodeRange {
DCHECK(valid());
return static_cast<Address>(code_range_->address());
}
+ size_t size() {
+ DCHECK(valid());
+ return code_range_->size();
+ }
bool contains(Address address) {
if (!valid()) return false;
Address start = static_cast<Address>(code_range_->address());
@@ -1830,14 +1826,11 @@ class PagedSpace : public Space {
static void ResetCodeStatistics(Isolate* isolate);
#endif
- bool swept_precisely() { return swept_precisely_; }
- void set_swept_precisely(bool b) { swept_precisely_ = b; }
-
// Evacuation candidates are swept by evacuator. Needs to return a valid
// result before _and_ after evacuation has finished.
static bool ShouldBeSweptBySweeperThreads(Page* p) {
return !p->IsEvacuationCandidate() &&
- !p->IsFlagSet(Page::RESCAN_ON_EVACUATION) && !p->WasSweptPrecisely();
+ !p->IsFlagSet(Page::RESCAN_ON_EVACUATION) && !p->WasSwept();
}
void IncrementUnsweptFreeBytes(intptr_t by) { unswept_free_bytes_ += by; }
@@ -1907,12 +1900,8 @@ class PagedSpace : public Space {
// Normal allocation information.
AllocationInfo allocation_info_;
- // This space was swept precisely, hence it is iterable.
- bool swept_precisely_;
-
// The number of free bytes which could be reclaimed by advancing the
- // concurrent sweeper threads. This is only an estimation because concurrent
- // sweeping is done conservatively.
+ // concurrent sweeper threads.
intptr_t unswept_free_bytes_;
// The sweeper threads iterate over the list of pointer and data space pages
@@ -2028,7 +2017,7 @@ class NewSpacePage : public MemoryChunk {
Address address() { return reinterpret_cast<Address>(this); }
- // Finds the NewSpacePage containg the given address.
+ // Finds the NewSpacePage containing the given address.
static inline NewSpacePage* FromAddress(Address address_in_page) {
Address page_start =
reinterpret_cast<Address>(reinterpret_cast<uintptr_t>(address_in_page) &
@@ -2176,14 +2165,14 @@ class SemiSpace : public Space {
inline static void AssertValidRange(Address from, Address to) {}
#endif
- // Returns the current capacity of the semi space.
- int Capacity() { return capacity_; }
+ // Returns the current total capacity of the semispace.
+ int TotalCapacity() { return total_capacity_; }
- // Returns the maximum capacity of the semi space.
- int MaximumCapacity() { return maximum_capacity_; }
+ // Returns the maximum total capacity of the semispace.
+ int MaximumTotalCapacity() { return maximum_total_capacity_; }
- // Returns the initial capacity of the semi space.
- int InitialCapacity() { return initial_capacity_; }
+ // Returns the initial capacity of the semispace.
+ int InitialTotalCapacity() { return initial_total_capacity_; }
SemiSpaceId id() { return id_; }
@@ -2205,10 +2194,10 @@ class SemiSpace : public Space {
NewSpacePage* anchor() { return &anchor_; }
- // The current and maximum capacity of the space.
- int capacity_;
- int maximum_capacity_;
- int initial_capacity_;
+ // The current and maximum total capacity of the space.
+ int total_capacity_;
+ int maximum_total_capacity_;
+ int initial_total_capacity_;
intptr_t maximum_committed_;
@@ -2378,22 +2367,24 @@ class NewSpace : public Space {
// new space, which can't get as big as the other spaces then this is useful:
int SizeAsInt() { return static_cast<int>(Size()); }
- // Return the current capacity of a semispace.
- intptr_t EffectiveCapacity() {
- SLOW_DCHECK(to_space_.Capacity() == from_space_.Capacity());
- return (to_space_.Capacity() / Page::kPageSize) * NewSpacePage::kAreaSize;
+ // Return the allocatable capacity of a semispace.
+ intptr_t Capacity() {
+ SLOW_DCHECK(to_space_.TotalCapacity() == from_space_.TotalCapacity());
+ return (to_space_.TotalCapacity() / Page::kPageSize) *
+ NewSpacePage::kAreaSize;
}
- // Return the current capacity of a semispace.
- intptr_t Capacity() {
- DCHECK(to_space_.Capacity() == from_space_.Capacity());
- return to_space_.Capacity();
+ // Return the current size of a semispace, allocatable and non-allocatable
+ // memory.
+ intptr_t TotalCapacity() {
+ DCHECK(to_space_.TotalCapacity() == from_space_.TotalCapacity());
+ return to_space_.TotalCapacity();
}
// Return the total amount of memory committed for new space.
intptr_t CommittedMemory() {
if (from_space_.is_committed()) return 2 * Capacity();
- return Capacity();
+ return TotalCapacity();
}
// Return the total amount of memory committed for new space.
@@ -2410,16 +2401,18 @@ class NewSpace : public Space {
// Return the maximum capacity of a semispace.
int MaximumCapacity() {
- DCHECK(to_space_.MaximumCapacity() == from_space_.MaximumCapacity());
- return to_space_.MaximumCapacity();
+ DCHECK(to_space_.MaximumTotalCapacity() ==
+ from_space_.MaximumTotalCapacity());
+ return to_space_.MaximumTotalCapacity();
}
- bool IsAtMaximumCapacity() { return Capacity() == MaximumCapacity(); }
+ bool IsAtMaximumCapacity() { return TotalCapacity() == MaximumCapacity(); }
// Returns the initial capacity of a semispace.
- int InitialCapacity() {
- DCHECK(to_space_.InitialCapacity() == from_space_.InitialCapacity());
- return to_space_.InitialCapacity();
+ int InitialTotalCapacity() {
+ DCHECK(to_space_.InitialTotalCapacity() ==
+ from_space_.InitialTotalCapacity());
+ return to_space_.InitialTotalCapacity();
}
// Return the address of the allocation pointer in the active semispace.
@@ -2636,7 +2629,7 @@ class MapSpace : public PagedSpace {
static const int kMaxMapPageIndex = 1 << 16;
virtual int RoundSizeDownToObjectAlignment(int size) {
- if (IsPowerOf2(Map::kSize)) {
+ if (base::bits::IsPowerOfTwo32(Map::kSize)) {
return RoundDown(size, Map::kSize);
} else {
return (size / Map::kSize) * Map::kSize;
@@ -2671,7 +2664,7 @@ class CellSpace : public PagedSpace {
: PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE) {}
virtual int RoundSizeDownToObjectAlignment(int size) {
- if (IsPowerOf2(Cell::kSize)) {
+ if (base::bits::IsPowerOfTwo32(Cell::kSize)) {
return RoundDown(size, Cell::kSize);
} else {
return (size / Cell::kSize) * Cell::kSize;
@@ -2696,7 +2689,7 @@ class PropertyCellSpace : public PagedSpace {
: PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE) {}
virtual int RoundSizeDownToObjectAlignment(int size) {
- if (IsPowerOf2(PropertyCell::kSize)) {
+ if (base::bits::IsPowerOfTwo32(PropertyCell::kSize)) {
return RoundDown(size, PropertyCell::kSize);
} else {
return (size / PropertyCell::kSize) * PropertyCell::kSize;
@@ -2739,6 +2732,8 @@ class LargeObjectSpace : public Space {
MUST_USE_RESULT AllocationResult
AllocateRaw(int object_size, Executability executable);
+ bool CanAllocateSize(int size) { return Size() + size <= max_capacity_; }
+
// Available bytes for objects in this space.
inline intptr_t Available();