Make test-dictionary work for GC stress builder.
authormstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 20 Nov 2012 10:47:31 +0000 (10:47 +0000)
committermstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 20 Nov 2012 10:47:31 +0000 (10:47 +0000)
R=yangguo@chromium.org
TEST=cctest/test-dictionary

Review URL: https://codereview.chromium.org/11299098

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13010 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

test/cctest/cctest.h
test/cctest/test-alloc.cc
test/cctest/test-api.cc
test/cctest/test-dictionary.cc
test/cctest/test-heap.cc

index f3961a4..88cb9b8 100644 (file)
@@ -233,4 +233,24 @@ static inline int FlagDependentPortOffset() {
 }
 
 
+// Helper function that simulates a fill 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());
+  v8::internal::MaybeObject* maybe = space->AllocateRaw(new_linear_size);
+  v8::internal::FreeListNode* node = v8::internal::FreeListNode::cast(maybe);
+  node->set_size(space->heap(), new_linear_size);
+}
+
+
+// Helper function that simulates a full old-space in the heap.
+static inline void SimulateFullSpace(v8::internal::PagedSpace* space) {
+  int old_linear_size = static_cast<int>(space->limit() - space->top());
+  space->Free(space->top(), old_linear_size);
+  space->SetTop(space->limit(), space->limit());
+  space->ResetFreeList();
+  space->ClearStats();
+}
+
+
 #endif  // ifndef CCTEST_H_
index 7ba2583..91979f1 100644 (file)
 using namespace v8::internal;
 
 
-// Also used in test-heap.cc test cases.
-void SimulateFullSpace(PagedSpace* space) {
-  int old_linear_size = static_cast<int>(space->limit() - space->top());
-  space->Free(space->top(), old_linear_size);
-  space->SetTop(space->limit(), space->limit());
-  space->ResetFreeList();
-  space->ClearStats();
-}
-
-
 static MaybeObject* AllocateAfterFailures() {
   static int attempts = 0;
   if (++attempts < 3) return Failure::RetryAfterGC();
index f9880bd..d241118 100644 (file)
@@ -11505,10 +11505,6 @@ static void event_handler(const v8::JitCodeEvent* event) {
 }
 
 
-// Implemented in the test-alloc.cc test suite.
-void SimulateFullSpace(i::PagedSpace* space);
-
-
 static bool MatchPointers(void* key1, void* key2) {
   return key1 == key2;
 }
index 00e3833..2acd4e6 100644 (file)
@@ -114,7 +114,8 @@ TEST(ObjectHashSetCausesGC) {
 
   // Simulate a full heap so that generating an identity hash code
   // in subsequent calls will request GC.
-  FLAG_gc_interval = 0;
+  SimulateFullSpace(HEAP->new_space());
+  SimulateFullSpace(HEAP->old_pointer_space());
 
   // Calling Contains() should not cause GC ever.
   CHECK(!table->Contains(*key));
@@ -143,7 +144,8 @@ TEST(ObjectHashTableCausesGC) {
 
   // Simulate a full heap so that generating an identity hash code
   // in subsequent calls will request GC.
-  FLAG_gc_interval = 0;
+  SimulateFullSpace(HEAP->new_space());
+  SimulateFullSpace(HEAP->old_pointer_space());
 
   // Calling Lookup() should not cause GC ever.
   CHECK(table->Lookup(*key)->IsTheHole());
index 8dee692..a51b37e 100644 (file)
@@ -1781,10 +1781,6 @@ TEST(InstanceOfStubWriteBarrier) {
 }
 
 
-// Implemented in the test-alloc.cc test suite.
-void SimulateFullSpace(PagedSpace* space);
-
-
 TEST(PrototypeTransitionClearing) {
   InitializeVM();
   v8::HandleScope scope;