| 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-utils.h" | 17 #include "test/cctest/heap/heap-utils.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 v8::Isolate* NewIsolateForPagePromotion() { | 21 v8::Isolate* NewIsolateForPagePromotion() { |
| 22 i::FLAG_page_promotion = true; | 22 i::FLAG_page_promotion = true; |
| 23 i::FLAG_page_promotion_threshold = 0; // % | 23 i::FLAG_page_promotion_threshold = 0; // % |
| 24 i::FLAG_min_semi_space_size = 8 * (i::Page::kPageSize / i::MB); | 24 i::FLAG_min_semi_space_size = 8; |
| 25 // We cannot optimize for size as we require a new space with more than one | 25 // We cannot optimize for size as we require a new space with more than one |
| 26 // page. | 26 // page. |
| 27 i::FLAG_optimize_for_size = false; | 27 i::FLAG_optimize_for_size = false; |
| 28 // Set max_semi_space_size because it could've been initialized by an | 28 // Set max_semi_space_size because it could've been initialized by an |
| 29 // implication of optimize_for_size. | 29 // implication of optimize_for_size. |
| 30 i::FLAG_max_semi_space_size = i::FLAG_min_semi_space_size; | 30 i::FLAG_max_semi_space_size = i::FLAG_min_semi_space_size; |
| 31 v8::Isolate::CreateParams create_params; | 31 v8::Isolate::CreateParams create_params; |
| 32 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 32 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
| 33 v8::Isolate* isolate = v8::Isolate::New(create_params); | 33 v8::Isolate* isolate = v8::Isolate::New(create_params); |
| 34 return isolate; | 34 return isolate; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 v8::Isolate* isolate = NewIsolateForPagePromotion(); | 102 v8::Isolate* isolate = NewIsolateForPagePromotion(); |
| 103 Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); | 103 Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); |
| 104 { | 104 { |
| 105 v8::Isolate::Scope isolate_scope(isolate); | 105 v8::Isolate::Scope isolate_scope(isolate); |
| 106 v8::HandleScope handle_scope(isolate); | 106 v8::HandleScope handle_scope(isolate); |
| 107 v8::Context::New(isolate)->Enter(); | 107 v8::Context::New(isolate)->Enter(); |
| 108 Heap* heap = i_isolate->heap(); | 108 Heap* heap = i_isolate->heap(); |
| 109 | 109 |
| 110 // Fill the current page which potentially contains the age mark. | 110 // Fill the current page which potentially contains the age mark. |
| 111 heap::FillCurrentPage(heap->new_space()); | 111 heap::FillCurrentPage(heap->new_space()); |
| 112 | |
| 113 // Allocate a buffer we would like to check against. | 112 // Allocate a buffer we would like to check against. |
| 114 Handle<JSArrayBuffer> buffer = | 113 Handle<JSArrayBuffer> buffer = |
| 115 i_isolate->factory()->NewJSArrayBuffer(SharedFlag::kNotShared); | 114 i_isolate->factory()->NewJSArrayBuffer(SharedFlag::kNotShared); |
| 116 JSArrayBuffer::SetupAllocatingData(buffer, i_isolate, 100); | 115 JSArrayBuffer::SetupAllocatingData(buffer, i_isolate, 100); |
| 117 std::vector<Handle<FixedArray>> handles; | 116 std::vector<Handle<FixedArray>> handles; |
| 118 // Simulate a full space, filling the interesting page with live objects. | 117 // Simulate a full space, filling the interesting page with live objects. |
| 119 heap::SimulateFullSpace(heap->new_space(), &handles); | 118 heap::SimulateFullSpace(heap->new_space(), &handles); |
| 120 CHECK_GT(handles.size(), 0u); | 119 CHECK_GT(handles.size(), 0u); |
| 121 // Last object in handles should definitely be on the last page which does | 120 // Last object in handles should definitely be on the last page which does |
| 122 // not contain the age mark. | 121 // not contain the age mark. |
| 123 Handle<FixedArray> first_object = handles.front(); | 122 Handle<FixedArray> first_object = handles.front(); |
| 124 Page* to_be_promoted_page = Page::FromAddress(first_object->address()); | 123 Page* to_be_promoted_page = Page::FromAddress(first_object->address()); |
| 125 CHECK(to_be_promoted_page->Contains(first_object->address())); | 124 CHECK(to_be_promoted_page->Contains(first_object->address())); |
| 126 CHECK(to_be_promoted_page->Contains(buffer->address())); | 125 CHECK(to_be_promoted_page->Contains(buffer->address())); |
| 127 CHECK(heap->new_space()->ToSpaceContainsSlow(first_object->address())); | 126 CHECK(heap->new_space()->ToSpaceContainsSlow(first_object->address())); |
| 128 CHECK(heap->new_space()->ToSpaceContainsSlow(buffer->address())); | 127 CHECK(heap->new_space()->ToSpaceContainsSlow(buffer->address())); |
| 129 heap::GcAndSweep(heap, OLD_SPACE); | 128 heap::GcAndSweep(heap, OLD_SPACE); |
| 130 CHECK(heap->new_space()->ToSpaceContainsSlow(first_object->address())); | 129 CHECK(heap->new_space()->ToSpaceContainsSlow(first_object->address())); |
| 131 CHECK(heap->new_space()->ToSpaceContainsSlow(buffer->address())); | 130 CHECK(heap->new_space()->ToSpaceContainsSlow(buffer->address())); |
| 132 CHECK(to_be_promoted_page->Contains(first_object->address())); | 131 CHECK(to_be_promoted_page->Contains(first_object->address())); |
| 133 CHECK(to_be_promoted_page->Contains(buffer->address())); | 132 CHECK(to_be_promoted_page->Contains(buffer->address())); |
| 134 CHECK(ArrayBufferTracker::IsTracked(*buffer)); | 133 CHECK(ArrayBufferTracker::IsTracked(*buffer)); |
| 135 } | 134 } |
| 136 } | 135 } |
| 137 | 136 |
| 138 } // namespace internal | 137 } // namespace internal |
| 139 } // namespace v8 | 138 } // namespace v8 |
| OLD | NEW |