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

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

Issue 2728113002: [heap] Remove Marking::AnyToGrey and change its callers to use simple marking functions. (Closed)
Patch Set: fixed comment 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
(...skipping 14 matching lines...) Expand all
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::BlackToWhite(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, TransitionAnyToGrey) {
36 Bitmap* bitmap = reinterpret_cast<Bitmap*>(
37 calloc(Bitmap::kSize / kPointerSize, kPointerSize));
38 const int kLocationsSize = 3;
39 int position[kLocationsSize] = {
40 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell};
41 for (int i = 0; i < kLocationsSize; i++) {
42 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]);
43 CHECK(Marking::IsWhite(mark_bit));
44 CHECK(!Marking::IsImpossible(mark_bit));
45 Marking::AnyToGrey(mark_bit);
46 CHECK(Marking::IsGrey(mark_bit));
47 CHECK(Marking::IsBlackOrGrey(mark_bit));
48 CHECK(!Marking::IsImpossible(mark_bit));
49 Marking::GreyToBlack(mark_bit);
50 CHECK(Marking::IsBlack(mark_bit));
51 CHECK(Marking::IsBlackOrGrey(mark_bit));
52 CHECK(!Marking::IsImpossible(mark_bit));
53 Marking::AnyToGrey(mark_bit);
54 CHECK(Marking::IsGrey(mark_bit));
55 CHECK(Marking::IsBlackOrGrey(mark_bit));
56 CHECK(!Marking::IsImpossible(mark_bit));
57 Marking::GreyToWhite(mark_bit);
58 CHECK(Marking::IsWhite(mark_bit));
59 CHECK(!Marking::IsImpossible(mark_bit));
60 }
61 free(bitmap);
62 }
63
64 TEST(Marking, TransitionWhiteGreyBlackGrey) { 35 TEST(Marking, TransitionWhiteGreyBlackGrey) {
65 Bitmap* bitmap = reinterpret_cast<Bitmap*>( 36 Bitmap* bitmap = reinterpret_cast<Bitmap*>(
66 calloc(Bitmap::kSize / kPointerSize, kPointerSize)); 37 calloc(Bitmap::kSize / kPointerSize, kPointerSize));
67 const int kLocationsSize = 3; 38 const int kLocationsSize = 3;
68 int position[kLocationsSize] = { 39 int position[kLocationsSize] = {
69 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell}; 40 Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell};
70 for (int i = 0; i < kLocationsSize; i++) { 41 for (int i = 0; i < kLocationsSize; i++) {
71 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]); 42 MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]);
72 CHECK(Marking::IsWhite(mark_bit)); 43 CHECK(Marking::IsWhite(mark_bit));
73 CHECK(!Marking::IsBlackOrGrey(mark_bit)); 44 CHECK(!Marking::IsBlackOrGrey(mark_bit));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 Bitmap::kBitsPerCell, Bitmap::kBitsPerCell + Bitmap::kBitsPerCell / 2)); 103 Bitmap::kBitsPerCell, Bitmap::kBitsPerCell + Bitmap::kBitsPerCell / 2));
133 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[2], 0xff00ffu); 104 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[2], 0xff00ffu);
134 CHECK(bitmap->AllBitsSetInRange(2 * Bitmap::kBitsPerCell, 105 CHECK(bitmap->AllBitsSetInRange(2 * Bitmap::kBitsPerCell,
135 2 * Bitmap::kBitsPerCell + 8)); 106 2 * Bitmap::kBitsPerCell + 8));
136 CHECK(bitmap->AllBitsClearInRange(2 * Bitmap::kBitsPerCell + 24, 107 CHECK(bitmap->AllBitsClearInRange(2 * Bitmap::kBitsPerCell + 24,
137 Bitmap::kBitsPerCell * 3)); 108 Bitmap::kBitsPerCell * 3));
138 free(bitmap); 109 free(bitmap);
139 } 110 }
140 } // namespace internal 111 } // namespace internal
141 } // 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