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

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

Issue 2139133003: [heap] Untangle Marking and friends from heap dependencies. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix comment formatting Created 4 years, 5 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/test-unboxed-doubles.cc ('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 2016 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 <stdlib.h>
6
7 #include "src/globals.h"
8 #include "src/heap/marking.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace v8 {
12 namespace internal {
13
14 TEST(Marking, MarkWhiteBlackWhite) {
15 Bitmap* bitmap = reinterpret_cast<Bitmap*>(
16 calloc(Bitmap::kSize / kPointerSize, kPointerSize));
17 const int kLocationsSize = 3;
18 int position[kLocationsSize] = {
19 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell};
20 for (int i = 0; i < kLocationsSize; i++) {
21 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]);
22 CHECK(Marking::IsWhite(mark_bit));
23 CHECK(!Marking::IsImpossible(mark_bit));
24 Marking::MarkBlack(mark_bit);
25 CHECK(Marking::IsBlack(mark_bit));
26 CHECK(!Marking::IsImpossible(mark_bit));
27 Marking::MarkWhite(mark_bit);
28 CHECK(Marking::IsWhite(mark_bit));
29 CHECK(!Marking::IsImpossible(mark_bit));
30 }
31 free(bitmap);
32 }
33
34 TEST(Marking, TransitionWhiteBlackWhite) {
35 Bitmap* bitmap = reinterpret_cast<Bitmap*>(
36 calloc(Bitmap::kSize / kPointerSize, kPointerSize));
37 const int kLocationsSize = 3;
38 int position[kLocationsSize] = {
39 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell};
40 for (int i = 0; i < kLocationsSize; i++) {
41 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]);
42 CHECK(Marking::IsWhite(mark_bit));
43 CHECK(!Marking::IsImpossible(mark_bit));
44 Marking::WhiteToBlack(mark_bit);
45 CHECK(Marking::IsBlack(mark_bit));
46 CHECK(!Marking::IsImpossible(mark_bit));
47 Marking::BlackToWhite(mark_bit);
48 CHECK(Marking::IsWhite(mark_bit));
49 CHECK(!Marking::IsImpossible(mark_bit));
50 }
51 free(bitmap);
52 }
53
54 TEST(Marking, TransitionAnyToGrey) {
55 Bitmap* bitmap = reinterpret_cast<Bitmap*>(
56 calloc(Bitmap::kSize / kPointerSize, kPointerSize));
57 const int kLocationsSize = 3;
58 int position[kLocationsSize] = {
59 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell};
60 for (int i = 0; i < kLocationsSize; i++) {
61 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]);
62 CHECK(Marking::IsWhite(mark_bit));
63 CHECK(!Marking::IsImpossible(mark_bit));
64 Marking::AnyToGrey(mark_bit);
65 CHECK(Marking::IsGrey(mark_bit));
66 CHECK(Marking::IsBlackOrGrey(mark_bit));
67 CHECK(!Marking::IsImpossible(mark_bit));
68 Marking::MarkBlack(mark_bit);
69 CHECK(Marking::IsBlack(mark_bit));
70 CHECK(Marking::IsBlackOrGrey(mark_bit));
71 CHECK(!Marking::IsImpossible(mark_bit));
72 Marking::AnyToGrey(mark_bit);
73 CHECK(Marking::IsGrey(mark_bit));
74 CHECK(Marking::IsBlackOrGrey(mark_bit));
75 CHECK(!Marking::IsImpossible(mark_bit));
76 Marking::MarkWhite(mark_bit);
77 CHECK(Marking::IsWhite(mark_bit));
78 CHECK(!Marking::IsImpossible(mark_bit));
79 }
80 free(bitmap);
81 }
82
83 TEST(Marking, TransitionWhiteGreyBlackGrey) {
84 Bitmap* bitmap = reinterpret_cast<Bitmap*>(
85 calloc(Bitmap::kSize / kPointerSize, kPointerSize));
86 const int kLocationsSize = 3;
87 int position[kLocationsSize] = {
88 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell};
89 for (int i = 0; i < kLocationsSize; i++) {
90 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]);
91 CHECK(Marking::IsWhite(mark_bit));
92 CHECK(!Marking::IsBlackOrGrey(mark_bit));
93 CHECK(!Marking::IsImpossible(mark_bit));
94 Marking::WhiteToGrey(mark_bit);
95 CHECK(Marking::IsGrey(mark_bit));
96 CHECK(Marking::IsBlackOrGrey(mark_bit));
97 CHECK(!Marking::IsImpossible(mark_bit));
98 Marking::GreyToBlack(mark_bit);
99 CHECK(Marking::IsBlack(mark_bit));
100 CHECK(Marking::IsBlackOrGrey(mark_bit));
101 CHECK(!Marking::IsImpossible(mark_bit));
102 Marking::BlackToGrey(mark_bit);
103 CHECK(Marking::IsGrey(mark_bit));
104 CHECK(Marking::IsBlackOrGrey(mark_bit));
105 CHECK(!Marking::IsImpossible(mark_bit));
106 Marking::MarkWhite(mark_bit);
107 CHECK(Marking::IsWhite(mark_bit));
108 CHECK(!Marking::IsImpossible(mark_bit));
109 }
110 free(bitmap);
111 }
112
113 } // namespace internal
114 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/test-unboxed-doubles.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698