Reviewers: Michael Starzinger,

Description:
Make --stress-compaction more stressful.

Please review this at https://chromiumcodereview.appspot.com/10141007/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/heap.h
  M     src/heap.cc
  M     src/spaces-inl.h
  M     test/mjsunit/regexp-capture-3.js


Index: src/heap.cc
===================================================================
--- src/heap.cc (revision 11422)
+++ src/heap.cc (working copy)
@@ -238,12 +238,17 @@
 GarbageCollector Heap::SelectGarbageCollector(AllocationSpace space,
                                               const char** reason) {
   // Is global GC requested?
-  if (space != NEW_SPACE || FLAG_gc_global) {
+  if (space != NEW_SPACE) {
     isolate_->counters()->gc_compactor_caused_by_request()->Increment();
     *reason = "GC in old space requested";
     return MARK_COMPACTOR;
   }

+  if (FLAG_gc_global || (FLAG_stress_compaction && (gc_count_ & 1) != 0)) {
+    *reason = "GC in old space forced by flags";
+    return MARK_COMPACTOR;
+  }
+
   // Is enough data promoted to justify a global GC?
   if (OldGenerationPromotionLimitReached()) {
isolate_->counters()->gc_compactor_caused_by_promoted_data()->Increment();
@@ -5695,6 +5700,11 @@
                          intptr_t max_executable_size) {
   if (HasBeenSetUp()) return false;

+  if (FLAG_stress_compaction) {
+    // This will cause more frequent GCs when stressing.
+    max_semispace_size_ = Page::kPageSize;
+  }
+
   if (max_semispace_size > 0) {
     if (max_semispace_size < Page::kPageSize) {
       max_semispace_size = Page::kPageSize;
@@ -6131,6 +6141,9 @@


 void Heap::TearDown() {
+  if (FLAG_verify_heap) {
+    Verify();
+  }
   if (FLAG_print_cumulative_gc_stat) {
     PrintF("\n\n");
     PrintF("gc_count=%d ", gc_count_);
Index: src/heap.h
===================================================================
--- src/heap.h  (revision 11422)
+++ src/heap.h  (working copy)
@@ -1455,6 +1455,8 @@
   inline bool NextGCIsLikelyToBeFull() {
     if (FLAG_gc_global) return true;

+    if (FLAG_stress_compaction && (gc_count_ & 1) != 0) return true;
+
     intptr_t total_promoted = PromotedTotalSize();

     intptr_t adjusted_promotion_limit =
Index: src/spaces-inl.h
===================================================================
--- src/spaces-inl.h    (revision 11422)
+++ src/spaces-inl.h    (working copy)
@@ -295,11 +295,25 @@

 MaybeObject* NewSpace::AllocateRaw(int size_in_bytes) {
   Address old_top = allocation_info_.top;
+#ifdef DEBUG
+  if (FLAG_stress_compaction) {
+    if (allocation_info_.limit - old_top >= size_in_bytes * 4) {
+      int filler_size = size_in_bytes * 4;
+      for (int i = 0; i < filler_size; i += kPointerSize) {
+        *(reinterpret_cast<Object**>(old_top + i)) =
+            HEAP->one_pointer_filler_map();
+      }
+      old_top += filler_size;
+      allocation_info_.top += filler_size;
+    }
+  }
+#endif
+
   if (allocation_info_.limit - old_top < size_in_bytes) {
     return SlowAllocateRaw(size_in_bytes);
   }

-  Object* obj = HeapObject::FromAddress(allocation_info_.top);
+  Object* obj = HeapObject::FromAddress(old_top);
   allocation_info_.top += size_in_bytes;
   ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);

Index: test/mjsunit/regexp-capture-3.js
===================================================================
--- test/mjsunit/regexp-capture-3.js    (revision 11422)
+++ test/mjsunit/regexp-capture-3.js    (working copy)
@@ -149,6 +149,8 @@
 assertEquals("bar", RegExp.$1);


+// A test that initially does a zero width match, but later does a non-zero
+// width match.
 var a = "foo bar baz".replace(/^|bar/g, "");
 assertEquals("foo  baz", a);



--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to