Reviewers: Hannes Payer,
Description:
Fix %SetFlags("--stress-compaction")
BUG=369943
LOG=N
Please review this at https://codereview.chromium.org/261253006/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+15, -9 lines):
M src/heap.h
M src/heap-inl.h
M src/spaces-inl.h
A + test/mjsunit/regress/regress-set-flags-stress-compact.js
Index: src/heap-inl.h
diff --git a/src/heap-inl.h b/src/heap-inl.h
index
40f4142db75296d99cc97b87306ab5768ef481ba..f7033bba98b6b4c9383489dcc42d4f71f39d5123
100644
--- a/src/heap-inl.h
+++ b/src/heap-inl.h
@@ -306,6 +306,11 @@ bool Heap::ShouldBePromoted(Address old_address, int
object_size) {
// An object should be promoted if:
// - the object has survived a scavenge operation or
// - to space is already 25% full.
+
+ // Stress compaction adds extra filler to each allocation,
+ // account for it here.
+ object_size += NewSpaceAllocationFillerFactor() * object_size;
+
NewSpacePage* page = NewSpacePage::FromAddress(old_address);
Address age_mark = new_space_.age_mark();
bool below_mark = page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK)
&&
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
44e1b94593546a78bb7d4ea09d3babea7a7bdd41..64cfa896ac70e0a8143a810f5091a6c1dc563914
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -1205,6 +1205,10 @@ class Heap {
void VisitExternalResources(v8::ExternalResourceVisitor* visitor);
+ inline int NewSpaceAllocationFillerFactor() {
+ return (FLAG_stress_compaction && !linear_allocation()) ? 4 : 0;
+ }
+
// Helper function that governs the promotion policy from new space to
// old. If the object's old address lies below the new space's age
// mark or if we've already filled the bottom 1/16th of the to space,
Index: src/spaces-inl.h
diff --git a/src/spaces-inl.h b/src/spaces-inl.h
index
da9c03d9137b9d2510778ea95a97c4355962f911..6c0f413480c4dcc66833bc141f0e6890b042ee2a
100644
--- a/src/spaces-inl.h
+++ b/src/spaces-inl.h
@@ -293,9 +293,9 @@ AllocationResult NewSpace::AllocateRaw(int
size_in_bytes) {
#ifdef DEBUG
// If we are stressing compaction we waste some memory in new space
// in order to get more frequent GCs.
- if (FLAG_stress_compaction && !heap()->linear_allocation()) {
- if (allocation_info_.limit() - old_top >= size_in_bytes * 4) {
- int filler_size = size_in_bytes * 4;
+ if (heap()->NewSpaceAllocationFillerFactor() > 0) {
+ int filler_size = size_in_bytes *
heap()->NewSpaceAllocationFillerFactor();
+ if (allocation_info_.limit() - old_top >= filler_size) {
for (int i = 0; i < filler_size; i += kPointerSize) {
*(reinterpret_cast<Object**>(old_top + i)) =
heap()->one_pointer_filler_map();
Index: test/mjsunit/regress/regress-set-flags-stress-compact.js
diff --git a/test/mjsunit/regress/regress-355486.js
b/test/mjsunit/regress/regress-set-flags-stress-compact.js
similarity index 63%
copy from test/mjsunit/regress/regress-355486.js
copy to test/mjsunit/regress/regress-set-flags-stress-compact.js
index
55362a13416335b72bfa1ff92bc29f7a04edbd65..5bc59a7e1107fa2938029ebde868caf502fe3997
100644
--- a/test/mjsunit/regress/regress-355486.js
+++ b/test/mjsunit/regress/regress-set-flags-stress-compact.js
@@ -4,10 +4,7 @@
// Flags: --allow-natives-syntax
-function f() { var v = arguments[0]; }
-function g() { f(); }
+%SetFlags("--gc-interval=164 --stress-compaction");
-g();
-g();
-%OptimizeFunctionOnNextCall(g);
-g();
+var a = [];
+for (var i = 0; i < 10000; i++) { a[i * 100] = 0; }
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.