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 class StaticOneByteResource : public v8::String::ExternalOneByteStringResource { | |
6790 public: | |
6791 explicit StaticOneByteResource(const char* data) : data_(data) {} | |
6792 | |
6793 ~StaticOneByteResource() {} | |
6794 | |
6795 const char* data() const { return data_; } | |
6796 | |
6797 size_t length() const { return strlen(data_); } | |
6798 | |
6799 private: | |
6800 const char* data_; | |
6801 }; | |
6802 | |
6803 TEST(Regress631969) { | |
6804 FLAG_manual_evacuation_candidates_selection = true; | |
6805 FLAG_parallel_compaction = false; | |
6806 FLAG_concurrent_sweeping = false; | |
6807 CcTest::InitializeVM(); | |
6808 v8::HandleScope scope(CcTest::isolate()); | |
6809 Heap* heap = CcTest::heap(); | |
6810 // Get the heap in clean state. | |
6811 heap->CollectGarbage(OLD_SPACE); | |
6812 heap->CollectGarbage(OLD_SPACE); | |
6813 Isolate* isolate = CcTest::i_isolate(); | |
6814 Factory* factory = isolate->factory(); | |
6815 // Allocate two string in a fresh page and mark the page as evacuation | |
Jakob Kummerow
2016/08/02 11:34:08
nit: s/string/strings/
ulan
2016/08/02 15:00:24
Done.
| |
6816 // candidate. | |
6817 heap::SimulateFullSpace(heap->old_space()); | |
6818 Handle<String> s1 = factory->NewStringFromStaticChars("123456789", TENURED); | |
6819 Handle<String> s2 = factory->NewStringFromStaticChars("01234", TENURED); | |
6820 Page::FromAddress(s1->address()) | |
6821 ->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); | |
6822 | |
6823 heap::SimulateIncrementalMarking(heap, false); | |
6824 | |
6825 // Allocate a cons string and promote it to a fresh page in the old space. | |
6826 heap::SimulateFullSpace(heap->old_space()); | |
6827 Handle<String> s3; | |
6828 factory->NewConsString(s1, s2).ToHandle(&s3); | |
6829 heap->CollectGarbage(NEW_SPACE); | |
6830 heap->CollectGarbage(NEW_SPACE); | |
6831 | |
6832 // Finish incremental marking. | |
6833 IncrementalMarking* marking = heap->incremental_marking(); | |
6834 while (!marking->IsComplete()) { | |
6835 marking->Step(MB, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD); | |
6836 if (marking->IsReadyToOverApproximateWeakClosure()) { | |
6837 marking->FinalizeIncrementally(); | |
6838 } | |
6839 } | |
6840 | |
6841 s3->MakeExternal(new StaticOneByteResource("12345678901234")); | |
6842 | |
6843 heap->CollectGarbage(OLD_SPACE); | |
6844 } | |
6845 | |
6789 TEST(LeftTrimFixedArrayInBlackArea) { | 6846 TEST(LeftTrimFixedArrayInBlackArea) { |
6790 FLAG_black_allocation = true; | 6847 FLAG_black_allocation = true; |
6791 CcTest::InitializeVM(); | 6848 CcTest::InitializeVM(); |
6792 v8::HandleScope scope(CcTest::isolate()); | 6849 v8::HandleScope scope(CcTest::isolate()); |
6793 Heap* heap = CcTest::heap(); | 6850 Heap* heap = CcTest::heap(); |
6794 Isolate* isolate = heap->isolate(); | 6851 Isolate* isolate = heap->isolate(); |
6795 heap->CollectAllGarbage(); | 6852 heap->CollectAllGarbage(); |
6796 | 6853 |
6797 i::MarkCompactCollector* collector = heap->mark_compact_collector(); | 6854 i::MarkCompactCollector* collector = heap->mark_compact_collector(); |
6798 i::IncrementalMarking* marking = heap->incremental_marking(); | 6855 i::IncrementalMarking* marking = heap->incremental_marking(); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6922 chunk, chunk->area_end() - kPointerSize, chunk->area_end()); | 6979 chunk, chunk->area_end() - kPointerSize, chunk->area_end()); |
6923 slots[chunk->area_end() - kPointerSize] = false; | 6980 slots[chunk->area_end() - kPointerSize] = false; |
6924 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { | 6981 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { |
6925 CHECK(slots[addr]); | 6982 CHECK(slots[addr]); |
6926 return KEEP_SLOT; | 6983 return KEEP_SLOT; |
6927 }); | 6984 }); |
6928 } | 6985 } |
6929 | 6986 |
6930 } // namespace internal | 6987 } // namespace internal |
6931 } // namespace v8 | 6988 } // namespace v8 |
OLD | NEW |