| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |