chromium/v8/test/unittests/objects/roots-unittest.cc

// Copyright 2018 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 "src/common/globals.h"
#include "src/heap/heap-inl.h"
#include "src/heap/memory-chunk-metadata.h"
#include "src/objects/cell.h"
#include "src/objects/feedback-cell.h"
#include "src/objects/script.h"
#include "src/roots/roots-inl.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace v8 {
namespace internal {

using RootsTest = TestWithIsolate;

namespace {
AllocationSpace GetSpaceFromObject(Tagged<Object> object) {}
}  // namespace

#define CHECK_IN_RO_SPACE

// The following tests check that all the roots accessible via ReadOnlyRoots are
// in RO_SPACE.
TEST_F(RootsTest, TestReadOnlyRoots) {}

#undef CHECK_IN_RO_SPACE

namespace {
// Applies to objects in mutable root slots; specific slots may point into RO
// space (e.g. because the slot value may change and only the initial value is
// in RO space; or, because RO promotion dynamically decides whether to promote
// the slot value to RO space).
bool CanBeInReadOnlySpace(Factory* factory, Handle<Object> object) {}

// Some mutable roots may initially point to undefined until they are properly
// initialized.
bool IsUninitialized(DirectHandle<Object> object) {}
}  // namespace

// The CHECK_EQ line is there just to ensure that the root is publicly
// accessible from Heap, but ultimately the factory is used as it provides
// handles that have the address in the root table.
#define CHECK_NOT_IN_RO_SPACE

// The following tests check that all the roots accessible via public Heap
// accessors are not in RO_SPACE (with some exceptions, see
// CanBeInReadOnlySpace).
TEST_F(RootsTest, TestHeapRootsNotReadOnly) {}

TEST_F(RootsTest, TestHeapNumberList) {}

#undef CHECK_NOT_IN_RO_SPACE

}  // namespace internal
}  // namespace v8