Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1011)

Side by Side Diff: test/cctest/heap/test-page-promotion.cc

Issue 2310143002: [heap] Introduce enum of garbage collection reasons. (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/heap/test-mark-compact.cc ('k') | test/cctest/test-accessors.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « test/cctest/heap/test-mark-compact.cc ('k') | test/cctest/test-accessors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698