OLD | NEW |
---|---|
(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*>(calloc(Bitmap::kSize, 0)); | |
16 const int kLocationsSize = 3; | |
17 int position[kLocationsSize] = { | |
18 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell}; | |
19 for (int i = 0; i < kLocationsSize; i++) { | |
20 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]); | |
21 CHECK(Marking::IsWhite(mark_bit)); | |
22 CHECK(!Marking::IsImpossible(mark_bit)); | |
23 Marking::MarkBlack(mark_bit); | |
24 CHECK(Marking::IsBlack(mark_bit)); | |
25 CHECK(!Marking::IsImpossible(mark_bit)); | |
26 Marking::MarkWhite(mark_bit); | |
27 CHECK(Marking::IsWhite(mark_bit)); | |
28 CHECK(!Marking::IsImpossible(mark_bit)); | |
29 } | |
Michael Lippautz
2016/07/12 14:22:31
free(bitmap) or you will get mail from leak saniti
Hannes Payer (out of office)
2016/07/12 14:44:26
Done.
| |
30 } | |
31 | |
32 TEST(Marking, TransitionWhiteBlackWhite) { | |
33 Bitmap* bitmap = reinterpret_cast<Bitmap*>(calloc(Bitmap::kSize, 0)); | |
34 const int kLocationsSize = 3; | |
35 int position[kLocationsSize] = { | |
36 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell}; | |
37 for (int i = 0; i < kLocationsSize; i++) { | |
38 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]); | |
39 CHECK(Marking::IsWhite(mark_bit)); | |
40 CHECK(!Marking::IsImpossible(mark_bit)); | |
41 Marking::WhiteToBlack(mark_bit); | |
42 CHECK(Marking::IsBlack(mark_bit)); | |
43 CHECK(!Marking::IsImpossible(mark_bit)); | |
44 Marking::BlackToWhite(mark_bit); | |
45 CHECK(Marking::IsWhite(mark_bit)); | |
46 CHECK(!Marking::IsImpossible(mark_bit)); | |
47 } | |
48 } | |
49 | |
50 TEST(Marking, TransitionAnyToGrey) { | |
51 Bitmap* bitmap = reinterpret_cast<Bitmap*>(calloc(Bitmap::kSize, 0)); | |
52 const int kLocationsSize = 3; | |
53 int position[kLocationsSize] = { | |
54 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell}; | |
55 for (int i = 0; i < kLocationsSize; i++) { | |
56 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]); | |
57 CHECK(Marking::IsWhite(mark_bit)); | |
58 CHECK(!Marking::IsImpossible(mark_bit)); | |
59 Marking::AnyToGrey(mark_bit); | |
60 CHECK(Marking::IsGrey(mark_bit)); | |
61 CHECK(Marking::IsBlackOrGrey(mark_bit)); | |
62 CHECK(!Marking::IsImpossible(mark_bit)); | |
63 Marking::MarkBlack(mark_bit); | |
64 CHECK(Marking::IsBlack(mark_bit)); | |
65 CHECK(Marking::IsBlackOrGrey(mark_bit)); | |
66 CHECK(!Marking::IsImpossible(mark_bit)); | |
67 Marking::AnyToGrey(mark_bit); | |
68 CHECK(Marking::IsGrey(mark_bit)); | |
69 CHECK(Marking::IsBlackOrGrey(mark_bit)); | |
70 CHECK(!Marking::IsImpossible(mark_bit)); | |
71 } | |
72 } | |
73 | |
74 TEST(Marking, TransitionWhiteGreyBlackGrey) { | |
75 Bitmap* bitmap = reinterpret_cast<Bitmap*>(calloc(Bitmap::kSize, 0)); | |
76 const int kLocationsSize = 3; | |
77 int position[kLocationsSize] = { | |
78 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell}; | |
79 for (int i = 0; i < kLocationsSize; i++) { | |
80 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]); | |
81 CHECK(Marking::IsWhite(mark_bit)); | |
82 CHECK(!Marking::IsBlackOrGrey(mark_bit)); | |
83 CHECK(!Marking::IsImpossible(mark_bit)); | |
84 Marking::WhiteToGrey(mark_bit); | |
85 CHECK(Marking::IsGrey(mark_bit)); | |
86 CHECK(Marking::IsBlackOrGrey(mark_bit)); | |
87 CHECK(!Marking::IsImpossible(mark_bit)); | |
88 Marking::GreyToBlack(mark_bit); | |
89 CHECK(Marking::IsBlack(mark_bit)); | |
90 CHECK(Marking::IsBlackOrGrey(mark_bit)); | |
91 CHECK(!Marking::IsImpossible(mark_bit)); | |
92 Marking::BlackToGrey(mark_bit); | |
93 CHECK(Marking::IsGrey(mark_bit)); | |
94 CHECK(Marking::IsBlackOrGrey(mark_bit)); | |
95 CHECK(!Marking::IsImpossible(mark_bit)); | |
96 } | |
97 } | |
98 | |
99 } // namespace internal | |
100 } // namespace v8 | |
OLD | NEW |