Skip to content

Commit 6083078

Browse files
committed
PATCH: Re-add Isolate::VisitHandlesWithClassIds since cocos needs it.
It was removed at v8/v8@4cf204d
1 parent 8e17c98 commit 6083078

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

include/v8-isolate.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,12 @@ class V8_EXPORT Isolate {
16151615
V8_DEPRECATE_SOON("Will be removed without replacement. crbug.com/v8/14172")
16161616
void VisitExternalResources(ExternalResourceVisitor* visitor);
16171617

1618+
/**
1619+
* Iterates through all the persistent handles in the current isolate's heap
1620+
* that have class_ids.
1621+
*/
1622+
void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
1623+
16181624
/**
16191625
* Check if this isolate is in use.
16201626
* True if at least one thread Enter'ed this isolate.

src/api/api.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10163,6 +10163,12 @@ bool Isolate::IsInUse() {
1016310163
return i_isolate->IsInUse();
1016410164
}
1016510165

10166+
void Isolate::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) {
10167+
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this);
10168+
i::DisallowGarbageCollection no_gc;
10169+
i_isolate->global_handles()->IterateAllRootsWithClassIds(visitor);
10170+
}
10171+
1016610172
void Isolate::SetAllowAtomicsWait(bool allow) {
1016710173
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this);
1016810174
i_isolate->set_allow_atomics_wait(allow);

src/handles/global-handles.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,10 +944,10 @@ void GlobalHandles::ApplyPersistentHandleVisitor(
944944
node->wrapper_class_id());
945945
}
946946

947-
void GlobalHandles::IterateAllRootsForTesting(
947+
void GlobalHandles::IterateAllRootsWithClassIds(
948948
v8::PersistentHandleVisitor* visitor) {
949949
for (Node* node : *regular_nodes_) {
950-
if (node->IsWeakOrStrongRetainer()) {
950+
if (node->IsWeakOrStrongRetainer() && node->has_wrapper_class_id()) {
951951
ApplyPersistentHandleVisitor(visitor, node);
952952
}
953953
}

src/handles/global-handles.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class V8_EXPORT_PRIVATE GlobalHandles final {
125125
size_t handles_count() const;
126126
size_t last_gc_custom_callbacks() const { return last_gc_custom_callbacks_; }
127127

128-
void IterateAllRootsForTesting(v8::PersistentHandleVisitor* v);
128+
void IterateAllRootsWithClassIds(v8::PersistentHandleVisitor* v);
129129

130130
#ifdef DEBUG
131131
void PrintStats();

test/cctest/test-heap-profiler.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ class EmbedderGraphBuilder : public v8::PersistentHandleVisitor {
16151615
EmbedderGraphBuilder builder(isolate, graph);
16161616
reinterpret_cast<i::Isolate*>(isolate)
16171617
->global_handles()
1618-
->IterateAllRootsForTesting(&builder);
1618+
->IterateAllRootsWithClassIds(&builder);
16191619
}
16201620

16211621
void VisitPersistentHandle(v8::Persistent<v8::Value>* value,

0 commit comments

Comments
 (0)