[api] Remove deprecated global handle APIs
Bug: v8:12819 Change-Id: I9150a8a8ffa38b0628eee0f399d403af6363c04d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3695587 Reviewed-by: Dominik Inführ <dinfuehr@chromium.org> Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/main@{#81042}
This commit is contained in:
parent
cfea0eb0e8
commit
4cf204da0a
@ -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.
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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<i::Isolate*>(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<i::Isolate*>(this);
|
||||
i::DisallowGarbageCollection no_gc;
|
||||
i_isolate->global_handles()->IterateAllRootsWithClassIds(visitor);
|
||||
}
|
||||
|
||||
void Isolate::VisitWeakHandles(PersistentHandleVisitor* visitor) {
|
||||
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this);
|
||||
i::DisallowGarbageCollection no_gc;
|
||||
i_isolate->global_handles()->IterateYoungWeakRootsWithClassIds(visitor);
|
||||
}
|
||||
|
||||
void Isolate::SetAllowAtomicsWait(bool allow) {
|
||||
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this);
|
||||
i_isolate->set_allow_atomics_wait(allow);
|
||||
|
@ -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<v8::Value>(node->handle());
|
||||
handler->ResetRoot(
|
||||
*reinterpret_cast<v8::TracedReference<v8::Value>*>(&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;
|
||||
|
@ -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<TracedNode*> traced_young_nodes_;
|
||||
std::unique_ptr<OnStackTracedNodeSpace> on_stack_nodes_;
|
||||
|
||||
size_t number_of_phantom_handle_resets_ = 0;
|
||||
|
||||
std::vector<std::pair<Node*, PendingPhantomCallback>>
|
||||
regular_pending_phantom_callbacks_;
|
||||
std::vector<std::pair<TracedNode*, PendingPhantomCallback>>
|
||||
|
@ -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<v8::Object>* object)
|
||||
: counter_(0), object_(object) { }
|
||||
|
||||
void VisitPersistentHandle(Persistent<Value>* 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<v8::Value> handle = v8::Local<v8::Value>::New(isolate, *value);
|
||||
v8::Local<v8::Value> object = v8::Local<v8::Object>::New(isolate, *object_);
|
||||
CHECK(handle->IsObject());
|
||||
CHECK(Local<Object>::Cast(handle)
|
||||
->Equals(isolate->GetCurrentContext(), object)
|
||||
.FromJust());
|
||||
++counter_;
|
||||
}
|
||||
|
||||
int counter_;
|
||||
v8::Persistent<v8::Object>* object_;
|
||||
};
|
||||
|
||||
START_ALLOW_USE_DEPRECATED()
|
||||
|
||||
TEST(PersistentHandleVisitor) {
|
||||
LocalContext context;
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
v8::Persistent<v8::Object> 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();
|
||||
|
@ -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()
|
||||
|
@ -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<i::Isolate*>(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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user