Reviewers: ulan,
Description:
Add kAbortIncrementalMarkingMask flag for GC.
This adds an additional flag to control whether incremental marking
should be aborted when requesting a GC, providing a finer granularity
between kNoGCFlags and kMakeHeapIterableMask.
[email protected]
BUG=v8:1608
Please review this at https://chromiumcodereview.appspot.com/9608006/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/heap.h
M src/heap.cc
M src/mark-compact-inl.h
M src/mark-compact.h
M src/mark-compact.cc
M src/runtime.cc
M test/cctest/test-api.cc
M test/cctest/test-deoptimization.cc
M test/cctest/test-heap.cc
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
acb1b926b213c2ab0bea23a3bd5949afbfa790a8..da98239db1ead1a20c1bedc4dabdb82bf705858a
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -499,7 +499,7 @@ bool Heap::CollectGarbage(AllocationSpace space,
}
if (collector == MARK_COMPACTOR &&
- !mark_compact_collector()->PreciseSweepingRequired() &&
+ !mark_compact_collector()->abort_incremental_marking_ &&
!incremental_marking()->IsStopped() &&
!incremental_marking()->should_hurry() &&
FLAG_incremental_marking_steps) {
@@ -582,7 +582,7 @@ static bool AbortIncrementalMarkingAndCollectGarbage(
Heap* heap,
AllocationSpace space,
const char* gc_reason = NULL) {
- heap->mark_compact_collector()->SetFlags(Heap::kMakeHeapIterableMask);
+
heap->mark_compact_collector()->SetFlags(Heap::kAbortIncrementalMarkingMask);
bool result = heap->CollectGarbage(space, gc_reason);
heap->mark_compact_collector()->SetFlags(Heap::kNoGCFlags);
return result;
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
0aacd841448c0a24581d1cafdf905d501b66a583..76442699937f3a301bfa659387ce62fac9c2f6cd
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -1043,6 +1043,7 @@ class Heap {
static const int kNoGCFlags = 0;
static const int kMakeHeapIterableMask = 1;
static const int kReduceMemoryFootprintMask = 2;
+ static const int kAbortIncrementalMarkingMask = 4;
// Performs a full garbage collection. If (flags &
kMakeHeapIterableMask) is
// non-zero, then the slower precise sweeper is used, which leaves the
heap
Index: src/mark-compact-inl.h
diff --git a/src/mark-compact-inl.h b/src/mark-compact-inl.h
index
fd25a403cae2d131a753bc22ff58276ab2053004..65ab311fdf753324bdacf4f2d890aa70e28c3ad5
100644
--- a/src/mark-compact-inl.h
+++ b/src/mark-compact-inl.h
@@ -47,6 +47,9 @@ MarkBit Marking::MarkBitFrom(Address addr) {
void MarkCompactCollector::SetFlags(int flags) {
sweep_precisely_ = ((flags & Heap::kMakeHeapIterableMask) != 0);
reduce_memory_footprint_ = ((flags &
Heap::kReduceMemoryFootprintMask) != 0);
+ // Precise sweeping requires us to abort any incremental marking as well.
+ abort_incremental_marking_ = ((flags &
(Heap::kAbortIncrementalMarkingMask |
+ Heap::kMakeHeapIterableMask)) != 0);
}
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index
7c59c0471e4b81c74169ad75beff6a50776168e1..3db91ced8b44eed2654394303502700c1e50024f
100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -686,8 +686,10 @@ void MarkCompactCollector::Prepare(GCTracer* tracer) {
}
#endif
- // Clear marking bits for precise sweeping to collect all garbage.
- if (was_marked_incrementally_ && PreciseSweepingRequired()) {
+ // Clear marking bits if incremental marking is aborted (required for
+ // precise sweeping to collect all garbage).
+ ASSERT(abort_incremental_marking_ || !sweep_precisely_);
+ if (was_marked_incrementally_ && abort_incremental_marking_) {
heap()->incremental_marking()->Abort();
ClearMarkbits();
AbortCompaction();
Index: src/mark-compact.h
diff --git a/src/mark-compact.h b/src/mark-compact.h
index
dc4bcee259d9be7a72eb68970193725095409215..442ad1d98c39ec810948f8a8c9924ddf4fb5c46e
100644
--- a/src/mark-compact.h
+++ b/src/mark-compact.h
@@ -420,14 +420,9 @@ class MarkCompactCollector {
// Pointer to member function, used in IterateLiveObjects.
typedef int (MarkCompactCollector::*LiveObjectCallback)(HeapObject* obj);
- // Set the global force_compaction flag, it must be called before Prepare
- // to take effect.
+ // Set the global flags, it must be called before Prepare to take effect.
inline void SetFlags(int flags);
- inline bool PreciseSweepingRequired() {
- return sweep_precisely_;
- }
-
static void Initialize();
void CollectEvacuationCandidates(PagedSpace* space);
@@ -579,6 +574,8 @@ class MarkCompactCollector {
bool reduce_memory_footprint_;
+ bool abort_incremental_marking_;
+
// True if we are collecting slots to perform evacuation from evacuation
// candidates.
bool compacting_;
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
9209b9e169cee922799358dba69f9686d65a787a..019851e466a363948a3338c171eeac531b0290c4
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -12925,7 +12925,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) {
// Performs a GC.
// Presently, it only does a full GC.
RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) {
- isolate->heap()->CollectAllGarbage(true, "%CollectGarbage");
+ isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage");
return isolate->heap()->undefined_value();
}
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
641c443bb927f29b69bdecff673fd06680c25fa4..5137c6563764d63e6d1fb5ab172ef7cb94a878e7
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -450,8 +450,7 @@ THREADED_TEST(ScriptMakingExternalString) {
CHECK_EQ(0, dispose_count);
}
i::Isolate::Current()->compilation_cache()->Clear();
- // TODO(1608): This should use kAbortIncrementalMarking.
- HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+ HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
CHECK_EQ(1, dispose_count);
}
@@ -477,8 +476,7 @@ THREADED_TEST(ScriptMakingExternalAsciiString) {
CHECK_EQ(0, dispose_count);
}
i::Isolate::Current()->compilation_cache()->Clear();
- // TODO(1608): This should use kAbortIncrementalMarking.
- HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+ HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
CHECK_EQ(1, dispose_count);
}
@@ -2253,9 +2251,8 @@ THREADED_TEST(ApiObjectGroups) {
V8::AddObjectGroup(g2_objects, 2);
V8::AddImplicitReferences(g2s2, g2_children, 1);
}
- // Do a single full GC. Use kMakeHeapIterableMask to ensure that
- // incremental garbage collection is stopped.
- HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+ // Do a single full GC, ensure incremental marking is stopped.
+ HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
// All object should be alive.
CHECK_EQ(0, counter.NumberOfWeakCalls());
@@ -2279,7 +2276,7 @@ THREADED_TEST(ApiObjectGroups) {
V8::AddImplicitReferences(g2s2, g2_children, 1);
}
- HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+ HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
// All objects should be gone. 5 global handles in total.
CHECK_EQ(5, counter.NumberOfWeakCalls());
@@ -2288,7 +2285,7 @@ THREADED_TEST(ApiObjectGroups) {
g1c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
g2c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+ HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
CHECK_EQ(7, counter.NumberOfWeakCalls());
}
@@ -2344,7 +2341,7 @@ THREADED_TEST(ApiObjectGroupsCycle) {
V8::AddImplicitReferences(g3s1, g3_children, 1);
}
// Do a single full GC
- HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+ HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
// All object should be alive.
CHECK_EQ(0, counter.NumberOfWeakCalls());
@@ -2368,7 +2365,7 @@ THREADED_TEST(ApiObjectGroupsCycle) {
V8::AddImplicitReferences(g3s1, g3_children, 1);
}
- HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+ HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
// All objects should be gone. 7 global handles in total.
CHECK_EQ(7, counter.NumberOfWeakCalls());
Index: test/cctest/test-deoptimization.cc
diff --git a/test/cctest/test-deoptimization.cc
b/test/cctest/test-deoptimization.cc
index
ee57d65b2425857a43b47ec5b6c095fd694c0233..c52c5788dbce107e3db13e444bac44af56cd9c1e
100644
--- a/test/cctest/test-deoptimization.cc
+++ b/test/cctest/test-deoptimization.cc
@@ -100,8 +100,7 @@ class AllowNativesSyntaxNoInlining {
// Abort any ongoing incremental marking to make sure that all weak global
// handle callbacks are processed.
static void NonIncrementalGC() {
- // TODO(1608): This should use kAbortIncrementalMarking.
- HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+ HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
}
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index
10bacf50432c94124247cfd84ff4dc1d358806e7..999e2c66518b010561440292419606b8816b08d6
100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -959,17 +959,17 @@ TEST(TestCodeFlushing) {
CHECK(function->shared()->is_compiled());
// TODO(1609) Currently incremental marker does not support code
flushing.
- HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
- HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
CHECK(function->shared()->is_compiled());
- HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
- HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
- HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
- HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
- HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
- HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
// foo should no longer be in the compilation cache
CHECK(!function->shared()->is_compiled() || function->IsOptimized());
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev