Reviewers: Michael Lippautz, Michael Starzinger,
Description:
Respect old generation limit in large object space allocations.
Also remove unused max_capcity_ field in old spaces.
BUG=chromium:518028,chromium:504854
Please review this at https://codereview.chromium.org/1284853003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+17, -35 lines):
M src/heap/heap.cc
M src/heap/spaces.h
M src/heap/spaces.cc
M test/cctest/test-spaces.cc
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
0e027f83b026a98b73fa4402d8828fffebb84454..583211fe4fd4fb78528ef68e936ee82dfe280986
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -1069,7 +1069,7 @@ bool Heap::ReserveSpace(Reservation* reservations) {
bool perform_gc = false;
if (space == LO_SPACE) {
DCHECK_EQ(1, reservation->length());
- perform_gc = !lo_space()->CanAllocateSize(reservation->at(0).size);
+ perform_gc = !CanExpandOldGeneration(reservation->at(0).size);
} else {
for (auto& chunk : *reservation) {
AllocationResult allocation;
@@ -5763,8 +5763,7 @@ bool Heap::SetUp() {
new_space_top_after_last_gc_ = new_space()->top();
// Initialize old space.
- old_space_ =
- new OldSpace(this, max_old_generation_size_, OLD_SPACE,
NOT_EXECUTABLE);
+ old_space_ = new OldSpace(this, OLD_SPACE, NOT_EXECUTABLE);
if (old_space_ == NULL) return false;
if (!old_space_->SetUp()) return false;
@@ -5772,20 +5771,19 @@ bool Heap::SetUp() {
// Initialize the code space, set its maximum capacity to the old
// generation size. It needs executable memory.
- code_space_ =
- new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE);
+ code_space_ = new OldSpace(this, CODE_SPACE, EXECUTABLE);
if (code_space_ == NULL) return false;
if (!code_space_->SetUp()) return false;
// Initialize map space.
- map_space_ = new MapSpace(this, max_old_generation_size_, MAP_SPACE);
+ map_space_ = new MapSpace(this, MAP_SPACE);
if (map_space_ == NULL) return false;
if (!map_space_->SetUp()) return false;
// The large object code space may contain code or data. We set the
memory
// to be non-executable here for safety, but this means we need to
enable it
// explicitly when allocating large code objects.
- lo_space_ = new LargeObjectSpace(this, max_old_generation_size_,
LO_SPACE);
+ lo_space_ = new LargeObjectSpace(this, LO_SPACE);
if (lo_space_ == NULL) return false;
if (!lo_space_->SetUp()) return false;
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index
ee7751a5a89bf28abf6b0984ea12c554f5c000e7..0d1c592ef400c26f70d877ac84e5b7faa4207b17
100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -931,7 +931,7 @@ STATIC_ASSERT(static_cast<ObjectSpace>(1 <<
AllocationSpace::MAP_SPACE) ==
ObjectSpace::kObjectSpaceMapSpace);
-PagedSpace::PagedSpace(Heap* heap, intptr_t max_capacity, AllocationSpace
space,
+PagedSpace::PagedSpace(Heap* heap, AllocationSpace space,
Executability executable)
: Space(heap, space, executable),
free_list_(this),
@@ -939,8 +939,6 @@ PagedSpace::PagedSpace(Heap* heap, intptr_t
max_capacity, AllocationSpace space,
end_of_unswept_pages_(NULL),
emergency_memory_(NULL) {
area_size_ = MemoryAllocator::PageAreaSize(space);
- max_capacity_ =
- (RoundDown(max_capacity, Page::kPageSize) / Page::kPageSize) *
AreaSize();
accounting_stats_.Clear();
allocation_info_.set_top(NULL);
@@ -1009,7 +1007,6 @@ Object* PagedSpace::FindObject(Address addr) {
bool PagedSpace::CanExpand() {
- DCHECK(max_capacity_ % AreaSize() == 0);
DCHECK(heap()->mark_compact_collector()->is_compacting() ||
Capacity() <= heap()->MaxOldGenerationSize());
DCHECK(heap()->CommittedOldGenerationMemory() <=
@@ -2808,10 +2805,8 @@ HeapObject* LargeObjectIterator::Next() {
static bool ComparePointers(void* key1, void* key2) { return key1 == key2;
}
-LargeObjectSpace::LargeObjectSpace(Heap* heap, intptr_t max_capacity,
- AllocationSpace id)
+LargeObjectSpace::LargeObjectSpace(Heap* heap, AllocationSpace id)
: Space(heap, id, NOT_EXECUTABLE), // Managed on a per-allocation
basis
- max_capacity_(max_capacity),
first_page_(NULL),
size_(0),
page_count_(0),
@@ -2850,12 +2845,10 @@ AllocationResult LargeObjectSpace::AllocateRaw(int
object_size,
// Check if we want to force a GC before growing the old space further.
// If so, fail the allocation.
if (!heap()->always_allocate() &&
- heap()->OldGenerationAllocationLimitReached()) {
+ !heap()->CanExpandOldGeneration(object_size)) {
return AllocationResult::Retry(identity());
}
- if (!CanAllocateSize(object_size)) return
AllocationResult::Retry(identity());
-
LargePage* page =
heap()->isolate()->memory_allocator()->AllocateLargePage(
object_size, this, executable);
if (page == NULL) return AllocationResult::Retry(identity());
Index: src/heap/spaces.h
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
index
11af00febd9d1371eccd95a9d71eb6a664a7a2cf..7bcaa66557a1d6180c42ee18a7200cbee6fe455b
100644
--- a/src/heap/spaces.h
+++ b/src/heap/spaces.h
@@ -1663,9 +1663,8 @@ STATIC_ASSERT(sizeof(AllocationResult) ==
kPointerSize);
class PagedSpace : public Space {
public:
- // Creates a space with a maximum capacity, and an id.
- PagedSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id,
- Executability executable);
+ // Creates a space with an id.
+ PagedSpace(Heap* heap, AllocationSpace id, Executability executable);
virtual ~PagedSpace() {}
@@ -1902,9 +1901,6 @@ class PagedSpace : public Space {
int area_size_;
- // Maximum capacity of this space.
- intptr_t max_capacity_;
-
// Accounting information for this space.
AllocationStats accounting_stats_;
@@ -2654,9 +2650,8 @@ class OldSpace : public PagedSpace {
public:
// Creates an old space object with a given maximum capacity.
// The constructor does not allocate pages from OS.
- OldSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id,
- Executability executable)
- : PagedSpace(heap, max_capacity, id, executable) {}
+ OldSpace(Heap* heap, AllocationSpace id, Executability executable)
+ : PagedSpace(heap, id, executable) {}
};
@@ -2674,8 +2669,8 @@ class OldSpace : public PagedSpace {
class MapSpace : public PagedSpace {
public:
// Creates a map space object with a maximum capacity.
- MapSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id)
- : PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE),
+ MapSpace(Heap* heap, AllocationSpace id)
+ : PagedSpace(heap, id, NOT_EXECUTABLE),
max_map_space_pages_(kMaxMapPageIndex - 1) {}
// Given an index, returns the page address.
@@ -2714,7 +2709,7 @@ class MapSpace : public PagedSpace {
class LargeObjectSpace : public Space {
public:
- LargeObjectSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id);
+ LargeObjectSpace(Heap* heap, AllocationSpace id);
virtual ~LargeObjectSpace() {}
// Initializes internal data structures.
@@ -2733,8 +2728,6 @@ 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() override;
@@ -2784,7 +2777,6 @@ class LargeObjectSpace : public Space {
bool SlowContains(Address addr) { return
FindObject(addr)->IsHeapObject(); }
private:
- intptr_t max_capacity_;
intptr_t maximum_committed_;
// The head of the linked list of large object chunks.
LargePage* first_page_;
Index: test/cctest/test-spaces.cc
diff --git a/test/cctest/test-spaces.cc b/test/cctest/test-spaces.cc
index
3f5e437223a57ba246c093ce8ce4d0ea7d061fcc..86500c52d3658eeb31ca19a79500714413b7469d
100644
--- a/test/cctest/test-spaces.cc
+++ b/test/cctest/test-spaces.cc
@@ -309,7 +309,7 @@ TEST(MemoryAllocator) {
heap->MaxExecutableSize()));
int total_pages = 0;
- OldSpace faked_space(heap, heap->MaxReserved(), OLD_SPACE,
NOT_EXECUTABLE);
+ OldSpace faked_space(heap, OLD_SPACE, NOT_EXECUTABLE);
Page* first_page = memory_allocator->AllocatePage(
faked_space.AreaSize(), &faked_space, NOT_EXECUTABLE);
@@ -379,8 +379,7 @@ TEST(OldSpace) {
heap->MaxExecutableSize()));
TestMemoryAllocatorScope test_scope(isolate, memory_allocator);
- OldSpace* s = new OldSpace(heap, heap->MaxOldGenerationSize(), OLD_SPACE,
- NOT_EXECUTABLE);
+ OldSpace* s = new OldSpace(heap, OLD_SPACE, NOT_EXECUTABLE);
CHECK(s != NULL);
CHECK(s->SetUp());
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.