Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1501)

Unified Diff: test/cctest/cctest.h

Issue 876613002: Only use FreeSpace objects in the free list. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/serialize.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/cctest.h
diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h
index e3e7607479bed4e6d7afb0d19a3924bd3c4d2d35..92ea2fb85a1c7875f5022da7fe71d27f5d65728b 100644
--- a/test/cctest/cctest.h
+++ b/test/cctest/cctest.h
@@ -486,27 +486,39 @@ static inline bool FillUpOnePage(v8::internal::NewSpace* space) {
v8::internal::AllocationResult allocation =
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(), v8::internal::Page::kMaxRegularHeapObjectSize);
+ v8::internal::HeapObject* free_space;
+ CHECK(allocation.To(&free_space));
+ space->heap()->CreateFillerObjectAt(
+ free_space->address(), 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() -
+// Helper function that simulates a fill new-space in the heap.
+static inline void AllocateAllButNBytes(v8::internal::NewSpace* space,
+ int extra_bytes) {
+ int space_remaining = 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);
+ CHECK(space_remaining >= extra_bytes);
+ int new_linear_size = space_remaining - extra_bytes;
+ if (new_linear_size == 0) return;
+ v8::internal::AllocationResult allocation =
+ space->AllocateRaw(new_linear_size);
+ v8::internal::HeapObject* free_space;
+ CHECK(allocation.To(&free_space));
+ space->heap()->CreateFillerObjectAt(free_space->address(), new_linear_size);
+}
+
+
+static inline void FillCurrentPage(v8::internal::NewSpace* space) {
+ AllocateAllButNBytes(space, 0);
+}
+
+
+static inline void SimulateFullSpace(v8::internal::NewSpace* space) {
+ FillCurrentPage(space);
+ while (FillUpOnePage(space)) {
}
- // Fill up all remaining pages.
- while (FillUpOnePage(space))
- ;
}
« no previous file with comments | « src/serialize.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698