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