| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/factory.h" | 5 #include "src/factory.h" |
| 6 #include "src/heap/array-buffer-tracker.h" | 6 #include "src/heap/array-buffer-tracker.h" |
| 7 #include "src/heap/spaces-inl.h" | 7 #include "src/heap/spaces-inl.h" |
| 8 #include "src/isolate.h" | 8 #include "src/isolate.h" |
| 9 // FIXME(mstarzinger, marja): This is weird, but required because of the missing | 9 // FIXME(mstarzinger, marja): This is weird, but required because of the missing |
| 10 // (disallowed) include: src/factory.h -> src/objects-inl.h | 10 // (disallowed) include: src/factory.h -> src/objects-inl.h |
| 11 #include "src/objects-inl.h" | 11 #include "src/objects-inl.h" |
| 12 // FIXME(mstarzinger, marja): This is weird, but required because of the missing | 12 // FIXME(mstarzinger, marja): This is weird, but required because of the missing |
| 13 // (disallowed) include: src/type-feedback-vector.h -> | 13 // (disallowed) include: src/type-feedback-vector.h -> |
| 14 // src/type-feedback-vector-inl.h | 14 // src/type-feedback-vector-inl.h |
| 15 #include "src/type-feedback-vector-inl.h" | 15 #include "src/type-feedback-vector-inl.h" |
| 16 #include "test/cctest/cctest.h" | 16 #include "test/cctest/cctest.h" |
| 17 #include "test/cctest/heap/heap-tester.h" |
| 17 #include "test/cctest/heap/heap-utils.h" | 18 #include "test/cctest/heap/heap-utils.h" |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 v8::Isolate* NewIsolateForPagePromotion() { | 22 v8::Isolate* NewIsolateForPagePromotion(int min_semi_space_size = 8, |
| 23 int max_semi_space_size = 8) { |
| 22 i::FLAG_page_promotion = true; | 24 i::FLAG_page_promotion = true; |
| 23 i::FLAG_page_promotion_threshold = 0; // % | 25 i::FLAG_page_promotion_threshold = 0; // % |
| 24 i::FLAG_min_semi_space_size = 8; | 26 i::FLAG_min_semi_space_size = min_semi_space_size; |
| 25 // We cannot optimize for size as we require a new space with more than one | 27 // We cannot optimize for size as we require a new space with more than one |
| 26 // page. | 28 // page. |
| 27 i::FLAG_optimize_for_size = false; | 29 i::FLAG_optimize_for_size = false; |
| 28 // Set max_semi_space_size because it could've been initialized by an | 30 // Set max_semi_space_size because it could've been initialized by an |
| 29 // implication of optimize_for_size. | 31 // implication of optimize_for_size. |
| 30 i::FLAG_max_semi_space_size = i::FLAG_min_semi_space_size; | 32 i::FLAG_max_semi_space_size = max_semi_space_size; |
| 31 v8::Isolate::CreateParams create_params; | 33 v8::Isolate::CreateParams create_params; |
| 32 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 34 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
| 33 v8::Isolate* isolate = v8::Isolate::New(create_params); | 35 v8::Isolate* isolate = v8::Isolate::New(create_params); |
| 34 return isolate; | 36 return isolate; |
| 35 } | 37 } |
| 36 | 38 |
| 37 } // namespace | 39 } // namespace |
| 38 | 40 |
| 39 namespace v8 { | 41 namespace v8 { |
| 40 namespace internal { | 42 namespace internal { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 CHECK(heap->new_space()->ToSpaceContainsSlow(buffer->address())); | 129 CHECK(heap->new_space()->ToSpaceContainsSlow(buffer->address())); |
| 128 heap::GcAndSweep(heap, OLD_SPACE); | 130 heap::GcAndSweep(heap, OLD_SPACE); |
| 129 CHECK(heap->new_space()->ToSpaceContainsSlow(first_object->address())); | 131 CHECK(heap->new_space()->ToSpaceContainsSlow(first_object->address())); |
| 130 CHECK(heap->new_space()->ToSpaceContainsSlow(buffer->address())); | 132 CHECK(heap->new_space()->ToSpaceContainsSlow(buffer->address())); |
| 131 CHECK(to_be_promoted_page->Contains(first_object->address())); | 133 CHECK(to_be_promoted_page->Contains(first_object->address())); |
| 132 CHECK(to_be_promoted_page->Contains(buffer->address())); | 134 CHECK(to_be_promoted_page->Contains(buffer->address())); |
| 133 CHECK(ArrayBufferTracker::IsTracked(*buffer)); | 135 CHECK(ArrayBufferTracker::IsTracked(*buffer)); |
| 134 } | 136 } |
| 135 } | 137 } |
| 136 | 138 |
| 139 UNINITIALIZED_HEAP_TEST(Regress658718) { |
| 140 v8::Isolate* isolate = NewIsolateForPagePromotion(4, 8); |
| 141 Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); |
| 142 { |
| 143 v8::Isolate::Scope isolate_scope(isolate); |
| 144 v8::HandleScope handle_scope(isolate); |
| 145 v8::Context::New(isolate)->Enter(); |
| 146 Heap* heap = i_isolate->heap(); |
| 147 heap->delay_sweeper_tasks_for_testing_ = true; |
| 148 heap->new_space()->Grow(); |
| 149 { |
| 150 v8::HandleScope inner_handle_scope(isolate); |
| 151 std::vector<Handle<FixedArray>> handles; |
| 152 heap::SimulateFullSpace(heap->new_space(), &handles); |
| 153 CHECK_GT(handles.size(), 0u); |
| 154 // Last object in handles should definitely be on the last page which does |
| 155 // not contain the age mark. |
| 156 Handle<FixedArray> last_object = handles.back(); |
| 157 Page* to_be_promoted_page = Page::FromAddress(last_object->address()); |
| 158 CHECK(to_be_promoted_page->Contains(last_object->address())); |
| 159 CHECK(heap->new_space()->ToSpaceContainsSlow(last_object->address())); |
| 160 heap->CollectGarbage(OLD_SPACE, i::GarbageCollectionReason::kTesting); |
| 161 CHECK(heap->new_space()->ToSpaceContainsSlow(last_object->address())); |
| 162 CHECK(to_be_promoted_page->Contains(last_object->address())); |
| 163 } |
| 164 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting); |
| 165 heap->new_space()->Shrink(); |
| 166 heap->memory_allocator()->unmapper()->WaitUntilCompleted(); |
| 167 heap->mark_compact_collector()->sweeper().StartSweeperTasks(); |
| 168 heap->mark_compact_collector()->EnsureSweepingCompleted(); |
| 169 } |
| 170 } |
| 171 |
| 137 } // namespace internal | 172 } // namespace internal |
| 138 } // namespace v8 | 173 } // namespace v8 |
| OLD | NEW |