[heap] Properly reset flags for partially aborted evacuation candidates.

See bug description.

R=hpayer@chromium.org
BUG=chromium:538257
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#31070}
This commit is contained in:
mlippautz 2015-10-02 04:49:55 -07:00 committed by Commit bot
parent ecf2327691
commit 5ef26f3a6b
2 changed files with 40 additions and 6 deletions

View File

@ -3783,6 +3783,14 @@ void MarkCompactCollector::EvacuateNewSpaceAndCandidates() {
SkipList* list = p->skip_list();
if (list != NULL) list->Clear();
}
if (p->IsEvacuationCandidate() &&
p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) {
// Case where we've aborted compacting a page. Clear the flag here to
// avoid release the page later on.
p->ClearEvacuationCandidate();
}
if (p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) {
if (FLAG_gc_verbose) {
PrintF("Sweeping 0x%" V8PRIxPTR " during evacuation.\n",
@ -3813,12 +3821,6 @@ void MarkCompactCollector::EvacuateNewSpaceAndCandidates() {
break;
}
}
if (p->IsEvacuationCandidate() &&
p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) {
// Case where we've aborted compacting a page. Clear the flag here to
// avoid release the page later on.
p->ClearEvacuationCandidate();
}
}
}

View File

@ -5479,6 +5479,38 @@ static void RequestInterrupt(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
UNINITIALIZED_TEST(Regress538257) {
i::FLAG_manual_evacuation_candidates_selection = true;
v8::Isolate::CreateParams create_params;
// Set heap limits.
create_params.constraints.set_max_semi_space_size(1 * Page::kPageSize / MB);
create_params.constraints.set_max_old_space_size(6 * Page::kPageSize / MB);
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params);
isolate->Enter();
{
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
HandleScope handle_scope(i_isolate);
PagedSpace* old_space = i_isolate->heap()->old_space();
const int kMaxObjects = 10000;
const int kFixedArrayLen = 512;
Handle<FixedArray> objects[kMaxObjects];
for (int i = 0; (i < kMaxObjects) && old_space->CanExpand(Page::kPageSize);
i++) {
objects[i] = i_isolate->factory()->NewFixedArray(kFixedArrayLen, TENURED);
Page::FromAddress(objects[i]->address())
->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING);
}
SimulateFullSpace(old_space);
i_isolate->heap()->CollectGarbage(OLD_SPACE);
// If we get this far, we've successfully aborted compaction. Any further
// allocations might trigger OOM.
}
isolate->Exit();
isolate->Dispose();
}
TEST(Regress357137) {
CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate();