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

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

Issue 2737483002: [heap] Remove Marking::BlackToWhite and Marking::GreyToWhite. (Closed)
Patch Set: Created 3 years, 9 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 | « src/heap/marking.h ('k') | no next file » | 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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "src/globals.h" 7 #include "src/globals.h"
8 #include "src/heap/marking.h" 8 #include "src/heap/marking.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 14
15 TEST(Marking, TransitionWhiteBlackWhite) { 15 TEST(Marking, TransitionWhiteBlackWhite) {
16 Bitmap* bitmap = reinterpret_cast<Bitmap*>( 16 Bitmap* bitmap = reinterpret_cast<Bitmap*>(
17 calloc(Bitmap::kSize / kPointerSize, kPointerSize)); 17 calloc(Bitmap::kSize / kPointerSize, kPointerSize));
18 const int kLocationsSize = 3; 18 const int kLocationsSize = 3;
19 int position[kLocationsSize] = { 19 int position[kLocationsSize] = {
20 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell}; 20 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell};
21 for (int i = 0; i < kLocationsSize; i++) { 21 for (int i = 0; i < kLocationsSize; i++) {
22 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]); 22 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]);
23 CHECK(Marking::IsWhite(mark_bit)); 23 CHECK(Marking::IsWhite(mark_bit));
24 CHECK(!Marking::IsImpossible(mark_bit)); 24 CHECK(!Marking::IsImpossible(mark_bit));
25 Marking::WhiteToBlack(mark_bit); 25 Marking::WhiteToBlack(mark_bit);
26 CHECK(Marking::IsBlack(mark_bit)); 26 CHECK(Marking::IsBlack(mark_bit));
27 CHECK(!Marking::IsImpossible(mark_bit)); 27 CHECK(!Marking::IsImpossible(mark_bit));
28 Marking::BlackToWhite(mark_bit); 28 Marking::MarkWhite(mark_bit);
29 CHECK(Marking::IsWhite(mark_bit)); 29 CHECK(Marking::IsWhite(mark_bit));
30 CHECK(!Marking::IsImpossible(mark_bit)); 30 CHECK(!Marking::IsImpossible(mark_bit));
31 } 31 }
32 free(bitmap); 32 free(bitmap);
33 } 33 }
34 34
35 TEST(Marking, TransitionWhiteGreyBlackGrey) { 35 TEST(Marking, TransitionWhiteGreyBlackGrey) {
36 Bitmap* bitmap = reinterpret_cast<Bitmap*>( 36 Bitmap* bitmap = reinterpret_cast<Bitmap*>(
37 calloc(Bitmap::kSize / kPointerSize, kPointerSize)); 37 calloc(Bitmap::kSize / kPointerSize, kPointerSize));
38 const int kLocationsSize = 3; 38 const int kLocationsSize = 3;
39 int position[kLocationsSize] = { 39 int position[kLocationsSize] = {
40 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell}; 40 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell};
41 for (int i = 0; i < kLocationsSize; i++) { 41 for (int i = 0; i < kLocationsSize; i++) {
42 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]); 42 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]);
43 CHECK(Marking::IsWhite(mark_bit)); 43 CHECK(Marking::IsWhite(mark_bit));
44 CHECK(!Marking::IsBlackOrGrey(mark_bit)); 44 CHECK(!Marking::IsBlackOrGrey(mark_bit));
45 CHECK(!Marking::IsImpossible(mark_bit)); 45 CHECK(!Marking::IsImpossible(mark_bit));
46 Marking::WhiteToGrey(mark_bit); 46 Marking::WhiteToGrey(mark_bit);
47 CHECK(Marking::IsGrey(mark_bit)); 47 CHECK(Marking::IsGrey(mark_bit));
48 CHECK(Marking::IsBlackOrGrey(mark_bit)); 48 CHECK(Marking::IsBlackOrGrey(mark_bit));
49 CHECK(!Marking::IsImpossible(mark_bit)); 49 CHECK(!Marking::IsImpossible(mark_bit));
50 Marking::GreyToBlack(mark_bit); 50 Marking::GreyToBlack(mark_bit);
51 CHECK(Marking::IsBlack(mark_bit)); 51 CHECK(Marking::IsBlack(mark_bit));
52 CHECK(Marking::IsBlackOrGrey(mark_bit)); 52 CHECK(Marking::IsBlackOrGrey(mark_bit));
53 CHECK(!Marking::IsImpossible(mark_bit)); 53 CHECK(!Marking::IsImpossible(mark_bit));
54 Marking::BlackToGrey(mark_bit); 54 Marking::BlackToGrey(mark_bit);
55 CHECK(Marking::IsGrey(mark_bit)); 55 CHECK(Marking::IsGrey(mark_bit));
56 CHECK(Marking::IsBlackOrGrey(mark_bit)); 56 CHECK(Marking::IsBlackOrGrey(mark_bit));
57 CHECK(!Marking::IsImpossible(mark_bit)); 57 CHECK(!Marking::IsImpossible(mark_bit));
58 Marking::GreyToWhite(mark_bit); 58 Marking::MarkWhite(mark_bit);
59 CHECK(Marking::IsWhite(mark_bit)); 59 CHECK(Marking::IsWhite(mark_bit));
60 CHECK(!Marking::IsImpossible(mark_bit)); 60 CHECK(!Marking::IsImpossible(mark_bit));
61 } 61 }
62 free(bitmap); 62 free(bitmap);
63 } 63 }
64 64
65 TEST(Marking, SetAndClearRange) { 65 TEST(Marking, SetAndClearRange) {
66 Bitmap* bitmap = reinterpret_cast<Bitmap*>( 66 Bitmap* bitmap = reinterpret_cast<Bitmap*>(
67 calloc(Bitmap::kSize / kPointerSize, kPointerSize)); 67 calloc(Bitmap::kSize / kPointerSize, kPointerSize));
68 for (int i = 0; i < 3; i++) { 68 for (int i = 0; i < 3; i++) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 Bitmap::kBitsPerCell, Bitmap::kBitsPerCell + Bitmap::kBitsPerCell / 2)); 103 Bitmap::kBitsPerCell, Bitmap::kBitsPerCell + Bitmap::kBitsPerCell / 2));
104 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[2], 0xff00ffu); 104 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[2], 0xff00ffu);
105 CHECK(bitmap->AllBitsSetInRange(2 * Bitmap::kBitsPerCell, 105 CHECK(bitmap->AllBitsSetInRange(2 * Bitmap::kBitsPerCell,
106 2 * Bitmap::kBitsPerCell + 8)); 106 2 * Bitmap::kBitsPerCell + 8));
107 CHECK(bitmap->AllBitsClearInRange(2 * Bitmap::kBitsPerCell + 24, 107 CHECK(bitmap->AllBitsClearInRange(2 * Bitmap::kBitsPerCell + 24,
108 Bitmap::kBitsPerCell * 3)); 108 Bitmap::kBitsPerCell * 3));
109 free(bitmap); 109 free(bitmap);
110 } 110 }
111 } // namespace internal 111 } // namespace internal
112 } // namespace v8 112 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/marking.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698