#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"
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.
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();
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; }
// 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
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) &
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_; }
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_;
// 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.
// 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.
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;
: 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;
: 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;