Skip to content

Commit

Permalink
PATCH: Re-add Isolate::VisitHandlesWithClassIds since cocos needs it.
Browse files Browse the repository at this point in the history
It was removed at v8/v8@4cf204d
  • Loading branch information
dumganhar committed Sep 30, 2023
1 parent 6a778e0 commit bfd2dae
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions include/v8-isolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,12 @@ class V8_EXPORT Isolate {
*/
void VisitExternalResources(ExternalResourceVisitor* visitor);

/**
* Iterates through all the persistent handles in the current isolate's heap
* that have class_ids.
*/
void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);

/**
* Check if this isolate is in use.
* True if at least one thread Enter'ed this isolate.
Expand Down
6 changes: 6 additions & 0 deletions src/api/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10306,6 +10306,12 @@ 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::SetAllowAtomicsWait(bool allow) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this);
i_isolate->set_allow_atomics_wait(allow);
Expand Down
4 changes: 2 additions & 2 deletions src/handles/global-handles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -944,10 +944,10 @@ void GlobalHandles::ApplyPersistentHandleVisitor(
node->wrapper_class_id());
}

void GlobalHandles::IterateAllRootsForTesting(
void GlobalHandles::IterateAllRootsWithClassIds(
v8::PersistentHandleVisitor* visitor) {
for (Node* node : *regular_nodes_) {
if (node->IsWeakOrStrongRetainer()) {
if (node->IsWeakOrStrongRetainer() && node->has_wrapper_class_id()) {
ApplyPersistentHandleVisitor(visitor, node);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/handles/global-handles.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class V8_EXPORT_PRIVATE GlobalHandles final {
size_t handles_count() const;
size_t last_gc_custom_callbacks() const { return last_gc_custom_callbacks_; }

void IterateAllRootsForTesting(v8::PersistentHandleVisitor* v);
void IterateAllRootsWithClassIds(v8::PersistentHandleVisitor* v);

#ifdef DEBUG
void PrintStats();
Expand Down
2 changes: 1 addition & 1 deletion test/cctest/test-heap-profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ class EmbedderGraphBuilder : public v8::PersistentHandleVisitor {
EmbedderGraphBuilder builder(isolate, graph);
reinterpret_cast<i::Isolate*>(isolate)
->global_handles()
->IterateAllRootsForTesting(&builder);
->IterateAllRootsWithClassIds(&builder);
}

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

0 comments on commit bfd2dae

Please sign in to comment.