Commit f6386018 authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

[api] Remove TracedGlobal<>

Remove deprecated TracedGlobal<>, greatly simplifying handling of
traced references in general.

Also saves a word per v8::TracedReference as there's no need to keep a
possible callback around.

Bug: v8:12603
Change-Id: Ice35d7906775b912d02e97a27a722b3e1cec28d9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3532251Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79589}
parent 574c2809
...@@ -34,29 +34,22 @@ class V8_EXPORT EmbedderRootsHandler { ...@@ -34,29 +34,22 @@ class V8_EXPORT EmbedderRootsHandler {
virtual ~EmbedderRootsHandler() = default; virtual ~EmbedderRootsHandler() = default;
/** /**
* Returns true if the TracedGlobal handle should be considered as root for * Returns true if the |TracedReference| handle should be considered as root
* the currently running non-tracing garbage collection and false otherwise. * for the currently running non-tracing garbage collection and false
* The default implementation will keep all TracedGlobal references as roots. * otherwise. The default implementation will keep all |TracedReference|
* references as roots.
* *
* If this returns false, then V8 may decide that the object referred to by * If this returns false, then V8 may decide that the object referred to by
* such a handle is reclaimed. In that case: * such a handle is reclaimed. In that case, V8 calls |ResetRoot()| for the
* - No action is required if handles are used with destructors, i.e., by just * |TracedReference|.
* using |TracedGlobal|.
* - When run without destructors, i.e., by using |TracedReference|, V8 calls
* |ResetRoot|.
* *
* Note that the |handle| is different from the handle that the embedder holds * Note that the `handle` is different from the handle that the embedder holds
* for retaining the object. The embedder may use |WrapperClassId()| to * for retaining the object. The embedder may use |WrapperClassId()| to
* distinguish cases where it wants handles to be treated as roots from not * distinguish cases where it wants handles to be treated as roots from not
* being treated as roots. * being treated as roots.
*/ */
virtual bool IsRoot(const v8::TracedReference<v8::Value>& handle) = 0; virtual bool IsRoot(const v8::TracedReference<v8::Value>& handle) = 0;
V8_DEPRECATED("See v8::TracedGlobal class comment.")
virtual bool IsRoot(const v8::TracedGlobal<v8::Value>& handle) {
return true;
}
/** /**
* Used in combination with |IsRoot|. Called by V8 when an * Used in combination with |IsRoot|. Called by V8 when an
* object that is backed by a handle is reclaimed by a non-tracing garbage * object that is backed by a handle is reclaimed by a non-tracing garbage
...@@ -87,13 +80,11 @@ class V8_EXPORT EmbedderHeapTracer { ...@@ -87,13 +80,11 @@ class V8_EXPORT EmbedderHeapTracer {
}; };
/** /**
* Interface for iterating through TracedGlobal handles. * Interface for iterating through |TracedReference| handles.
*/ */
class V8_EXPORT TracedGlobalHandleVisitor { class V8_EXPORT TracedGlobalHandleVisitor {
public: public:
virtual ~TracedGlobalHandleVisitor() = default; virtual ~TracedGlobalHandleVisitor() = default;
V8_DEPRECATED("See v8::TracedGlobal class comment.")
virtual void VisitTracedGlobalHandle(const TracedGlobal<Value>& handle) {}
virtual void VisitTracedReference(const TracedReference<Value>& handle) {} virtual void VisitTracedReference(const TracedReference<Value>& handle) {}
}; };
...@@ -118,8 +109,8 @@ class V8_EXPORT EmbedderHeapTracer { ...@@ -118,8 +109,8 @@ class V8_EXPORT EmbedderHeapTracer {
virtual ~EmbedderHeapTracer() = default; virtual ~EmbedderHeapTracer() = default;
/** /**
* Iterates all TracedGlobal handles created for the v8::Isolate the tracer is * Iterates all |TracedReference| handles created for the |v8::Isolate| the
* attached to. * tracer is attached to.
*/ */
void IterateTracedGlobalHandles(TracedGlobalHandleVisitor* visitor); void IterateTracedGlobalHandles(TracedGlobalHandleVisitor* visitor);
...@@ -194,8 +185,6 @@ class V8_EXPORT EmbedderHeapTracer { ...@@ -194,8 +185,6 @@ class V8_EXPORT EmbedderHeapTracer {
*/ */
virtual bool IsRootForNonTracingGC( virtual bool IsRootForNonTracingGC(
const v8::TracedReference<v8::Value>& handle); const v8::TracedReference<v8::Value>& handle);
V8_DEPRECATED("See v8::TracedGlobal class comment.")
virtual bool IsRootForNonTracingGC(const v8::TracedGlobal<v8::Value>& handle);
/** /**
* See documentation on EmbedderRootsHandler. * See documentation on EmbedderRootsHandler.
......
...@@ -46,8 +46,6 @@ class String; ...@@ -46,8 +46,6 @@ class String;
template <class F> template <class F>
class Traced; class Traced;
template <class F> template <class F>
class TracedGlobal;
template <class F>
class TracedReference; class TracedReference;
class TracedReferenceBase; class TracedReferenceBase;
class Utils; class Utils;
...@@ -312,8 +310,6 @@ class Local { ...@@ -312,8 +310,6 @@ class Local {
template <class F> template <class F>
friend class Traced; friend class Traced;
template <class F> template <class F>
friend class TracedGlobal;
template <class F>
friend class BasicTracedReference; friend class BasicTracedReference;
template <class F> template <class F>
friend class TracedReference; friend class TracedReference;
......
...@@ -493,7 +493,7 @@ class V8_EXPORT Object : public Value { ...@@ -493,7 +493,7 @@ class V8_EXPORT Object : public Value {
return object.val_->GetAlignedPointerFromInternalField(index); return object.val_->GetAlignedPointerFromInternalField(index);
} }
/** Same as above, but works for TracedGlobal. */ /** Same as above, but works for TracedReference. */
V8_INLINE static void* GetAlignedPointerFromInternalField( V8_INLINE static void* GetAlignedPointerFromInternalField(
const BasicTracedReference<Object>& object, int index) { const BasicTracedReference<Object>& object, int index) {
return object->GetAlignedPointerFromInternalField(index); return object->GetAlignedPointerFromInternalField(index);
......
This diff is collapsed.
...@@ -807,17 +807,16 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, ...@@ -807,17 +807,16 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
namespace internal { namespace internal {
i::Address* GlobalizeTracedReference( i::Address* GlobalizeTracedReference(i::Isolate* isolate, i::Address* obj,
i::Isolate* isolate, i::Address* obj, internal::Address* slot, internal::Address* slot,
GlobalHandleDestructionMode destruction_mode, GlobalHandleStoreMode store_mode) {
GlobalHandleStoreMode store_mode) {
LOG_API(isolate, TracedGlobal, New); LOG_API(isolate, TracedGlobal, New);
#ifdef DEBUG #ifdef DEBUG
Utils::ApiCheck((slot != nullptr), "v8::GlobalizeTracedReference", Utils::ApiCheck((slot != nullptr), "v8::GlobalizeTracedReference",
"the address slot must be not null"); "the address slot must be not null");
#endif #endif
i::Handle<i::Object> result = isolate->global_handles()->CreateTraced( i::Handle<i::Object> result =
*obj, slot, destruction_mode, store_mode); isolate->global_handles()->CreateTraced(*obj, slot, store_mode);
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
if (i::FLAG_verify_heap) { if (i::FLAG_verify_heap) {
i::Object(*obj).ObjectVerify(isolate); i::Object(*obj).ObjectVerify(isolate);
...@@ -826,24 +825,17 @@ i::Address* GlobalizeTracedReference( ...@@ -826,24 +825,17 @@ i::Address* GlobalizeTracedReference(
return result.location(); return result.location();
} }
void MoveTracedGlobalReference(internal::Address** from, void MoveTracedReference(internal::Address** from, internal::Address** to) {
internal::Address** to) { GlobalHandles::MoveTracedReference(from, to);
GlobalHandles::MoveTracedGlobal(from, to);
} }
void CopyTracedGlobalReference(const internal::Address* const* from, void CopyTracedReference(const internal::Address* const* from,
internal::Address** to) { internal::Address** to) {
GlobalHandles::CopyTracedGlobal(from, to); GlobalHandles::CopyTracedReference(from, to);
} }
void DisposeTracedGlobal(internal::Address* location) { void DisposeTracedReference(internal::Address* location) {
GlobalHandles::DestroyTraced(location); GlobalHandles::DestroyTracedReference(location);
}
void SetFinalizationCallbackTraced(internal::Address* location, void* parameter,
WeakCallbackInfo<void>::Callback callback) {
GlobalHandles::SetFinalizationCallbackForTraced(location, parameter,
callback);
} }
} // namespace internal } // namespace internal
...@@ -10277,11 +10269,6 @@ bool EmbedderHeapTracer::IsRootForNonTracingGC( ...@@ -10277,11 +10269,6 @@ bool EmbedderHeapTracer::IsRootForNonTracingGC(
return true; return true;
} }
bool EmbedderHeapTracer::IsRootForNonTracingGC(
const v8::TracedGlobal<v8::Value>& handle) {
return true;
}
void EmbedderHeapTracer::ResetHandleInNonTracingGC( void EmbedderHeapTracer::ResetHandleInNonTracingGC(
const v8::TracedReference<v8::Value>& handle) { const v8::TracedReference<v8::Value>& handle) {
UNREACHABLE(); UNREACHABLE();
......
This diff is collapsed.
...@@ -90,12 +90,9 @@ class V8_EXPORT_PRIVATE GlobalHandles final { ...@@ -90,12 +90,9 @@ class V8_EXPORT_PRIVATE GlobalHandles final {
// API for traced handles. // API for traced handles.
// //
static void MoveTracedGlobal(Address** from, Address** to); static void MoveTracedReference(Address** from, Address** to);
static void CopyTracedGlobal(const Address* const* from, Address** to); static void CopyTracedReference(const Address* const* from, Address** to);
static void DestroyTraced(Address* location); static void DestroyTracedReference(Address* location);
static void SetFinalizationCallbackForTraced(
Address* location, void* parameter,
WeakCallbackInfo<void>::Callback callback);
static void MarkTraced(Address* location); static void MarkTraced(Address* location);
explicit GlobalHandles(Isolate* isolate); explicit GlobalHandles(Isolate* isolate);
...@@ -109,14 +106,11 @@ class V8_EXPORT_PRIVATE GlobalHandles final { ...@@ -109,14 +106,11 @@ class V8_EXPORT_PRIVATE GlobalHandles final {
inline Handle<T> Create(T value); inline Handle<T> Create(T value);
Handle<Object> CreateTraced(Object value, Address* slot, Handle<Object> CreateTraced(Object value, Address* slot,
GlobalHandleDestructionMode destruction_mode,
GlobalHandleStoreMode store_mode, GlobalHandleStoreMode store_mode,
bool is_on_stack); bool is_on_stack);
Handle<Object> CreateTraced(Object value, Address* slot, Handle<Object> CreateTraced(Object value, Address* slot,
GlobalHandleDestructionMode destruction_mode,
GlobalHandleStoreMode store_mode); GlobalHandleStoreMode store_mode);
Handle<Object> CreateTraced(Address value, Address* slot, Handle<Object> CreateTraced(Address value, Address* slot,
GlobalHandleDestructionMode destruction_mode,
GlobalHandleStoreMode store_mode); GlobalHandleStoreMode store_mode);
void RecordStats(HeapStats* stats); void RecordStats(HeapStats* stats);
......
...@@ -64,10 +64,6 @@ class V8ToCppGCReferencesVisitor final ...@@ -64,10 +64,6 @@ class V8ToCppGCReferencesVisitor final
isolate_(isolate), isolate_(isolate),
wrapper_descriptor_(wrapper_descriptor) {} wrapper_descriptor_(wrapper_descriptor) {}
void VisitTracedGlobalHandle(const v8::TracedGlobal<v8::Value>&) final {
UNREACHABLE();
}
void VisitTracedReference(const v8::TracedReference<v8::Value>& value) final { void VisitTracedReference(const v8::TracedReference<v8::Value>& value) final {
VisitHandle(value, value.WrapperClassId()); VisitHandle(value, value.WrapperClassId());
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "include/v8-cppgc.h" #include "include/v8-cppgc.h"
#include "src/base/logging.h" #include "src/base/logging.h"
#include "src/common/allow-deprecated.h"
#include "src/handles/global-handles.h" #include "src/handles/global-handles.h"
#include "src/heap/embedder-tracing-inl.h" #include "src/heap/embedder-tracing-inl.h"
#include "src/heap/gc-tracer.h" #include "src/heap/gc-tracer.h"
...@@ -211,13 +210,6 @@ bool DefaultEmbedderRootsHandler::IsRoot( ...@@ -211,13 +210,6 @@ bool DefaultEmbedderRootsHandler::IsRoot(
return !tracer_ || tracer_->IsRootForNonTracingGC(handle); return !tracer_ || tracer_->IsRootForNonTracingGC(handle);
} }
START_ALLOW_USE_DEPRECATED()
bool DefaultEmbedderRootsHandler::IsRoot(
const v8::TracedGlobal<v8::Value>& handle) {
return !tracer_ || tracer_->IsRootForNonTracingGC(handle);
}
END_ALLOW_USE_DEPRECATED()
void DefaultEmbedderRootsHandler::ResetRoot( void DefaultEmbedderRootsHandler::ResetRoot(
const v8::TracedReference<v8::Value>& handle) { const v8::TracedReference<v8::Value>& handle) {
// Resetting is only called when IsRoot() returns false which // Resetting is only called when IsRoot() returns false which
......
...@@ -27,10 +27,6 @@ class V8_EXPORT_PRIVATE DefaultEmbedderRootsHandler final ...@@ -27,10 +27,6 @@ class V8_EXPORT_PRIVATE DefaultEmbedderRootsHandler final
public: public:
bool IsRoot(const v8::TracedReference<v8::Value>& handle) final; bool IsRoot(const v8::TracedReference<v8::Value>& handle) final;
START_ALLOW_USE_DEPRECATED()
bool IsRoot(const v8::TracedGlobal<v8::Value>& handle) final;
END_ALLOW_USE_DEPRECATED()
void ResetRoot(const v8::TracedReference<v8::Value>& handle) final; void ResetRoot(const v8::TracedReference<v8::Value>& handle) final;
void SetTracer(EmbedderHeapTracer* tracer) { tracer_ = tracer; } void SetTracer(EmbedderHeapTracer* tracer) { tracer_ = tracer; }
......
...@@ -1032,22 +1032,15 @@ ...@@ -1032,22 +1032,15 @@
'test-debug/TerminateOnResumeFromOtherThread': [SKIP], 'test-debug/TerminateOnResumeFromOtherThread': [SKIP],
'test-debug/TerminateOnResumeRunJavaScriptAtBreakpoint': [SKIP], 'test-debug/TerminateOnResumeRunJavaScriptAtBreakpoint': [SKIP],
'test-debug/TerminateOnResumeRunMicrotaskAtBreakpoint': [SKIP], 'test-debug/TerminateOnResumeRunMicrotaskAtBreakpoint': [SKIP],
'test-embedder-tracing/BasicTracedReference': [SKIP],
'test-embedder-tracing/GarbageCollectionForTesting': [SKIP], 'test-embedder-tracing/GarbageCollectionForTesting': [SKIP],
'test-embedder-tracing/NotifyEmptyStack': [SKIP], 'test-embedder-tracing/NotifyEmptyStack': [SKIP],
'test-embedder-tracing/TracedGlobalCopy': [SKIP], 'test-embedder-tracing/TracedReferenceCopyReferences': [SKIP],
'test-embedder-tracing/TracedGlobalCopyNoDestructor': [SKIP],
'test-embedder-tracing/TracedGlobalCopyWithDestructor': [SKIP],
'test-embedder-tracing/TracedGlobalDestructor': [SKIP],
'test-embedder-tracing/TracedGlobalInStdUnorderedMap': [SKIP],
'test-embedder-tracing/TracedGlobalInStdVector': [SKIP],
'test-embedder-tracing/TracedGlobalMove': [SKIP],
'test-embedder-tracing/TracedGlobalNoDestructor': [SKIP],
'test-embedder-tracing/TracedGlobalSetFinalizationCallbackMarkSweep': [SKIP],
'test-embedder-tracing/TracedGlobalToUnmodifiedJSObjectDiesOnMarkSweep': [SKIP],
'test-embedder-tracing/TracedReferenceCopy': [SKIP], 'test-embedder-tracing/TracedReferenceCopy': [SKIP],
'test-embedder-tracing/TracedReferenceHandlesDoNotLeak': [SKIP], 'test-embedder-tracing/TracedReferenceHandlesDoNotLeak': [SKIP],
'test-embedder-tracing/TracedReferenceHandlesMarking': [SKIP], 'test-embedder-tracing/TracedReferenceHandlesMarking': [SKIP],
'test-embedder-tracing/TracedReferenceMove': [SKIP], 'test-embedder-tracing/TracedReferenceMove': [SKIP],
'test-embedder-tracing/TracedReferenceToUnmodifiedJSObjectDiesOnMarkSweep': [SKIP],
'test-embedder-tracing/TracingInEphemerons': [SKIP], 'test-embedder-tracing/TracingInEphemerons': [SKIP],
'test-embedder-tracing/TracingInRevivedSubgraph': [SKIP], 'test-embedder-tracing/TracingInRevivedSubgraph': [SKIP],
'test-embedder-tracing/V8RegisteringEmbedderReference': [SKIP], 'test-embedder-tracing/V8RegisteringEmbedderReference': [SKIP],
......
This diff is collapsed.
...@@ -44,6 +44,10 @@ namespace internal { ...@@ -44,6 +44,10 @@ namespace internal {
namespace { namespace {
struct TracedReferenceWrapper {
v8::TracedReference<v8::Object> handle;
};
// Empty v8::EmbedderHeapTracer that never keeps objects alive on Scavenge. See // Empty v8::EmbedderHeapTracer that never keeps objects alive on Scavenge. See
// |IsRootForNonTracingGC|. // |IsRootForNonTracingGC|.
class NonRootingEmbedderHeapTracer final : public v8::EmbedderHeapTracer { class NonRootingEmbedderHeapTracer final : public v8::EmbedderHeapTracer {
...@@ -58,9 +62,26 @@ class NonRootingEmbedderHeapTracer final : public v8::EmbedderHeapTracer { ...@@ -58,9 +62,26 @@ class NonRootingEmbedderHeapTracer final : public v8::EmbedderHeapTracer {
void TraceEpilogue(TraceSummary*) final {} void TraceEpilogue(TraceSummary*) final {}
void EnterFinalPause(EmbedderStackState) final {} void EnterFinalPause(EmbedderStackState) final {}
bool IsRootForNonTracingGC(const v8::TracedGlobal<v8::Value>& handle) final { bool IsRootForNonTracingGC(
const v8::TracedReference<v8::Value>& handle) final {
return false; return false;
} }
void ResetHandleInNonTracingGC(
const v8::TracedReference<v8::Value>& handle) final {
for (auto* wrapper : wrappers_) {
if (wrapper->handle == handle) {
wrapper->handle.Reset();
}
}
}
void Register(TracedReferenceWrapper* wrapper) {
wrappers_.push_back(wrapper);
}
private:
std::vector<TracedReferenceWrapper*> wrappers_;
}; };
void InvokeScavenge() { CcTest::CollectGarbage(i::NEW_SPACE); } void InvokeScavenge() { CcTest::CollectGarbage(i::NEW_SPACE); }
...@@ -76,10 +97,6 @@ struct FlagAndGlobal { ...@@ -76,10 +97,6 @@ struct FlagAndGlobal {
v8::Global<v8::Object> handle; v8::Global<v8::Object> handle;
}; };
struct TracedGlobalWrapper {
v8::TracedGlobal<v8::Object> handle;
};
void ResetHandleAndSetFlag(const v8::WeakCallbackInfo<FlagAndGlobal>& data) { void ResetHandleAndSetFlag(const v8::WeakCallbackInfo<FlagAndGlobal>& data) {
data.GetParameter()->handle.Reset(); data.GetParameter()->handle.Reset();
data.GetParameter()->flag = true; data.GetParameter()->flag = true;
...@@ -104,12 +121,12 @@ void ConstructJSObject(v8::Isolate* isolate, v8::Global<v8::Object>* global) { ...@@ -104,12 +121,12 @@ void ConstructJSObject(v8::Isolate* isolate, v8::Global<v8::Object>* global) {
} }
void ConstructJSObject(v8::Isolate* isolate, void ConstructJSObject(v8::Isolate* isolate,
v8::TracedGlobal<v8::Object>* traced) { v8::TracedReference<v8::Object>* handle) {
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
v8::Local<v8::Object> object(v8::Object::New(isolate)); v8::Local<v8::Object> object(v8::Object::New(isolate));
CHECK(!object.IsEmpty()); CHECK(!object.IsEmpty());
*traced = v8::TracedGlobal<v8::Object>(isolate, object); *handle = v8::TracedReference<v8::Object>(isolate, object);
CHECK(!traced->IsEmpty()); CHECK(!handle->IsEmpty());
} }
template <typename HandleContainer> template <typename HandleContainer>
...@@ -150,12 +167,11 @@ void WeakHandleTest(v8::Isolate* isolate, ConstructFunction construct_function, ...@@ -150,12 +167,11 @@ void WeakHandleTest(v8::Isolate* isolate, ConstructFunction construct_function,
CHECK_IMPLIES(survives == SurvivalMode::kDies, fp.flag); CHECK_IMPLIES(survives == SurvivalMode::kDies, fp.flag);
} }
template <typename ConstructFunction, typename ModifierFunction, template <typename ConstructFunction, typename ModifierFunction>
typename GCFunction> void TracedReferenceTestWithScavenge(v8::Isolate* isolate,
void TracedGlobalTest(v8::Isolate* isolate, ConstructFunction construct_function,
ConstructFunction construct_function, ModifierFunction modifier_function,
ModifierFunction modifier_function, SurvivalMode survives) {
GCFunction gc_function, SurvivalMode survives) {
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate); v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context); v8::Context::Scope context_scope(context);
...@@ -163,11 +179,14 @@ void TracedGlobalTest(v8::Isolate* isolate, ...@@ -163,11 +179,14 @@ void TracedGlobalTest(v8::Isolate* isolate,
NonRootingEmbedderHeapTracer tracer; NonRootingEmbedderHeapTracer tracer;
heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer);
auto fp = std::make_unique<TracedGlobalWrapper>(); auto fp = std::make_unique<TracedReferenceWrapper>();
tracer.Register(fp.get());
construct_function(isolate, context, fp.get()); construct_function(isolate, context, fp.get());
CHECK(heap::InCorrectGeneration(isolate, fp->handle)); CHECK(heap::InCorrectGeneration(isolate, fp->handle));
modifier_function(fp.get()); modifier_function(fp.get());
gc_function(); InvokeScavenge();
// Scavenge clear properly resets the original handle, so we can check the
// handle directly here.
CHECK_IMPLIES(survives == SurvivalMode::kSurvives, !fp->handle.IsEmpty()); CHECK_IMPLIES(survives == SurvivalMode::kSurvives, !fp->handle.IsEmpty());
CHECK_IMPLIES(survives == SurvivalMode::kDies, fp->handle.IsEmpty()); CHECK_IMPLIES(survives == SurvivalMode::kDies, fp->handle.IsEmpty());
} }
...@@ -343,14 +362,13 @@ TEST(WeakHandleToUnmodifiedJSObjectDiesOnScavenge) { ...@@ -343,14 +362,13 @@ TEST(WeakHandleToUnmodifiedJSObjectDiesOnScavenge) {
SurvivalMode::kDies); SurvivalMode::kDies);
} }
TEST(TracedGlobalToUnmodifiedJSObjectSurvivesScavenge) { TEST(TracedReferenceToUnmodifiedJSObjectSurvivesScavenge) {
if (FLAG_single_generation) return; if (FLAG_single_generation) return;
ManualGCScope manual_gc; ManualGCScope manual_gc;
CcTest::InitializeVM(); CcTest::InitializeVM();
TracedGlobalTest( TracedReferenceTestWithScavenge(
CcTest::isolate(), &ConstructJSObject<TracedGlobalWrapper>, CcTest::isolate(), &ConstructJSObject<TracedReferenceWrapper>,
[](TracedGlobalWrapper* fp) {}, []() { InvokeScavenge(); }, [](TracedReferenceWrapper* fp) {}, SurvivalMode::kSurvives);
SurvivalMode::kSurvives);
} }
TEST(WeakHandleToUnmodifiedJSObjectDiesOnMarkCompact) { TEST(WeakHandleToUnmodifiedJSObjectDiesOnMarkCompact) {
...@@ -382,17 +400,16 @@ TEST(WeakHandleToUnmodifiedJSApiObjectDiesOnScavenge) { ...@@ -382,17 +400,16 @@ TEST(WeakHandleToUnmodifiedJSApiObjectDiesOnScavenge) {
SurvivalMode::kDies); SurvivalMode::kDies);
} }
TEST(TracedGlobalToUnmodifiedJSApiObjectDiesOnScavenge) { TEST(TracedReferenceToUnmodifiedJSApiObjectDiesOnScavenge) {
if (FLAG_single_generation) return; if (FLAG_single_generation) return;
ManualGCScope manual_gc; ManualGCScope manual_gc;
CcTest::InitializeVM(); CcTest::InitializeVM();
TracedGlobalTest( TracedReferenceTestWithScavenge(
CcTest::isolate(), &ConstructJSApiObject<TracedGlobalWrapper>, CcTest::isolate(), &ConstructJSApiObject<TracedReferenceWrapper>,
[](TracedGlobalWrapper* fp) {}, []() { InvokeScavenge(); }, [](TracedReferenceWrapper* fp) {}, SurvivalMode::kDies);
SurvivalMode::kDies);
} }
TEST(TracedGlobalToJSApiObjectWithIdentityHashSurvivesScavenge) { TEST(TracedReferenceToJSApiObjectWithIdentityHashSurvivesScavenge) {
if (FLAG_single_generation) return; if (FLAG_single_generation) return;
ManualGCScope manual_gc; ManualGCScope manual_gc;
...@@ -401,9 +418,9 @@ TEST(TracedGlobalToJSApiObjectWithIdentityHashSurvivesScavenge) { ...@@ -401,9 +418,9 @@ TEST(TracedGlobalToJSApiObjectWithIdentityHashSurvivesScavenge) {
HandleScope scope(i_isolate); HandleScope scope(i_isolate);
Handle<JSWeakMap> weakmap = i_isolate->factory()->NewJSWeakMap(); Handle<JSWeakMap> weakmap = i_isolate->factory()->NewJSWeakMap();
TracedGlobalTest( TracedReferenceTestWithScavenge(
CcTest::isolate(), &ConstructJSApiObject<TracedGlobalWrapper>, CcTest::isolate(), &ConstructJSApiObject<TracedReferenceWrapper>,
[&weakmap, i_isolate](TracedGlobalWrapper* fp) { [&weakmap, i_isolate](TracedReferenceWrapper* fp) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Handle<JSReceiver> key = Handle<JSReceiver> key =
Utils::OpenHandle(*fp->handle.Get(CcTest::isolate())); Utils::OpenHandle(*fp->handle.Get(CcTest::isolate()));
...@@ -411,7 +428,7 @@ TEST(TracedGlobalToJSApiObjectWithIdentityHashSurvivesScavenge) { ...@@ -411,7 +428,7 @@ TEST(TracedGlobalToJSApiObjectWithIdentityHashSurvivesScavenge) {
int32_t hash = key->GetOrCreateHash(i_isolate).value(); int32_t hash = key->GetOrCreateHash(i_isolate).value();
JSWeakCollection::Set(weakmap, key, smi, hash); JSWeakCollection::Set(weakmap, key, smi, hash);
}, },
[]() { InvokeScavenge(); }, SurvivalMode::kSurvives); SurvivalMode::kSurvives);
} }
TEST(WeakHandleToUnmodifiedJSApiObjectSurvivesScavengeWhenInHandle) { TEST(WeakHandleToUnmodifiedJSApiObjectSurvivesScavengeWhenInHandle) {
...@@ -447,13 +464,13 @@ TEST(WeakHandleToUnmodifiedJSApiObjectSurvivesMarkCompactWhenInHandle) { ...@@ -447,13 +464,13 @@ TEST(WeakHandleToUnmodifiedJSApiObjectSurvivesMarkCompactWhenInHandle) {
[]() { InvokeMarkSweep(); }, SurvivalMode::kSurvives); []() { InvokeMarkSweep(); }, SurvivalMode::kSurvives);
} }
TEST(TracedGlobalToJSApiObjectWithModifiedMapSurvivesScavenge) { TEST(TracedReferenceToJSApiObjectWithModifiedMapSurvivesScavenge) {
if (FLAG_single_generation) return; if (FLAG_single_generation) return;
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
LocalContext context; LocalContext context;
TracedGlobal<v8::Object> handle; TracedReference<v8::Object> handle;
{ {
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
// Create an API object which does not have the same map as constructor. // Create an API object which does not have the same map as constructor.
...@@ -469,13 +486,13 @@ TEST(TracedGlobalToJSApiObjectWithModifiedMapSurvivesScavenge) { ...@@ -469,13 +486,13 @@ TEST(TracedGlobalToJSApiObjectWithModifiedMapSurvivesScavenge) {
CHECK(!handle.IsEmpty()); CHECK(!handle.IsEmpty());
} }
TEST(TracedGlobalTOJsApiObjectWithElementsSurvivesScavenge) { TEST(TracedReferenceTOJsApiObjectWithElementsSurvivesScavenge) {
if (FLAG_single_generation) return; if (FLAG_single_generation) return;
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
LocalContext context; LocalContext context;
TracedGlobal<v8::Object> handle; TracedReference<v8::Object> handle;
{ {
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
...@@ -717,13 +734,14 @@ TEST(TotalSizeTracedNode) { ...@@ -717,13 +734,14 @@ TEST(TotalSizeTracedNode) {
Isolate* i_isolate = CcTest::i_isolate(); Isolate* i_isolate = CcTest::i_isolate();
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
v8::TracedGlobal<v8::Object>* global = new TracedGlobal<v8::Object>(); v8::TracedReference<v8::Object>* handle = new TracedReference<v8::Object>();
CHECK_EQ(i_isolate->global_handles()->TotalSize(), 0); CHECK_EQ(i_isolate->global_handles()->TotalSize(), 0);
CHECK_EQ(i_isolate->global_handles()->UsedSize(), 0); CHECK_EQ(i_isolate->global_handles()->UsedSize(), 0);
ConstructJSObject(isolate, global); ConstructJSObject(isolate, handle);
CHECK_GT(i_isolate->global_handles()->TotalSize(), 0); CHECK_GT(i_isolate->global_handles()->TotalSize(), 0);
CHECK_GT(i_isolate->global_handles()->UsedSize(), 0); CHECK_GT(i_isolate->global_handles()->UsedSize(), 0);
delete global; delete handle;
InvokeMarkSweep();
CHECK_GT(i_isolate->global_handles()->TotalSize(), 0); CHECK_GT(i_isolate->global_handles()->TotalSize(), 0);
CHECK_EQ(i_isolate->global_handles()->UsedSize(), 0); CHECK_EQ(i_isolate->global_handles()->UsedSize(), 0);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment