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

Unified Diff: test/unittests/heap/marking-unittest.cc

Issue 2139133003: [heap] Untangle Marking and friends from heap dependencies. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix comment formatting Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-unboxed-doubles.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/heap/marking-unittest.cc
diff --git a/test/unittests/heap/marking-unittest.cc b/test/unittests/heap/marking-unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5be909a1a400a7f7babe9d30cf749df4b78cb5f3
--- /dev/null
+++ b/test/unittests/heap/marking-unittest.cc
@@ -0,0 +1,114 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <stdlib.h>
+
+#include "src/globals.h"
+#include "src/heap/marking.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace internal {
+
+TEST(Marking, MarkWhiteBlackWhite) {
+ Bitmap* bitmap = reinterpret_cast<Bitmap*>(
+ calloc(Bitmap::kSize / kPointerSize, kPointerSize));
+ const int kLocationsSize = 3;
+ int position[kLocationsSize] = {
+ Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell};
+ for (int i = 0; i < kLocationsSize; i++) {
+ MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]);
+ CHECK(Marking::IsWhite(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ Marking::MarkBlack(mark_bit);
+ CHECK(Marking::IsBlack(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ Marking::MarkWhite(mark_bit);
+ CHECK(Marking::IsWhite(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ }
+ free(bitmap);
+}
+
+TEST(Marking, TransitionWhiteBlackWhite) {
+ Bitmap* bitmap = reinterpret_cast<Bitmap*>(
+ calloc(Bitmap::kSize / kPointerSize, kPointerSize));
+ const int kLocationsSize = 3;
+ int position[kLocationsSize] = {
+ Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell};
+ for (int i = 0; i < kLocationsSize; i++) {
+ MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]);
+ CHECK(Marking::IsWhite(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ Marking::WhiteToBlack(mark_bit);
+ CHECK(Marking::IsBlack(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ Marking::BlackToWhite(mark_bit);
+ CHECK(Marking::IsWhite(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ }
+ free(bitmap);
+}
+
+TEST(Marking, TransitionAnyToGrey) {
+ Bitmap* bitmap = reinterpret_cast<Bitmap*>(
+ calloc(Bitmap::kSize / kPointerSize, kPointerSize));
+ const int kLocationsSize = 3;
+ int position[kLocationsSize] = {
+ Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell};
+ for (int i = 0; i < kLocationsSize; i++) {
+ MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]);
+ CHECK(Marking::IsWhite(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ Marking::AnyToGrey(mark_bit);
+ CHECK(Marking::IsGrey(mark_bit));
+ CHECK(Marking::IsBlackOrGrey(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ Marking::MarkBlack(mark_bit);
+ CHECK(Marking::IsBlack(mark_bit));
+ CHECK(Marking::IsBlackOrGrey(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ Marking::AnyToGrey(mark_bit);
+ CHECK(Marking::IsGrey(mark_bit));
+ CHECK(Marking::IsBlackOrGrey(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ Marking::MarkWhite(mark_bit);
+ CHECK(Marking::IsWhite(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ }
+ free(bitmap);
+}
+
+TEST(Marking, TransitionWhiteGreyBlackGrey) {
+ Bitmap* bitmap = reinterpret_cast<Bitmap*>(
+ calloc(Bitmap::kSize / kPointerSize, kPointerSize));
+ const int kLocationsSize = 3;
+ int position[kLocationsSize] = {
+ Bitmap::kBitsPerCell - 2, Bitmap::kBitsPerCell - 1, Bitmap::kBitsPerCell};
+ for (int i = 0; i < kLocationsSize; i++) {
+ MarkBit mark_bit = bitmap->MarkBitFromIndex(position[i]);
+ CHECK(Marking::IsWhite(mark_bit));
+ CHECK(!Marking::IsBlackOrGrey(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ Marking::WhiteToGrey(mark_bit);
+ CHECK(Marking::IsGrey(mark_bit));
+ CHECK(Marking::IsBlackOrGrey(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ Marking::GreyToBlack(mark_bit);
+ CHECK(Marking::IsBlack(mark_bit));
+ CHECK(Marking::IsBlackOrGrey(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ Marking::BlackToGrey(mark_bit);
+ CHECK(Marking::IsGrey(mark_bit));
+ CHECK(Marking::IsBlackOrGrey(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ Marking::MarkWhite(mark_bit);
+ CHECK(Marking::IsWhite(mark_bit));
+ CHECK(!Marking::IsImpossible(mark_bit));
+ }
+ free(bitmap);
+}
+
+} // namespace internal
+} // namespace v8
« no previous file with comments | « test/cctest/test-unboxed-doubles.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698