chromium/v8/test/unittests/heap/global-handles-unittest.cc

// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
//       copyright notice, this list of conditions and the following
//       disclaimer in the documentation and/or other materials provided
//       with the distribution.
//     * Neither the name of Google Inc. nor the names of its
//       contributors may be used to endorse or promote products derived
//       from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "src/handles/global-handles.h"

#include "include/v8-embedder-heap.h"
#include "include/v8-function.h"
#include "src/api/api-inl.h"
#include "src/execution/isolate.h"
#include "src/flags/flags.h"
#include "src/heap/factory.h"
#include "src/heap/heap-inl.h"
#include "src/objects/objects-inl.h"
#include "test/unittests/heap/heap-utils.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace v8 {
namespace internal {

namespace {

struct TracedReferenceWrapper {};

class NonRootingEmbedderRootsHandler final : public v8::EmbedderRootsHandler {};

void SimpleCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {}

struct FlagAndHandles {};

void ResetHandleAndSetFlag(const v8::WeakCallbackInfo<FlagAndHandles>& data) {}

template <typename HandleContainer>
void ConstructJSObject(v8::Isolate* isolate, v8::Local<v8::Context> context,
                       HandleContainer* flag_and_persistent) {}

void ConstructJSObject(v8::Isolate* isolate, v8::Global<v8::Object>* global) {}

void ConstructJSObject(v8::Isolate* isolate,
                       v8::TracedReference<v8::Object>* handle) {}

template <typename HandleContainer>
void ConstructJSApiObject(v8::Isolate* isolate, v8::Local<v8::Context> context,
                          HandleContainer* flag_and_persistent) {}

enum class SurvivalMode {};

template <typename ConstructFunction, typename ModifierFunction,
          typename GCFunction>
void WeakHandleTest(v8::Isolate* isolate, ConstructFunction construct_function,
                    ModifierFunction modifier_function, GCFunction gc_function,
                    SurvivalMode survives) {}

void EmptyWeakCallback(const v8::WeakCallbackInfo<void>& data) {}

class GlobalHandlesTest : public TestWithContext {};

}  // namespace

TEST_F(GlobalHandlesTest, EternalHandles) {}

TEST_F(GlobalHandlesTest, PersistentBaseGetLocal) {}

TEST_F(GlobalHandlesTest, WeakPersistentSmi) {}

TEST_F(GlobalHandlesTest, PhantomHandlesWithoutCallbacks) {}

TEST_F(GlobalHandlesTest, WeakHandleToUnmodifiedJSObjectDiesOnScavenge) {}

TEST_F(GlobalHandlesTest, TracedReferenceToUnmodifiedJSObjectSurvivesScavenge) {}

TEST_F(GlobalHandlesTest, WeakHandleToUnmodifiedJSObjectDiesOnMarkCompact) {}

TEST_F(GlobalHandlesTest,
       WeakHandleToUnmodifiedJSObjectSurvivesMarkCompactWhenInHandle) {}

TEST_F(GlobalHandlesTest, WeakHandleToUnmodifiedJSApiObjectDiesOnScavenge) {}

TEST_F(GlobalHandlesTest,
       TracedReferenceToUnmodifiedJSApiObjectDiesOnScavenge) {}

TEST_F(GlobalHandlesTest,
       TracedReferenceToJSApiObjectWithIdentityHashSurvivesScavenge) {}

TEST_F(GlobalHandlesTest,
       WeakHandleToUnmodifiedJSApiObjectSurvivesScavengeWhenInHandle) {}

TEST_F(GlobalHandlesTest, WeakHandleToUnmodifiedJSApiObjectDiesOnMarkCompact) {}

TEST_F(GlobalHandlesTest,
       WeakHandleToUnmodifiedJSApiObjectSurvivesMarkCompactWhenInHandle) {}

TEST_F(GlobalHandlesTest,
       TracedReferenceToJSApiObjectWithModifiedMapSurvivesScavenge) {}

TEST_F(GlobalHandlesTest,
       TracedReferenceTOJsApiObjectWithElementsSurvivesScavenge) {}

namespace {

void ForceMinorGC2(const v8::WeakCallbackInfo<FlagAndHandles>& data) {}

void ForceMinorGC1(const v8::WeakCallbackInfo<FlagAndHandles>& data) {}

void ForceMajorGC2(const v8::WeakCallbackInfo<FlagAndHandles>& data) {}

void ForceMajorGC1(const v8::WeakCallbackInfo<FlagAndHandles>& data) {}

}  // namespace

TEST_F(GlobalHandlesTest, GCFromWeakCallbacks) {}

namespace {

void SecondPassCallback(const v8::WeakCallbackInfo<FlagAndHandles>& data) {}

void FirstPassCallback(const v8::WeakCallbackInfo<FlagAndHandles>& data) {}

}  // namespace

TEST_F(GlobalHandlesTest, SecondPassPhantomCallbacks) {}

TEST_F(GlobalHandlesTest, MoveStrongGlobal) {}

TEST_F(GlobalHandlesTest, MoveWeakGlobal) {}

TEST_F(GlobalHandlesTest, TotalSizeRegularNode) {}

TEST_F(GlobalHandlesTest, TotalSizeTracedNode) {}

}  // namespace internal
}  // namespace v8