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

Side by Side Diff: test/unittests/heap/spaces-unittest.cc

Issue 2796033002: [heap] Fix CompactionSpace test and move to unittests (Closed)
Patch Set: Win compile failures Created 3 years, 8 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/unittests/BUILD.gn ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/heap/heap-inl.h"
6 #include "src/heap/spaces-inl.h"
7 #include "src/isolate.h"
8 #include "test/unittests/test-utils.h"
9
10 namespace v8 {
11 namespace internal {
12
13 typedef TestWithIsolate SpacesTest;
14
15 TEST_F(SpacesTest, CompactionSpaceMerge) {
16 Heap* heap = i_isolate()->heap();
17 OldSpace* old_space = heap->old_space();
18 EXPECT_TRUE(old_space != NULL);
19
20 CompactionSpace* compaction_space =
21 new CompactionSpace(heap, OLD_SPACE, NOT_EXECUTABLE);
22 EXPECT_TRUE(compaction_space != NULL);
23 EXPECT_TRUE(compaction_space->SetUp());
24
25 // Cannot loop until "Available()" since we initially have 0 bytes available
26 // and would thus neither grow, nor be able to allocate an object.
27 const int kNumObjects = 10;
28 const int kNumObjectsPerPage =
29 compaction_space->AreaSize() / kMaxRegularHeapObjectSize;
30 const int kExpectedPages =
31 (kNumObjects + kNumObjectsPerPage - 1) / kNumObjectsPerPage;
32 for (int i = 0; i < kNumObjects; i++) {
33 HeapObject* object =
34 compaction_space->AllocateRawUnaligned(kMaxRegularHeapObjectSize)
35 .ToObjectChecked();
36 heap->CreateFillerObjectAt(object->address(), kMaxRegularHeapObjectSize,
37 ClearRecordedSlots::kNo);
38 }
39 int pages_in_old_space = old_space->CountTotalPages();
40 int pages_in_compaction_space = compaction_space->CountTotalPages();
41 EXPECT_EQ(kExpectedPages, pages_in_compaction_space);
42 old_space->MergeCompactionSpace(compaction_space);
43 EXPECT_EQ(pages_in_old_space + pages_in_compaction_space,
44 old_space->CountTotalPages());
45
46 delete compaction_space;
47 }
48
49 } // namespace internal
50 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/BUILD.gn ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698