summaryrefslogtreecommitdiff
path: root/deps/v8/src/spaces.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/spaces.h')
-rw-r--r--deps/v8/src/spaces.h102
1 files changed, 56 insertions, 46 deletions
diff --git a/deps/v8/src/spaces.h b/deps/v8/src/spaces.h
index 9ffa94048..2fdb96f3f 100644
--- a/deps/v8/src/spaces.h
+++ b/deps/v8/src/spaces.h
@@ -243,8 +243,10 @@ class Page {
static const int kPageHeaderSize = kPointerSize + kPointerSize + kIntSize +
kIntSize + kPointerSize;
- // The start offset of the object area in a page.
- static const int kObjectStartOffset = MAP_POINTER_ALIGN(kPageHeaderSize);
+ // The start offset of the object area in a page. Aligned to both maps and
+ // code alignment to be suitable for both.
+ static const int kObjectStartOffset =
+ CODE_POINTER_ALIGN(MAP_POINTER_ALIGN(kPageHeaderSize));
// Object area size in bytes.
static const int kObjectAreaSize = kPageSize - kObjectStartOffset;
@@ -369,7 +371,7 @@ class Space : public Malloced {
// Identity used in error reporting.
AllocationSpace identity() { return id_; }
- virtual int Size() = 0;
+ virtual intptr_t Size() = 0;
#ifdef ENABLE_HEAP_PROTECTION
// Protect/unprotect the space by marking it read-only/writable.
@@ -489,7 +491,7 @@ class MemoryAllocator : public AllStatic {
public:
// Initializes its internal bookkeeping structures.
// Max capacity of the total space.
- static bool Setup(int max_capacity);
+ static bool Setup(intptr_t max_capacity);
// Deletes valid chunks.
static void TearDown();
@@ -580,16 +582,18 @@ class MemoryAllocator : public AllStatic {
MemoryAllocationCallback callback);
// Returns the maximum available bytes of heaps.
- static int Available() { return capacity_ < size_ ? 0 : capacity_ - size_; }
+ static intptr_t Available() {
+ return capacity_ < size_ ? 0 : capacity_ - size_;
+ }
// Returns allocated spaces in bytes.
- static int Size() { return size_; }
+ static intptr_t Size() { return size_; }
// Returns allocated executable spaces in bytes.
- static int SizeExecutable() { return size_executable_; }
+ static intptr_t SizeExecutable() { return size_executable_; }
// Returns maximum available bytes that the old space can have.
- static int MaxAvailable() {
+ static intptr_t MaxAvailable() {
return (Available() / Page::kPageSize) * Page::kObjectAreaSize;
}
@@ -647,12 +651,12 @@ class MemoryAllocator : public AllStatic {
private:
// Maximum space size in bytes.
- static int capacity_;
+ static intptr_t capacity_;
// Allocated space size in bytes.
- static int size_;
+ static intptr_t size_;
// Allocated executable space size in bytes.
- static int size_executable_;
+ static intptr_t size_executable_;
struct MemoryAllocationCallbackRegistration {
MemoryAllocationCallbackRegistration(MemoryAllocationCallback callback,
@@ -925,10 +929,10 @@ class AllocationStats BASE_EMBEDDED {
}
// Accessors for the allocation statistics.
- int Capacity() { return capacity_; }
- int Available() { return available_; }
- int Size() { return size_; }
- int Waste() { return waste_; }
+ intptr_t Capacity() { return capacity_; }
+ intptr_t Available() { return available_; }
+ intptr_t Size() { return size_; }
+ intptr_t Waste() { return waste_; }
// Grow the space by adding available bytes.
void ExpandSpace(int size_in_bytes) {
@@ -943,13 +947,13 @@ class AllocationStats BASE_EMBEDDED {
}
// Allocate from available bytes (available -> size).
- void AllocateBytes(int size_in_bytes) {
+ void AllocateBytes(intptr_t size_in_bytes) {
available_ -= size_in_bytes;
size_ += size_in_bytes;
}
// Free allocated bytes, making them available (size -> available).
- void DeallocateBytes(int size_in_bytes) {
+ void DeallocateBytes(intptr_t size_in_bytes) {
size_ -= size_in_bytes;
available_ += size_in_bytes;
}
@@ -962,23 +966,25 @@ class AllocationStats BASE_EMBEDDED {
// Consider the wasted bytes to be allocated, as they contain filler
// objects (waste -> size).
- void FillWastedBytes(int size_in_bytes) {
+ void FillWastedBytes(intptr_t size_in_bytes) {
waste_ -= size_in_bytes;
size_ += size_in_bytes;
}
private:
- int capacity_;
- int available_;
- int size_;
- int waste_;
+ intptr_t capacity_;
+ intptr_t available_;
+ intptr_t size_;
+ intptr_t waste_;
};
class PagedSpace : public Space {
public:
// Creates a space with a maximum capacity, and an id.
- PagedSpace(int max_capacity, AllocationSpace id, Executability executable);
+ PagedSpace(intptr_t max_capacity,
+ AllocationSpace id,
+ Executability executable);
virtual ~PagedSpace() {}
@@ -1029,21 +1035,21 @@ class PagedSpace : public Space {
}
// Current capacity without growing (Size() + Available() + Waste()).
- int Capacity() { return accounting_stats_.Capacity(); }
+ intptr_t Capacity() { return accounting_stats_.Capacity(); }
// Total amount of memory committed for this space. For paged
// spaces this equals the capacity.
- int CommittedMemory() { return Capacity(); }
+ intptr_t CommittedMemory() { return Capacity(); }
// Available bytes without growing.
- int Available() { return accounting_stats_.Available(); }
+ intptr_t Available() { return accounting_stats_.Available(); }
// Allocated bytes in this space.
- virtual int Size() { return accounting_stats_.Size(); }
+ virtual intptr_t Size() { return accounting_stats_.Size(); }
// Wasted bytes due to fragmentation and not recoverable until the
// next GC of this space.
- int Waste() { return accounting_stats_.Waste(); }
+ intptr_t Waste() { return accounting_stats_.Waste(); }
// Returns the address of the first object in this space.
Address bottom() { return first_page_->ObjectAreaStart(); }
@@ -1135,7 +1141,7 @@ class PagedSpace : public Space {
protected:
// Maximum capacity of this space.
- int max_capacity_;
+ intptr_t max_capacity_;
// Accounting information for this space.
AllocationStats accounting_stats_;
@@ -1326,7 +1332,7 @@ class SemiSpace : public Space {
// If we don't have these here then SemiSpace will be abstract. However
// they should never be called.
- virtual int Size() {
+ virtual intptr_t Size() {
UNREACHABLE();
return 0;
}
@@ -1469,22 +1475,26 @@ class NewSpace : public Space {
}
// Return the allocated bytes in the active semispace.
- virtual int Size() { return static_cast<int>(top() - bottom()); }
+ virtual intptr_t Size() { return static_cast<int>(top() - bottom()); }
+ // The same, but returning an int. We have to have the one that returns
+ // intptr_t because it is inherited, but if we know we are dealing with the
+ // 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.
- int Capacity() {
+ intptr_t Capacity() {
ASSERT(to_space_.Capacity() == from_space_.Capacity());
return to_space_.Capacity();
}
// Return the total amount of memory committed for new space.
- int CommittedMemory() {
+ intptr_t CommittedMemory() {
if (from_space_.is_committed()) return 2 * Capacity();
return Capacity();
}
// Return the available bytes without growing in the active semispace.
- int Available() { return Capacity() - Size(); }
+ intptr_t Available() { return Capacity() - Size(); }
// Return the maximum capacity of a semispace.
int MaximumCapacity() {
@@ -1679,7 +1689,7 @@ class OldSpaceFreeList BASE_EMBEDDED {
void Reset();
// Return the number of bytes available on the free list.
- int available() { return available_; }
+ intptr_t available() { return available_; }
// Place a node on the free list. The block of size 'size_in_bytes'
// starting at 'start' is placed on the free list. The return value is the
@@ -1781,7 +1791,7 @@ class FixedSizeFreeList BASE_EMBEDDED {
void Reset();
// Return the number of bytes available on the free list.
- int available() { return available_; }
+ intptr_t available() { return available_; }
// Place a node on the free list. The block starting at 'start' (assumed to
// have size object_size_) is placed on the free list. Bookkeeping
@@ -1795,7 +1805,7 @@ class FixedSizeFreeList BASE_EMBEDDED {
private:
// Available bytes on the free list.
- int available_;
+ intptr_t available_;
// The head of the free list.
Address head_;
@@ -1821,7 +1831,7 @@ class OldSpace : public PagedSpace {
public:
// Creates an old space object with a given maximum capacity.
// The constructor does not allocate pages from OS.
- explicit OldSpace(int max_capacity,
+ explicit OldSpace(intptr_t max_capacity,
AllocationSpace id,
Executability executable)
: PagedSpace(max_capacity, id, executable), free_list_(id) {
@@ -1830,7 +1840,7 @@ class OldSpace : public PagedSpace {
// The bytes available on the free list (ie, not above the linear allocation
// pointer).
- int AvailableFree() { return free_list_.available(); }
+ intptr_t AvailableFree() { return free_list_.available(); }
// The limit of allocation for a page in this space.
virtual Address PageAllocationLimit(Page* page) {
@@ -1891,7 +1901,7 @@ class OldSpace : public PagedSpace {
class FixedSpace : public PagedSpace {
public:
- FixedSpace(int max_capacity,
+ FixedSpace(intptr_t max_capacity,
AllocationSpace id,
int object_size_in_bytes,
const char* name)
@@ -1966,7 +1976,7 @@ class FixedSpace : public PagedSpace {
class MapSpace : public FixedSpace {
public:
// Creates a map space object with a maximum capacity.
- MapSpace(int max_capacity, int max_map_space_pages, AllocationSpace id)
+ MapSpace(intptr_t max_capacity, int max_map_space_pages, AllocationSpace id)
: FixedSpace(max_capacity, id, Map::kSize, "map"),
max_map_space_pages_(max_map_space_pages) {
ASSERT(max_map_space_pages < kMaxMapPageIndex);
@@ -2071,7 +2081,7 @@ class MapSpace : public FixedSpace {
class CellSpace : public FixedSpace {
public:
// Creates a property cell space object with a maximum capacity.
- CellSpace(int max_capacity, AllocationSpace id)
+ CellSpace(intptr_t max_capacity, AllocationSpace id)
: FixedSpace(max_capacity, id, JSGlobalPropertyCell::kSize, "cell") {}
protected:
@@ -2127,7 +2137,7 @@ class LargeObjectChunk {
// Given a chunk size, returns the object size it can accommodate. Used by
// LargeObjectSpace::Available.
- static int ObjectSizeFor(int chunk_size) {
+ static intptr_t ObjectSizeFor(intptr_t chunk_size) {
if (chunk_size <= (Page::kPageSize + Page::kObjectStartOffset)) return 0;
return chunk_size - Page::kPageSize - Page::kObjectStartOffset;
}
@@ -2163,11 +2173,11 @@ class LargeObjectSpace : public Space {
Object* AllocateRawFixedArray(int size_in_bytes);
// Available bytes for objects in this space.
- int Available() {
+ intptr_t Available() {
return LargeObjectChunk::ObjectSizeFor(MemoryAllocator::Available());
}
- virtual int Size() {
+ virtual intptr_t Size() {
return size_;
}
@@ -2221,7 +2231,7 @@ class LargeObjectSpace : public Space {
private:
// The head of the linked list of large object chunks.
LargeObjectChunk* first_chunk_;
- int size_; // allocated bytes
+ intptr_t size_; // allocated bytes
int page_count_; // number of chunks