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

Unified Diff: test/cctest/test-spaces.cc

Issue 652543007: Add support for a target new space size (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 2 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 | « test/cctest/cctest.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-spaces.cc
diff --git a/test/cctest/test-spaces.cc b/test/cctest/test-spaces.cc
index 5c01f5bc281d4ca2e1da51b6f819933300d958b1..5667b201571f4ebb24b9a542bbd4134dba5982eb 100644
--- a/test/cctest/test-spaces.cc
+++ b/test/cctest/test-spaces.cc
@@ -456,3 +456,54 @@ TEST(SizeOfFirstPageIsLargeEnough) {
// No large objects required to perform the above steps.
CHECK(isolate->heap()->lo_space()->IsEmpty());
}
+
+
+static inline void FillCurrentPage(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;
+ 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);
+}
+
+
+UNINITIALIZED_TEST(NewSpaceGrowsToTargetCapacity) {
+ FLAG_target_semi_space_size = 2;
+
+ v8::Isolate* isolate = v8::Isolate::New();
+ {
+ v8::Isolate::Scope isolate_scope(isolate);
+ v8::HandleScope handle_scope(isolate);
+ v8::Context::New(isolate)->Enter();
+
+ Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate);
+
+ NewSpace* new_space = i_isolate->heap()->new_space();
+
+ // This test doesn't work if we start with a non-default new space
+ // configuration.
+ if (new_space->InitialTotalCapacity() == Page::kPageSize) {
+ CHECK(new_space->CommittedMemory() == new_space->InitialTotalCapacity());
+
+ // Fill up the first (and only) page of the semi space.
+ FillCurrentPage(new_space);
+
+ // Try to allocate out of the new space. A new page should be added and
+ // the
+ // allocation should succeed.
+ v8::internal::AllocationResult allocation = new_space->AllocateRaw(80);
+ CHECK(!allocation.IsRetry());
+ CHECK(new_space->CommittedMemory() == 2 * Page::kPageSize);
+
+ // Turn the allocation into a proper object so isolate teardown won't
+ // crash.
+ v8::internal::FreeListNode* node =
+ v8::internal::FreeListNode::cast(allocation.ToObjectChecked());
+ node->set_size(new_space->heap(), 80);
+ }
+ }
+ isolate->Dispose();
+}
« no previous file with comments | « test/cctest/cctest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698