Index: test/cctest/cctest.h |
diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h |
index 4f078690e1d3bd81f0919bf6be30c97a827e193e..a8239d26fb218e882755aca02e0bb0738a99e094 100644 |
--- a/test/cctest/cctest.h |
+++ b/test/cctest/cctest.h |
@@ -481,15 +481,31 @@ static inline void ExpectUndefined(const char* code) { |
// Helper function that simulates a full new-space in the heap. |
-static inline void SimulateFullSpace(v8::internal::NewSpace* space) { |
- int new_linear_size = static_cast<int>( |
- *space->allocation_limit_address() - *space->allocation_top_address()); |
- if (new_linear_size == 0) return; |
+static inline bool FillUpOnePage(v8::internal::NewSpace* space) { |
v8::internal::AllocationResult allocation = |
- space->AllocateRaw(new_linear_size); |
+ space->AllocateRaw(v8::internal::Page::kMaxRegularHeapObjectSize); |
+ if (allocation.IsRetry()) return false; |
v8::internal::FreeListNode* node = |
v8::internal::FreeListNode::cast(allocation.ToObjectChecked()); |
- node->set_size(space->heap(), new_linear_size); |
+ node->set_size(space->heap(), v8::internal::Page::kMaxRegularHeapObjectSize); |
+ return true; |
+} |
+ |
+ |
+static inline void SimulateFullSpace(v8::internal::NewSpace* space) { |
+ int new_linear_size = static_cast<int>(*space->allocation_limit_address() - |
+ *space->allocation_top_address()); |
+ if (new_linear_size > 0) { |
+ // Fill up the current page. |
+ v8::internal::AllocationResult allocation = |
+ space->AllocateRaw(new_linear_size); |
+ v8::internal::FreeListNode* node = |
+ v8::internal::FreeListNode::cast(allocation.ToObjectChecked()); |
+ node->set_size(space->heap(), new_linear_size); |
+ } |
+ // Fill up all remaining pages. |
+ while (FillUpOnePage(space)) |
+ ; |
} |