| OLD | NEW |
| 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 6768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6779 } | 6779 } |
| 6780 } | 6780 } |
| 6781 CHECK(marking->IsComplete()); | 6781 CHECK(marking->IsComplete()); |
| 6782 intptr_t size_before = heap->SizeOfObjects(); | 6782 intptr_t size_before = heap->SizeOfObjects(); |
| 6783 CcTest::heap()->CollectAllGarbage(); | 6783 CcTest::heap()->CollectAllGarbage(); |
| 6784 intptr_t size_after = heap->SizeOfObjects(); | 6784 intptr_t size_after = heap->SizeOfObjects(); |
| 6785 // Live size does not increase after garbage collection. | 6785 // Live size does not increase after garbage collection. |
| 6786 CHECK_LE(size_after, size_before); | 6786 CHECK_LE(size_after, size_before); |
| 6787 } | 6787 } |
| 6788 | 6788 |
| 6789 TEST(LeftTrimFixedArrayInBlackArea) { | |
| 6790 FLAG_black_allocation = true; | |
| 6791 CcTest::InitializeVM(); | |
| 6792 v8::HandleScope scope(CcTest::isolate()); | |
| 6793 Heap* heap = CcTest::heap(); | |
| 6794 Isolate* isolate = heap->isolate(); | |
| 6795 heap->CollectAllGarbage(); | |
| 6796 | |
| 6797 i::MarkCompactCollector* collector = heap->mark_compact_collector(); | |
| 6798 i::IncrementalMarking* marking = heap->incremental_marking(); | |
| 6799 if (collector->sweeping_in_progress()) { | |
| 6800 collector->EnsureSweepingCompleted(); | |
| 6801 } | |
| 6802 CHECK(marking->IsMarking() || marking->IsStopped()); | |
| 6803 if (marking->IsStopped()) { | |
| 6804 heap->StartIncrementalMarking(); | |
| 6805 } | |
| 6806 CHECK(marking->IsMarking()); | |
| 6807 marking->StartBlackAllocationForTesting(); | |
| 6808 | |
| 6809 // Ensure that we allocate a new page, set up a bump pointer area, and | |
| 6810 // perform the allocation in a black area. | |
| 6811 heap::SimulateFullSpace(heap->old_space()); | |
| 6812 isolate->factory()->NewFixedArray(4, TENURED); | |
| 6813 Handle<FixedArray> array = isolate->factory()->NewFixedArray(50, TENURED); | |
| 6814 CHECK(heap->old_space()->Contains(*array)); | |
| 6815 CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(*array))); | |
| 6816 | |
| 6817 // Now left trim the allocated black area. A filler has to be installed | |
| 6818 // for the trimmed area and all mark bits of the trimmed area have to be | |
| 6819 // cleared. | |
| 6820 FixedArrayBase* trimmed = heap->LeftTrimFixedArray(*array, 10); | |
| 6821 CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(trimmed))); | |
| 6822 | |
| 6823 heap::GcAndSweep(heap, OLD_SPACE); | |
| 6824 } | |
| 6825 | |
| 6826 TEST(ContinuousLeftTrimFixedArrayInBlackArea) { | |
| 6827 FLAG_black_allocation = true; | |
| 6828 CcTest::InitializeVM(); | |
| 6829 v8::HandleScope scope(CcTest::isolate()); | |
| 6830 Heap* heap = CcTest::heap(); | |
| 6831 Isolate* isolate = heap->isolate(); | |
| 6832 heap->CollectAllGarbage(); | |
| 6833 | |
| 6834 i::MarkCompactCollector* collector = heap->mark_compact_collector(); | |
| 6835 i::IncrementalMarking* marking = heap->incremental_marking(); | |
| 6836 if (collector->sweeping_in_progress()) { | |
| 6837 collector->EnsureSweepingCompleted(); | |
| 6838 } | |
| 6839 CHECK(marking->IsMarking() || marking->IsStopped()); | |
| 6840 if (marking->IsStopped()) { | |
| 6841 heap->StartIncrementalMarking(); | |
| 6842 } | |
| 6843 CHECK(marking->IsMarking()); | |
| 6844 marking->StartBlackAllocationForTesting(); | |
| 6845 | |
| 6846 // Ensure that we allocate a new page, set up a bump pointer area, and | |
| 6847 // perform the allocation in a black area. | |
| 6848 heap::SimulateFullSpace(heap->old_space()); | |
| 6849 isolate->factory()->NewFixedArray(10, TENURED); | |
| 6850 | |
| 6851 // Allocate the fixed array that will be trimmed later. | |
| 6852 Handle<FixedArray> array = isolate->factory()->NewFixedArray(100, TENURED); | |
| 6853 Address start_address = array->address(); | |
| 6854 Address end_address = start_address + array->Size(); | |
| 6855 Page* page = Page::FromAddress(start_address); | |
| 6856 CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(*array))); | |
| 6857 CHECK(page->markbits()->AllBitsSetInRange( | |
| 6858 page->AddressToMarkbitIndex(start_address), | |
| 6859 page->AddressToMarkbitIndex(end_address))); | |
| 6860 CHECK(heap->old_space()->Contains(*array)); | |
| 6861 | |
| 6862 FixedArrayBase* previous = *array; | |
| 6863 FixedArrayBase* trimmed; | |
| 6864 | |
| 6865 // First trim in one word steps. | |
| 6866 for (int i = 0; i < 10; i++) { | |
| 6867 trimmed = heap->LeftTrimFixedArray(previous, 1); | |
| 6868 HeapObject* filler = HeapObject::FromAddress(previous->address()); | |
| 6869 CHECK(filler->IsFiller()); | |
| 6870 CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(trimmed))); | |
| 6871 CHECK(Marking::IsImpossible(ObjectMarking::MarkBitFrom(previous))); | |
| 6872 previous = trimmed; | |
| 6873 } | |
| 6874 | |
| 6875 // Then trim in two and three word steps. | |
| 6876 for (int i = 2; i <= 3; i++) { | |
| 6877 for (int j = 0; j < 10; j++) { | |
| 6878 trimmed = heap->LeftTrimFixedArray(previous, i); | |
| 6879 HeapObject* filler = HeapObject::FromAddress(previous->address()); | |
| 6880 CHECK(filler->IsFiller()); | |
| 6881 CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(trimmed))); | |
| 6882 CHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(previous))); | |
| 6883 previous = trimmed; | |
| 6884 } | |
| 6885 } | |
| 6886 | |
| 6887 heap::GcAndSweep(heap, OLD_SPACE); | |
| 6888 } | |
| 6889 | |
| 6890 TEST(ContinuousRightTrimFixedArrayInBlackArea) { | |
| 6891 FLAG_black_allocation = true; | |
| 6892 CcTest::InitializeVM(); | |
| 6893 v8::HandleScope scope(CcTest::isolate()); | |
| 6894 Heap* heap = CcTest::heap(); | |
| 6895 Isolate* isolate = heap->isolate(); | |
| 6896 heap->CollectAllGarbage(); | |
| 6897 | |
| 6898 i::MarkCompactCollector* collector = heap->mark_compact_collector(); | |
| 6899 i::IncrementalMarking* marking = heap->incremental_marking(); | |
| 6900 if (collector->sweeping_in_progress()) { | |
| 6901 collector->EnsureSweepingCompleted(); | |
| 6902 } | |
| 6903 CHECK(marking->IsMarking() || marking->IsStopped()); | |
| 6904 if (marking->IsStopped()) { | |
| 6905 heap->StartIncrementalMarking(); | |
| 6906 } | |
| 6907 CHECK(marking->IsMarking()); | |
| 6908 marking->StartBlackAllocationForTesting(); | |
| 6909 | |
| 6910 // Ensure that we allocate a new page, set up a bump pointer area, and | |
| 6911 // perform the allocation in a black area. | |
| 6912 heap::SimulateFullSpace(heap->old_space()); | |
| 6913 isolate->factory()->NewFixedArray(10, TENURED); | |
| 6914 | |
| 6915 // Allocate the fixed array that will be trimmed later. | |
| 6916 Handle<FixedArray> array = isolate->factory()->NewFixedArray(100, TENURED); | |
| 6917 Address start_address = array->address(); | |
| 6918 Address end_address = start_address + array->Size(); | |
| 6919 Page* page = Page::FromAddress(start_address); | |
| 6920 CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(*array))); | |
| 6921 CHECK(page->markbits()->AllBitsSetInRange( | |
| 6922 page->AddressToMarkbitIndex(start_address), | |
| 6923 page->AddressToMarkbitIndex(end_address))); | |
| 6924 CHECK(heap->old_space()->Contains(*array)); | |
| 6925 | |
| 6926 // Trim it once by one word to make checking for white marking color uniform. | |
| 6927 Address previous = end_address - kPointerSize; | |
| 6928 heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(*array, 1); | |
| 6929 HeapObject* filler = HeapObject::FromAddress(previous); | |
| 6930 CHECK(filler->IsFiller()); | |
| 6931 CHECK(Marking::IsImpossible(ObjectMarking::MarkBitFrom(previous))); | |
| 6932 | |
| 6933 // Trim 10 times by one, two, and three word. | |
| 6934 for (int i = 1; i <= 3; i++) { | |
| 6935 for (int j = 0; j < 10; j++) { | |
| 6936 previous -= kPointerSize * i; | |
| 6937 heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(*array, i); | |
| 6938 HeapObject* filler = HeapObject::FromAddress(previous); | |
| 6939 CHECK(filler->IsFiller()); | |
| 6940 CHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(previous))); | |
| 6941 } | |
| 6942 } | |
| 6943 | |
| 6944 heap::GcAndSweep(heap, OLD_SPACE); | |
| 6945 } | |
| 6946 | |
| 6947 TEST(Regress618958) { | 6789 TEST(Regress618958) { |
| 6948 CcTest::InitializeVM(); | 6790 CcTest::InitializeVM(); |
| 6949 v8::HandleScope scope(CcTest::isolate()); | 6791 v8::HandleScope scope(CcTest::isolate()); |
| 6950 Heap* heap = CcTest::heap(); | 6792 Heap* heap = CcTest::heap(); |
| 6951 bool isolate_is_locked = true; | 6793 bool isolate_is_locked = true; |
| 6952 heap->update_external_memory(100 * MB); | 6794 heap->update_external_memory(100 * MB); |
| 6953 int mark_sweep_count_before = heap->ms_count(); | 6795 int mark_sweep_count_before = heap->ms_count(); |
| 6954 heap->MemoryPressureNotification(MemoryPressureLevel::kCritical, | 6796 heap->MemoryPressureNotification(MemoryPressureLevel::kCritical, |
| 6955 isolate_is_locked); | 6797 isolate_is_locked); |
| 6956 int mark_sweep_count_after = heap->ms_count(); | 6798 int mark_sweep_count_after = heap->ms_count(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7043 chunk, chunk->area_end() - kPointerSize, chunk->area_end()); | 6885 chunk, chunk->area_end() - kPointerSize, chunk->area_end()); |
| 7044 slots[chunk->area_end() - kPointerSize] = false; | 6886 slots[chunk->area_end() - kPointerSize] = false; |
| 7045 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { | 6887 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { |
| 7046 CHECK(slots[addr]); | 6888 CHECK(slots[addr]); |
| 7047 return KEEP_SLOT; | 6889 return KEEP_SLOT; |
| 7048 }); | 6890 }); |
| 7049 } | 6891 } |
| 7050 | 6892 |
| 7051 } // namespace internal | 6893 } // namespace internal |
| 7052 } // namespace v8 | 6894 } // namespace v8 |
| OLD | NEW |