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

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

Issue 2489933002: [heap] Fix -Wsign-compare warnings (Closed)
Patch Set: fix test Created 4 years, 1 month 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/heap/test-spaces.cc ('k') | test/unittests/heap/slot-set-unittest.cc » ('j') | 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 CHECK(!Marking::IsImpossible(mark_bit)); 108 CHECK(!Marking::IsImpossible(mark_bit));
109 } 109 }
110 free(bitmap); 110 free(bitmap);
111 } 111 }
112 112
113 TEST(Marking, SetAndClearRange) { 113 TEST(Marking, SetAndClearRange) {
114 Bitmap* bitmap = reinterpret_cast<Bitmap*>( 114 Bitmap* bitmap = reinterpret_cast<Bitmap*>(
115 calloc(Bitmap::kSize / kPointerSize, kPointerSize)); 115 calloc(Bitmap::kSize / kPointerSize, kPointerSize));
116 for (int i = 0; i < 3; i++) { 116 for (int i = 0; i < 3; i++) {
117 bitmap->SetRange(i, Bitmap::kBitsPerCell + i); 117 bitmap->SetRange(i, Bitmap::kBitsPerCell + i);
118 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[0], 0xffffffff << i); 118 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[0], 0xffffffffu << i);
119 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[1], (1 << i) - 1); 119 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[1], (1u << i) - 1);
120 bitmap->ClearRange(i, Bitmap::kBitsPerCell + i); 120 bitmap->ClearRange(i, Bitmap::kBitsPerCell + i);
121 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[0], 0x0); 121 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[0], 0x0);
122 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[1], 0x0); 122 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[1], 0x0);
123 } 123 }
124 free(bitmap); 124 free(bitmap);
125 } 125 }
126 126
127 TEST(Marking, ClearMultipleRanges) { 127 TEST(Marking, ClearMultipleRanges) {
128 Bitmap* bitmap = reinterpret_cast<Bitmap*>( 128 Bitmap* bitmap = reinterpret_cast<Bitmap*>(
129 calloc(Bitmap::kSize / kPointerSize, kPointerSize)); 129 calloc(Bitmap::kSize / kPointerSize, kPointerSize));
130 CHECK(bitmap->AllBitsClearInRange(0, Bitmap::kBitsPerCell * 3)); 130 CHECK(bitmap->AllBitsClearInRange(0, Bitmap::kBitsPerCell * 3));
131 bitmap->SetRange(0, Bitmap::kBitsPerCell * 3); 131 bitmap->SetRange(0, Bitmap::kBitsPerCell * 3);
132 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[0], 0xffffffff); 132 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[0], 0xffffffffu);
133 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[1], 0xffffffff); 133 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[1], 0xffffffffu);
134 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[2], 0xffffffff); 134 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[2], 0xffffffffu);
135 CHECK(bitmap->AllBitsSetInRange(0, Bitmap::kBitsPerCell * 3)); 135 CHECK(bitmap->AllBitsSetInRange(0, Bitmap::kBitsPerCell * 3));
136 bitmap->ClearRange(Bitmap::kBitsPerCell / 2, Bitmap::kBitsPerCell); 136 bitmap->ClearRange(Bitmap::kBitsPerCell / 2, Bitmap::kBitsPerCell);
137 bitmap->ClearRange(Bitmap::kBitsPerCell, 137 bitmap->ClearRange(Bitmap::kBitsPerCell,
138 Bitmap::kBitsPerCell + Bitmap::kBitsPerCell / 2); 138 Bitmap::kBitsPerCell + Bitmap::kBitsPerCell / 2);
139 bitmap->ClearRange(Bitmap::kBitsPerCell * 2 + 8, 139 bitmap->ClearRange(Bitmap::kBitsPerCell * 2 + 8,
140 Bitmap::kBitsPerCell * 2 + 16); 140 Bitmap::kBitsPerCell * 2 + 16);
141 bitmap->ClearRange(Bitmap::kBitsPerCell * 2 + 24, Bitmap::kBitsPerCell * 3); 141 bitmap->ClearRange(Bitmap::kBitsPerCell * 2 + 24, Bitmap::kBitsPerCell * 3);
142 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[0], 0xffff); 142 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[0], 0xffff);
143 CHECK(bitmap->AllBitsSetInRange(0, Bitmap::kBitsPerCell / 2)); 143 CHECK(bitmap->AllBitsSetInRange(0, Bitmap::kBitsPerCell / 2));
144 CHECK(bitmap->AllBitsClearInRange(Bitmap::kBitsPerCell / 2, 144 CHECK(bitmap->AllBitsClearInRange(Bitmap::kBitsPerCell / 2,
145 Bitmap::kBitsPerCell)); 145 Bitmap::kBitsPerCell));
146 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[1], 0xffff0000); 146 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[1], 0xffff0000u);
147 CHECK( 147 CHECK(
148 bitmap->AllBitsSetInRange(Bitmap::kBitsPerCell + Bitmap::kBitsPerCell / 2, 148 bitmap->AllBitsSetInRange(Bitmap::kBitsPerCell + Bitmap::kBitsPerCell / 2,
149 2 * Bitmap::kBitsPerCell)); 149 2 * Bitmap::kBitsPerCell));
150 CHECK(bitmap->AllBitsClearInRange( 150 CHECK(bitmap->AllBitsClearInRange(
151 Bitmap::kBitsPerCell, Bitmap::kBitsPerCell + Bitmap::kBitsPerCell / 2)); 151 Bitmap::kBitsPerCell, Bitmap::kBitsPerCell + Bitmap::kBitsPerCell / 2));
152 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[2], 0xff00ff); 152 CHECK_EQ(reinterpret_cast<uint32_t*>(bitmap)[2], 0xff00ffu);
153 CHECK(bitmap->AllBitsSetInRange(2 * Bitmap::kBitsPerCell, 153 CHECK(bitmap->AllBitsSetInRange(2 * Bitmap::kBitsPerCell,
154 2 * Bitmap::kBitsPerCell + 8)); 154 2 * Bitmap::kBitsPerCell + 8));
155 CHECK(bitmap->AllBitsClearInRange(2 * Bitmap::kBitsPerCell + 24, 155 CHECK(bitmap->AllBitsClearInRange(2 * Bitmap::kBitsPerCell + 24,
156 Bitmap::kBitsPerCell * 3)); 156 Bitmap::kBitsPerCell * 3));
157 free(bitmap); 157 free(bitmap);
158 } 158 }
159 } // namespace internal 159 } // namespace internal
160 } // namespace v8 160 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/heap/test-spaces.cc ('k') | test/unittests/heap/slot-set-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698