Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: test/cctest/heap/test-heap.cc

Issue 2469273002: [heap] Exclude the owner of the linear allocation area from evacuation. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/heap/test-array-buffer-tracker.cc ('k') | test/cctest/test-unboxed-doubles.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 for (int i = 0; i < kRawBytesSize; i++) { 784 for (int i = 0; i < kRawBytesSize; i++) {
785 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]); 785 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]);
786 CHECK_EQ(array->get(i), kRawBytes[i]); 786 CHECK_EQ(array->get(i), kRawBytes[i]);
787 } 787 }
788 788
789 FixedArray* old_constant_pool_address = *constant_pool; 789 FixedArray* old_constant_pool_address = *constant_pool;
790 790
791 // Perform a full garbage collection and force the constant pool to be on an 791 // Perform a full garbage collection and force the constant pool to be on an
792 // evacuation candidate. 792 // evacuation candidate.
793 Page* evac_page = Page::FromAddress(constant_pool->address()); 793 Page* evac_page = Page::FromAddress(constant_pool->address());
794 evac_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); 794 heap::ForceEvacuationCandidate(evac_page);
795 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); 795 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
796 796
797 // BytecodeArray should survive. 797 // BytecodeArray should survive.
798 CHECK_EQ(array->length(), kRawBytesSize); 798 CHECK_EQ(array->length(), kRawBytesSize);
799 CHECK_EQ(array->frame_size(), kFrameSize); 799 CHECK_EQ(array->frame_size(), kFrameSize);
800 for (int i = 0; i < kRawBytesSize; i++) { 800 for (int i = 0; i < kRawBytesSize; i++) {
801 CHECK_EQ(array->get(i), kRawBytes[i]); 801 CHECK_EQ(array->get(i), kRawBytes[i]);
802 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]); 802 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]);
803 } 803 }
804 804
(...skipping 3546 matching lines...) Expand 10 before | Expand all | Expand 10 after
4351 Handle<LiteralsArray> lit = LiteralsArray::New(isolate, vector, 23); 4351 Handle<LiteralsArray> lit = LiteralsArray::New(isolate, vector, 23);
4352 4352
4353 evac_page = Page::FromAddress(lit->address()); 4353 evac_page = Page::FromAddress(lit->address());
4354 BailoutId id = BailoutId(100); 4354 BailoutId id = BailoutId(100);
4355 SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id); 4355 SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id);
4356 } 4356 }
4357 4357
4358 // Heap is ready, force {lit_page} to become an evacuation candidate and 4358 // Heap is ready, force {lit_page} to become an evacuation candidate and
4359 // simulate incremental marking to enqueue optimized code map. 4359 // simulate incremental marking to enqueue optimized code map.
4360 FLAG_manual_evacuation_candidates_selection = true; 4360 FLAG_manual_evacuation_candidates_selection = true;
4361 evac_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); 4361 heap::ForceEvacuationCandidate(evac_page);
4362 heap::SimulateIncrementalMarking(heap); 4362 heap::SimulateIncrementalMarking(heap);
4363 4363
4364 // No matter whether reachable or not, {boomer} is doomed. 4364 // No matter whether reachable or not, {boomer} is doomed.
4365 Handle<Object> boomer(shared->optimized_code_map(), isolate); 4365 Handle<Object> boomer(shared->optimized_code_map(), isolate);
4366 4366
4367 // Add the code several times to the optimized code map. This will leave old 4367 // Add the code several times to the optimized code map. This will leave old
4368 // copies of the optimized code map unreachable but still marked. 4368 // copies of the optimized code map unreachable but still marked.
4369 for (int i = 3; i < 6; ++i) { 4369 for (int i = 3; i < 6; ++i) {
4370 HandleScope inner_scope(isolate); 4370 HandleScope inner_scope(isolate);
4371 BailoutId id = BailoutId(i); 4371 BailoutId id = BailoutId(i);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
4550 FLAG_manual_evacuation_candidates_selection = true; 4550 FLAG_manual_evacuation_candidates_selection = true;
4551 CcTest::InitializeVM(); 4551 CcTest::InitializeVM();
4552 Isolate* isolate = CcTest::i_isolate(); 4552 Isolate* isolate = CcTest::i_isolate();
4553 Heap* heap = isolate->heap(); 4553 Heap* heap = isolate->heap();
4554 HandleScope scope(isolate); 4554 HandleScope scope(isolate);
4555 4555
4556 // Create an object on an evacuation candidate. 4556 // Create an object on an evacuation candidate.
4557 heap::SimulateFullSpace(heap->old_space()); 4557 heap::SimulateFullSpace(heap->old_space());
4558 Handle<FixedArray> lit = isolate->factory()->NewFixedArray(4, TENURED); 4558 Handle<FixedArray> lit = isolate->factory()->NewFixedArray(4, TENURED);
4559 Page* evac_page = Page::FromAddress(lit->address()); 4559 Page* evac_page = Page::FromAddress(lit->address());
4560 evac_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); 4560 heap::ForceEvacuationCandidate(evac_page);
4561 FixedArray* old_location = *lit; 4561 FixedArray* old_location = *lit;
4562 4562
4563 // Allocate a large object. 4563 // Allocate a large object.
4564 int size = Max(1000000, kMaxRegularHeapObjectSize + KB); 4564 int size = Max(1000000, kMaxRegularHeapObjectSize + KB);
4565 CHECK(size > kMaxRegularHeapObjectSize); 4565 CHECK(size > kMaxRegularHeapObjectSize);
4566 Handle<FixedArray> lo = isolate->factory()->NewFixedArray(size, TENURED); 4566 Handle<FixedArray> lo = isolate->factory()->NewFixedArray(size, TENURED);
4567 CHECK(heap->lo_space()->Contains(*lo)); 4567 CHECK(heap->lo_space()->Contains(*lo));
4568 4568
4569 // Start incremental marking to active write barrier. 4569 // Start incremental marking to active write barrier.
4570 heap::SimulateIncrementalMarking(heap, false); 4570 heap::SimulateIncrementalMarking(heap, false);
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
5556 Heap* heap = i_isolate->heap(); 5556 Heap* heap = i_isolate->heap();
5557 HandleScope handle_scope(i_isolate); 5557 HandleScope handle_scope(i_isolate);
5558 PagedSpace* old_space = heap->old_space(); 5558 PagedSpace* old_space = heap->old_space();
5559 const int kMaxObjects = 10000; 5559 const int kMaxObjects = 10000;
5560 const int kFixedArrayLen = 512; 5560 const int kFixedArrayLen = 512;
5561 Handle<FixedArray> objects[kMaxObjects]; 5561 Handle<FixedArray> objects[kMaxObjects];
5562 for (int i = 0; (i < kMaxObjects) && 5562 for (int i = 0; (i < kMaxObjects) &&
5563 heap->CanExpandOldGeneration(old_space->AreaSize()); 5563 heap->CanExpandOldGeneration(old_space->AreaSize());
5564 i++) { 5564 i++) {
5565 objects[i] = i_isolate->factory()->NewFixedArray(kFixedArrayLen, TENURED); 5565 objects[i] = i_isolate->factory()->NewFixedArray(kFixedArrayLen, TENURED);
5566 Page::FromAddress(objects[i]->address()) 5566 heap::ForceEvacuationCandidate(Page::FromAddress(objects[i]->address()));
5567 ->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING);
5568 } 5567 }
5569 heap::SimulateFullSpace(old_space); 5568 heap::SimulateFullSpace(old_space);
5570 heap->CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask, 5569 heap->CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask,
5571 i::GarbageCollectionReason::kTesting); 5570 i::GarbageCollectionReason::kTesting);
5572 // If we get this far, we've successfully aborted compaction. Any further 5571 // If we get this far, we've successfully aborted compaction. Any further
5573 // allocations might trigger OOM. 5572 // allocations might trigger OOM.
5574 } 5573 }
5575 isolate->Exit(); 5574 isolate->Exit();
5576 isolate->Dispose(); 5575 isolate->Dispose();
5577 } 5576 }
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
6519 handle(array); 6518 handle(array);
6520 // Do not expand anymore. 6519 // Do not expand anymore.
6521 heap->set_force_oom(true); 6520 heap->set_force_oom(true);
6522 } 6521 }
6523 // Expand and mark the new page as evacuation candidate. 6522 // Expand and mark the new page as evacuation candidate.
6524 heap->set_force_oom(false); 6523 heap->set_force_oom(false);
6525 { 6524 {
6526 AlwaysAllocateScope always_allocate(isolate); 6525 AlwaysAllocateScope always_allocate(isolate);
6527 Handle<HeapObject> ec_obj = factory->NewFixedArray(5000, TENURED); 6526 Handle<HeapObject> ec_obj = factory->NewFixedArray(5000, TENURED);
6528 Page* ec_page = Page::FromAddress(ec_obj->address()); 6527 Page* ec_page = Page::FromAddress(ec_obj->address());
6529 ec_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); 6528 heap::ForceEvacuationCandidate(ec_page);
6530 // Make all arrays point to evacuation candidate so that 6529 // Make all arrays point to evacuation candidate so that
6531 // slots are recorded for them. 6530 // slots are recorded for them.
6532 for (size_t j = 0; j < arrays.size(); j++) { 6531 for (size_t j = 0; j < arrays.size(); j++) {
6533 array = arrays[j]; 6532 array = arrays[j];
6534 for (int i = 0; i < N; i++) { 6533 for (int i = 0; i < N; i++) {
6535 array->set(i, *ec_obj); 6534 array->set(i, *ec_obj);
6536 } 6535 }
6537 } 6536 }
6538 } 6537 }
6539 heap::SimulateIncrementalMarking(heap); 6538 heap::SimulateIncrementalMarking(heap);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
6726 // Get the heap in clean state. 6725 // Get the heap in clean state.
6727 CcTest::CollectGarbage(OLD_SPACE); 6726 CcTest::CollectGarbage(OLD_SPACE);
6728 CcTest::CollectGarbage(OLD_SPACE); 6727 CcTest::CollectGarbage(OLD_SPACE);
6729 Isolate* isolate = CcTest::i_isolate(); 6728 Isolate* isolate = CcTest::i_isolate();
6730 Factory* factory = isolate->factory(); 6729 Factory* factory = isolate->factory();
6731 // Allocate two strings in a fresh page and mark the page as evacuation 6730 // Allocate two strings in a fresh page and mark the page as evacuation
6732 // candidate. 6731 // candidate.
6733 heap::SimulateFullSpace(heap->old_space()); 6732 heap::SimulateFullSpace(heap->old_space());
6734 Handle<String> s1 = factory->NewStringFromStaticChars("123456789", TENURED); 6733 Handle<String> s1 = factory->NewStringFromStaticChars("123456789", TENURED);
6735 Handle<String> s2 = factory->NewStringFromStaticChars("01234", TENURED); 6734 Handle<String> s2 = factory->NewStringFromStaticChars("01234", TENURED);
6736 Page::FromAddress(s1->address()) 6735 heap::ForceEvacuationCandidate(Page::FromAddress(s1->address()));
6737 ->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING);
6738 6736
6739 heap::SimulateIncrementalMarking(heap, false); 6737 heap::SimulateIncrementalMarking(heap, false);
6740 6738
6741 // Allocate a cons string and promote it to a fresh page in the old space. 6739 // Allocate a cons string and promote it to a fresh page in the old space.
6742 heap::SimulateFullSpace(heap->old_space()); 6740 heap::SimulateFullSpace(heap->old_space());
6743 Handle<String> s3; 6741 Handle<String> s3;
6744 factory->NewConsString(s1, s2).ToHandle(&s3); 6742 factory->NewConsString(s1, s2).ToHandle(&s3);
6745 CcTest::CollectGarbage(NEW_SPACE); 6743 CcTest::CollectGarbage(NEW_SPACE);
6746 CcTest::CollectGarbage(NEW_SPACE); 6744 CcTest::CollectGarbage(NEW_SPACE);
6747 6745
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
7026 SlotSet::FREE_EMPTY_BUCKETS); 7024 SlotSet::FREE_EMPTY_BUCKETS);
7027 slots[chunk->area_end() - kPointerSize] = false; 7025 slots[chunk->area_end() - kPointerSize] = false;
7028 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { 7026 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) {
7029 CHECK(slots[addr]); 7027 CHECK(slots[addr]);
7030 return KEEP_SLOT; 7028 return KEEP_SLOT;
7031 }); 7029 });
7032 } 7030 }
7033 7031
7034 } // namespace internal 7032 } // namespace internal
7035 } // namespace v8 7033 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/heap/test-array-buffer-tracker.cc ('k') | test/cctest/test-unboxed-doubles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698