Commit 492396f2 authored by hpayer@chromium.org's avatar hpayer@chromium.org

Fixed IsSweepingComplete and EnsureSweeperProgress helper functions.

BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13596 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 91218182
...@@ -1639,8 +1639,9 @@ class Heap { ...@@ -1639,8 +1639,9 @@ class Heap {
} }
bool IsSweepingComplete() { bool IsSweepingComplete() {
return old_data_space()->IsSweepingComplete() && return !mark_compact_collector()->IsConcurrentSweepingInProgress() &&
old_pointer_space()->IsSweepingComplete(); old_data_space()->IsLazySweepingComplete() &&
old_pointer_space()->IsLazySweepingComplete();
} }
bool AdvanceSweepers(int step_size) { bool AdvanceSweepers(int step_size) {
......
...@@ -562,6 +562,7 @@ void IncrementalMarking::UncommitMarkingDeque() { ...@@ -562,6 +562,7 @@ void IncrementalMarking::UncommitMarkingDeque() {
void IncrementalMarking::Start() { void IncrementalMarking::Start() {
ASSERT(!heap_->mark_compact_collector()->IsConcurrentSweepingInProgress());
if (FLAG_trace_incremental_marking) { if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Start\n"); PrintF("[IncrementalMarking] Start\n");
} }
...@@ -570,8 +571,7 @@ void IncrementalMarking::Start() { ...@@ -570,8 +571,7 @@ void IncrementalMarking::Start() {
ResetStepCounters(); ResetStepCounters();
if (heap_->old_pointer_space()->IsSweepingComplete() && if (heap_->IsSweepingComplete()) {
heap_->old_data_space()->IsSweepingComplete()) {
StartMarking(ALLOW_COMPACTION); StartMarking(ALLOW_COMPACTION);
} else { } else {
if (FLAG_trace_incremental_marking) { if (FLAG_trace_incremental_marking) {
......
...@@ -561,6 +561,11 @@ bool MarkCompactCollector::AreSweeperThreadsActivated() { ...@@ -561,6 +561,11 @@ bool MarkCompactCollector::AreSweeperThreadsActivated() {
} }
bool MarkCompactCollector::IsConcurrentSweepingInProgress() {
return SweeperThread::sweeping_pending();
}
void MarkCompactCollector::MarkInParallel() { void MarkCompactCollector::MarkInParallel() {
for (int i = 0; i < FLAG_marking_threads; i++) { for (int i = 0; i < FLAG_marking_threads; i++) {
heap()->isolate()->marking_threads()[i]->StartMarking(); heap()->isolate()->marking_threads()[i]->StartMarking();
......
...@@ -692,6 +692,8 @@ class MarkCompactCollector { ...@@ -692,6 +692,8 @@ class MarkCompactCollector {
bool AreSweeperThreadsActivated(); bool AreSweeperThreadsActivated();
bool IsConcurrentSweepingInProgress();
// Parallel marking support. // Parallel marking support.
void MarkInParallel(); void MarkInParallel();
......
...@@ -2525,7 +2525,7 @@ bool LargeObjectSpace::ReserveSpace(int bytes) { ...@@ -2525,7 +2525,7 @@ bool LargeObjectSpace::ReserveSpace(int bytes) {
bool PagedSpace::AdvanceSweeper(intptr_t bytes_to_sweep) { bool PagedSpace::AdvanceSweeper(intptr_t bytes_to_sweep) {
if (IsSweepingComplete()) return true; if (IsLazySweepingComplete()) return true;
intptr_t freed_bytes = 0; intptr_t freed_bytes = 0;
Page* p = first_unswept_page_; Page* p = first_unswept_page_;
...@@ -2553,7 +2553,7 @@ bool PagedSpace::AdvanceSweeper(intptr_t bytes_to_sweep) { ...@@ -2553,7 +2553,7 @@ bool PagedSpace::AdvanceSweeper(intptr_t bytes_to_sweep) {
heap()->FreeQueuedChunks(); heap()->FreeQueuedChunks();
return IsSweepingComplete(); return IsLazySweepingComplete();
} }
...@@ -2575,12 +2575,14 @@ void PagedSpace::EvictEvacuationCandidatesFromFreeLists() { ...@@ -2575,12 +2575,14 @@ void PagedSpace::EvictEvacuationCandidatesFromFreeLists() {
bool PagedSpace::EnsureSweeperProgress(intptr_t size_in_bytes) { bool PagedSpace::EnsureSweeperProgress(intptr_t size_in_bytes) {
MarkCompactCollector* collector = heap()->mark_compact_collector(); MarkCompactCollector* collector = heap()->mark_compact_collector();
if (collector->AreSweeperThreadsActivated()) { if (collector->AreSweeperThreadsActivated()) {
if (FLAG_concurrent_sweeping && if (FLAG_concurrent_sweeping) {
collector->StealMemoryFromSweeperThreads(this) < size_in_bytes) { if (collector->StealMemoryFromSweeperThreads(this) < size_in_bytes) {
collector->WaitUntilSweepingCompleted(); collector->WaitUntilSweepingCompleted();
return true; return true;
}
return false;
} }
return false; return true;
} else { } else {
return AdvanceSweeper(size_in_bytes); return AdvanceSweeper(size_in_bytes);
} }
...@@ -2618,7 +2620,7 @@ HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { ...@@ -2618,7 +2620,7 @@ HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) {
// Last ditch, sweep all the remaining pages to try to find space. This may // Last ditch, sweep all the remaining pages to try to find space. This may
// cause a pause. // cause a pause.
if (!IsSweepingComplete()) { if (!IsLazySweepingComplete()) {
EnsureSweeperProgress(kMaxInt); EnsureSweeperProgress(kMaxInt);
// Retry the free list allocation. // Retry the free list allocation.
......
...@@ -1644,7 +1644,8 @@ class PagedSpace : public Space { ...@@ -1644,7 +1644,8 @@ class PagedSpace : public Space {
// As size, but the bytes in lazily swept pages are estimated and the bytes // As size, but the bytes in lazily swept pages are estimated and the bytes
// in the current linear allocation area are not included. // in the current linear allocation area are not included.
virtual intptr_t SizeOfObjects() { virtual intptr_t SizeOfObjects() {
ASSERT(!IsSweepingComplete() || (unswept_free_bytes_ == 0)); // TODO(hpayer): broken when concurrent sweeping turned on
ASSERT(!IsLazySweepingComplete() || (unswept_free_bytes_ == 0));
return Size() - unswept_free_bytes_ - (limit() - top()); return Size() - unswept_free_bytes_ - (limit() - top());
} }
...@@ -1763,7 +1764,7 @@ class PagedSpace : public Space { ...@@ -1763,7 +1764,7 @@ class PagedSpace : public Space {
// is called. // is called.
bool EnsureSweeperProgress(intptr_t size_in_bytes); bool EnsureSweeperProgress(intptr_t size_in_bytes);
bool IsSweepingComplete() { bool IsLazySweepingComplete() {
return !first_unswept_page_->is_valid(); return !first_unswept_page_->is_valid();
} }
......
...@@ -1430,7 +1430,7 @@ TEST(TestSizeOfObjects) { ...@@ -1430,7 +1430,7 @@ TEST(TestSizeOfObjects) {
HEAP->CollectAllGarbage(Heap::kNoGCFlags); HEAP->CollectAllGarbage(Heap::kNoGCFlags);
HEAP->CollectAllGarbage(Heap::kNoGCFlags); HEAP->CollectAllGarbage(Heap::kNoGCFlags);
HEAP->CollectAllGarbage(Heap::kNoGCFlags); HEAP->CollectAllGarbage(Heap::kNoGCFlags);
CHECK(HEAP->old_pointer_space()->IsSweepingComplete()); CHECK(HEAP->old_pointer_space()->IsLazySweepingComplete());
int initial_size = static_cast<int>(HEAP->SizeOfObjects()); int initial_size = static_cast<int>(HEAP->SizeOfObjects());
{ {
...@@ -1454,7 +1454,7 @@ TEST(TestSizeOfObjects) { ...@@ -1454,7 +1454,7 @@ TEST(TestSizeOfObjects) {
CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects())); CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects()));
// Advancing the sweeper step-wise should not change the heap size. // Advancing the sweeper step-wise should not change the heap size.
while (!HEAP->old_pointer_space()->IsSweepingComplete()) { while (!HEAP->old_pointer_space()->IsLazySweepingComplete()) {
HEAP->old_pointer_space()->AdvanceSweeper(KB); HEAP->old_pointer_space()->AdvanceSweeper(KB);
CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects())); CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects()));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment