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 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 v8::Isolate* isolate = NewIsolateForPagePromotion(); | 43 v8::Isolate* isolate = NewIsolateForPagePromotion(); |
44 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 44 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
45 { | 45 { |
46 v8::Isolate::Scope isolate_scope(isolate); | 46 v8::Isolate::Scope isolate_scope(isolate); |
47 v8::HandleScope handle_scope(isolate); | 47 v8::HandleScope handle_scope(isolate); |
48 v8::Context::New(isolate)->Enter(); | 48 v8::Context::New(isolate)->Enter(); |
49 Heap* heap = i_isolate->heap(); | 49 Heap* heap = i_isolate->heap(); |
50 | 50 |
51 std::vector<Handle<FixedArray>> handles; | 51 std::vector<Handle<FixedArray>> handles; |
52 heap::SimulateFullSpace(heap->new_space(), &handles); | 52 heap::SimulateFullSpace(heap->new_space(), &handles); |
53 heap->CollectGarbage(NEW_SPACE); | 53 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting); |
54 CHECK_GT(handles.size(), 0u); | 54 CHECK_GT(handles.size(), 0u); |
55 // First object in handle should be on the first page. | 55 // First object in handle should be on the first page. |
56 Handle<FixedArray> first_object = handles.front(); | 56 Handle<FixedArray> first_object = handles.front(); |
57 Page* first_page = Page::FromAddress(first_object->address()); | 57 Page* first_page = Page::FromAddress(first_object->address()); |
58 // To perform a sanity check on live bytes we need to mark the heap. | 58 // To perform a sanity check on live bytes we need to mark the heap. |
59 heap::SimulateIncrementalMarking(heap, true); | 59 heap::SimulateIncrementalMarking(heap, true); |
60 // Sanity check that the page meets the requirements for promotion. | 60 // Sanity check that the page meets the requirements for promotion. |
61 const int threshold_bytes = | 61 const int threshold_bytes = |
62 FLAG_page_promotion_threshold * Page::kAllocatableMemory / 100; | 62 FLAG_page_promotion_threshold * Page::kAllocatableMemory / 100; |
63 CHECK_GE(first_page->LiveBytes(), threshold_bytes); | 63 CHECK_GE(first_page->LiveBytes(), threshold_bytes); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 CHECK(heap->new_space()->ToSpaceContainsSlow(first_object->address())); | 130 CHECK(heap->new_space()->ToSpaceContainsSlow(first_object->address())); |
131 CHECK(heap->new_space()->ToSpaceContainsSlow(buffer->address())); | 131 CHECK(heap->new_space()->ToSpaceContainsSlow(buffer->address())); |
132 CHECK(to_be_promoted_page->Contains(first_object->address())); | 132 CHECK(to_be_promoted_page->Contains(first_object->address())); |
133 CHECK(to_be_promoted_page->Contains(buffer->address())); | 133 CHECK(to_be_promoted_page->Contains(buffer->address())); |
134 CHECK(ArrayBufferTracker::IsTracked(*buffer)); | 134 CHECK(ArrayBufferTracker::IsTracked(*buffer)); |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 } // namespace internal | 138 } // namespace internal |
139 } // namespace v8 | 139 } // namespace v8 |
OLD | NEW |