#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 { … };
}
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) { … }
}
TEST_F(GlobalHandlesTest, GCFromWeakCallbacks) { … }
namespace {
void SecondPassCallback(const v8::WeakCallbackInfo<FlagAndHandles>& data) { … }
void FirstPassCallback(const v8::WeakCallbackInfo<FlagAndHandles>& data) { … }
}
TEST_F(GlobalHandlesTest, SecondPassPhantomCallbacks) { … }
TEST_F(GlobalHandlesTest, MoveStrongGlobal) { … }
TEST_F(GlobalHandlesTest, MoveWeakGlobal) { … }
TEST_F(GlobalHandlesTest, TotalSizeRegularNode) { … }
TEST_F(GlobalHandlesTest, TotalSizeTracedNode) { … }
}
}