diff --git a/include/v8-isolate.h b/include/v8-isolate.h index ce4f09351f..30589244a7 100644 --- a/include/v8-isolate.h +++ b/include/v8-isolate.h @@ -841,15 +841,6 @@ class V8_EXPORT Isolate { */ int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes); - /** - * Returns the number of phantom handles without callbacks that were reset - * by the garbage collector since the last call to this function. - */ - V8_DEPRECATED( - "Information cannot be relied on anymore as internal representation may " - "change.") - size_t NumberOfPhantomHandleResetsSinceLastCall(); - /** * Returns heap profiler for this isolate. Will return NULL until the isolate * is initialized. @@ -1608,25 +1599,6 @@ class V8_EXPORT Isolate { */ void VisitExternalResources(ExternalResourceVisitor* visitor); - /** - * Iterates through all the persistent handles in the current isolate's heap - * that have class_ids. - */ - V8_DEPRECATED( - "Information cannot be relied on anymore as internal representation may " - "change.") - void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor); - - /** - * Iterates through all the persistent handles in the current isolate's heap - * that have class_ids and are weak to be marked as inactive if there is no - * pending activity for the handle. - */ - V8_DEPRECATED( - "Information cannot be relied on anymore as internal representation may " - "change.") - void VisitWeakHandles(PersistentHandleVisitor* visitor); - /** * Check if this isolate is in use. * True if at least one thread Enter'ed this isolate. diff --git a/include/v8-persistent-handle.h b/include/v8-persistent-handle.h index 7e39be324b..4fe79862e4 100644 --- a/include/v8-persistent-handle.h +++ b/include/v8-persistent-handle.h @@ -169,8 +169,6 @@ class PersistentBase { * Turns this handle into a weak phantom handle without finalization callback. * The handle will be reset automatically when the garbage collector detects * that the object is no longer reachable. - * A related function Isolate::NumberOfPhantomHandleResetsSinceLastCall - * returns how many phantom handles were reset by the garbage collector. */ V8_INLINE void SetWeak(); diff --git a/src/api/api.cc b/src/api/api.cc index e5433eb749..775f0b7a04 100644 --- a/src/api/api.cc +++ b/src/api/api.cc @@ -9035,11 +9035,6 @@ void Isolate::GetStackSample(const RegisterState& state, void** frames, sample_info->external_callback_entry = nullptr; } -size_t Isolate::NumberOfPhantomHandleResetsSinceLastCall() { - i::Isolate* i_isolate = reinterpret_cast(this); - return i_isolate->global_handles()->GetAndResetGlobalHandleResetCount(); -} - int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( int64_t change_in_bytes) { // Try to check for unreasonably large or small values from the embedder. @@ -9490,18 +9485,6 @@ bool Isolate::IsInUse() { return i_isolate->IsInUse(); } -void Isolate::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) { - i::Isolate* i_isolate = reinterpret_cast(this); - i::DisallowGarbageCollection no_gc; - i_isolate->global_handles()->IterateAllRootsWithClassIds(visitor); -} - -void Isolate::VisitWeakHandles(PersistentHandleVisitor* visitor) { - i::Isolate* i_isolate = reinterpret_cast(this); - i::DisallowGarbageCollection no_gc; - i_isolate->global_handles()->IterateYoungWeakRootsWithClassIds(visitor); -} - void Isolate::SetAllowAtomicsWait(bool allow) { i::Isolate* i_isolate = reinterpret_cast(this); i_isolate->set_allow_atomics_wait(allow); diff --git a/src/handles/global-handles.cc b/src/handles/global-handles.cc index cdb62a49a2..41c85b10e3 100644 --- a/src/handles/global-handles.cc +++ b/src/handles/global-handles.cc @@ -1162,7 +1162,6 @@ V8_INLINE bool GlobalHandles::ResetWeakNodeIfDead( switch (node->weakness_type()) { case WeaknessType::kNoCallback: node->ResetPhantomHandle(); - ++number_of_phantom_handle_resets_; break; case WeaknessType::kCallback: V8_FALLTHROUGH; @@ -1186,7 +1185,6 @@ void GlobalHandles::IterateWeakRootsForPhantomHandles( // The handle itself is unreachable. We can clear it even if the target V8 // object is alive. node->ResetPhantomHandle(); - ++number_of_phantom_handle_resets_; continue; } // Clear the markbit for the next GC. @@ -1195,7 +1193,6 @@ void GlobalHandles::IterateWeakRootsForPhantomHandles( // Detect nodes with unreachable target objects. if (should_reset_handle(isolate()->heap(), node->location())) { node->ResetPhantomHandle(); - ++number_of_phantom_handle_resets_; } } } @@ -1260,7 +1257,6 @@ void GlobalHandles::ProcessWeakYoungObjects( v8::Value* value = ToApi(node->handle()); handler->ResetRoot( *reinterpret_cast*>(&value)); - ++number_of_phantom_handle_resets_; // We cannot check whether a node is in use here as the reset behavior // depends on whether incremental marking is running when reclaiming // young objects. @@ -1494,11 +1490,10 @@ void GlobalHandles::ApplyPersistentHandleVisitor( node->wrapper_class_id()); } -DISABLE_CFI_PERF -void GlobalHandles::IterateAllRootsWithClassIds( +void GlobalHandles::IterateAllRootsForTesting( v8::PersistentHandleVisitor* visitor) { for (Node* node : *regular_nodes_) { - if (node->IsWeakOrStrongRetainer() && node->has_wrapper_class_id()) { + if (node->IsWeakOrStrongRetainer()) { ApplyPersistentHandleVisitor(visitor, node); } } @@ -1516,26 +1511,6 @@ void GlobalHandles::IterateTracedNodes( } } -DISABLE_CFI_PERF -void GlobalHandles::IterateAllYoungRootsWithClassIds( - v8::PersistentHandleVisitor* visitor) { - for (Node* node : young_nodes_) { - if (node->IsWeakOrStrongRetainer() && node->has_wrapper_class_id()) { - ApplyPersistentHandleVisitor(visitor, node); - } - } -} - -DISABLE_CFI_PERF -void GlobalHandles::IterateYoungWeakRootsWithClassIds( - v8::PersistentHandleVisitor* visitor) { - for (Node* node : young_nodes_) { - if (node->has_wrapper_class_id() && node->IsWeak()) { - ApplyPersistentHandleVisitor(visitor, node); - } - } -} - void GlobalHandles::RecordStats(HeapStats* stats) { *stats->global_handle_count = 0; *stats->weak_global_handle_count = 0; diff --git a/src/handles/global-handles.h b/src/handles/global-handles.h index 23beabb2a9..66310ae50f 100644 --- a/src/handles/global-handles.h +++ b/src/handles/global-handles.h @@ -115,17 +115,6 @@ class V8_EXPORT_PRIVATE GlobalHandles final { void IterateAllRoots(RootVisitor* v); void IterateAllYoungRoots(RootVisitor* v); - // Iterates over all handles that have embedder-assigned class ID. - void IterateAllRootsWithClassIds(v8::PersistentHandleVisitor* v); - - // Iterates over all handles in the new space that have embedder-assigned - // class ID. - void IterateAllYoungRootsWithClassIds(v8::PersistentHandleVisitor* v); - - // Iterate over all handles in the new space that are weak, unmodified - // and have class IDs - void IterateYoungWeakRootsWithClassIds(v8::PersistentHandleVisitor* v); - // Iterates over all traces handles represented by TracedGlobal. void IterateTracedNodes( v8::EmbedderHeapTracer::TracedGlobalHandleVisitor* visitor); @@ -170,17 +159,13 @@ class V8_EXPORT_PRIVATE GlobalHandles final { // Number of global handles. size_t handles_count() const; - size_t GetAndResetGlobalHandleResetCount() { - size_t old = number_of_phantom_handle_resets_; - number_of_phantom_handle_resets_ = 0; - return old; - } - void SetStackStart(void* stack_start); void NotifyEmptyEmbedderStack(); void CleanupOnStackReferencesBelowCurrentStackPosition(); size_t NumberOfOnStackHandlesForTesting(); + void IterateAllRootsForTesting(v8::PersistentHandleVisitor* v); + #ifdef DEBUG void PrintStats(); void Print(); @@ -225,8 +210,6 @@ class V8_EXPORT_PRIVATE GlobalHandles final { std::vector traced_young_nodes_; std::unique_ptr on_stack_nodes_; - size_t number_of_phantom_handle_resets_ = 0; - std::vector> regular_pending_phantom_callbacks_; std::vector> diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index c1e82ae02d..6f14b27004 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -55,7 +55,6 @@ #include "src/base/platform/platform.h" #include "src/base/strings.h" #include "src/codegen/compilation-cache.h" -#include "src/common/allow-deprecated.h" #include "src/compiler/globals.h" #include "src/debug/debug.h" #include "src/execution/arguments.h" @@ -18782,51 +18781,6 @@ TEST(DontDeleteCellLoadIC) { } } - -class Visitor42 : public v8::PersistentHandleVisitor { - public: - explicit Visitor42(v8::Persistent* object) - : counter_(0), object_(object) { } - - void VisitPersistentHandle(Persistent* value, - uint16_t class_id) override { - if (class_id != 42) return; - CHECK_EQ(42, value->WrapperClassId()); - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope handle_scope(isolate); - v8::Local handle = v8::Local::New(isolate, *value); - v8::Local object = v8::Local::New(isolate, *object_); - CHECK(handle->IsObject()); - CHECK(Local::Cast(handle) - ->Equals(isolate->GetCurrentContext(), object) - .FromJust()); - ++counter_; - } - - int counter_; - v8::Persistent* object_; -}; - -START_ALLOW_USE_DEPRECATED() - -TEST(PersistentHandleVisitor) { - LocalContext context; - v8::Isolate* isolate = context->GetIsolate(); - v8::HandleScope scope(isolate); - v8::Persistent object(isolate, v8::Object::New(isolate)); - CHECK_EQ(0, object.WrapperClassId()); - object.SetWrapperClassId(42); - CHECK_EQ(42, object.WrapperClassId()); - - Visitor42 visitor(&object); - isolate->VisitHandlesWithClassIds(&visitor); - CHECK_EQ(1, visitor.counter_); - - object.Reset(); -} - -END_ALLOW_USE_DEPRECATED() - TEST(WrapperClassId) { LocalContext context; v8::Isolate* isolate = context->GetIsolate(); diff --git a/test/cctest/test-global-handles.cc b/test/cctest/test-global-handles.cc index 02217031bd..cc774ffc11 100644 --- a/test/cctest/test-global-handles.cc +++ b/test/cctest/test-global-handles.cc @@ -301,11 +301,11 @@ TEST(PhantomHandlesWithoutCallbacks) { g2.Reset(isolate, v8::Object::New(isolate)); g2.SetWeak(); } - - CHECK_EQ(0u, isolate->NumberOfPhantomHandleResetsSinceLastCall()); + CHECK(!g1.IsEmpty()); + CHECK(!g2.IsEmpty()); CcTest::CollectAllAvailableGarbage(); - CHECK_EQ(2u, isolate->NumberOfPhantomHandleResetsSinceLastCall()); - CHECK_EQ(0u, isolate->NumberOfPhantomHandleResetsSinceLastCall()); + CHECK(g1.IsEmpty()); + CHECK(g2.IsEmpty()); } END_ALLOW_USE_DEPRECATED() diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc index a2cd9e7e10..f9d36ce827 100644 --- a/test/cctest/test-heap-profiler.cc +++ b/test/cctest/test-heap-profiler.cc @@ -40,6 +40,7 @@ #include "src/codegen/assembler-inl.h" #include "src/common/allow-deprecated.h" #include "src/debug/debug.h" +#include "src/handles/global-handles.h" #include "src/heap/heap-inl.h" #include "src/init/v8.h" #include "src/objects/objects-inl.h" @@ -1651,7 +1652,9 @@ class EmbedderGraphBuilder : public v8::PersistentHandleVisitor { static void BuildEmbedderGraph(v8::Isolate* isolate, v8::EmbedderGraph* graph, void* data) { EmbedderGraphBuilder builder(isolate, graph); - isolate->VisitHandlesWithClassIds(&builder); + reinterpret_cast(isolate) + ->global_handles() + ->IterateAllRootsForTesting(&builder); } END_ALLOW_USE_DEPRECATED() @@ -1678,8 +1681,6 @@ class EmbedderGraphBuilder : public v8::PersistentHandleVisitor { graph_->AddEdge(node, group); graph_->AddEdge(group, node); } - } else { - UNREACHABLE(); } }