Call PersistentHandleVisitor directly instead of using ObjectVisitor.
This removes one virtual function from ObjectVisitor. BUG=chromium:709075 Review-Url: https://codereview.chromium.org/2798923004 Cr-Commit-Position: refs/heads/master@{#44476}
This commit is contained in:
parent
d43cebe7b5
commit
4a87608d7f
30
src/api.cc
30
src/api.cc
@ -8796,30 +8796,10 @@ bool Isolate::IsInUse() {
|
||||
}
|
||||
|
||||
|
||||
class VisitorAdapter : public i::ObjectVisitor {
|
||||
public:
|
||||
explicit VisitorAdapter(PersistentHandleVisitor* visitor)
|
||||
: visitor_(visitor) {}
|
||||
void VisitPointers(i::Object** start, i::Object** end) override {
|
||||
UNREACHABLE();
|
||||
}
|
||||
DISABLE_CFI_PERF
|
||||
void VisitEmbedderReference(i::Object** p, uint16_t class_id) override {
|
||||
Value* value = ToApi<Value>(i::Handle<i::Object>(p));
|
||||
visitor_->VisitPersistentHandle(
|
||||
reinterpret_cast<Persistent<Value>*>(&value), class_id);
|
||||
}
|
||||
|
||||
private:
|
||||
PersistentHandleVisitor* visitor_;
|
||||
};
|
||||
|
||||
|
||||
void Isolate::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) {
|
||||
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
|
||||
i::DisallowHeapAllocation no_allocation;
|
||||
VisitorAdapter visitor_adapter(visitor);
|
||||
isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter);
|
||||
isolate->global_handles()->IterateAllRootsWithClassIds(visitor);
|
||||
}
|
||||
|
||||
|
||||
@ -8827,18 +8807,14 @@ void Isolate::VisitHandlesForPartialDependence(
|
||||
PersistentHandleVisitor* visitor) {
|
||||
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
|
||||
i::DisallowHeapAllocation no_allocation;
|
||||
VisitorAdapter visitor_adapter(visitor);
|
||||
isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds(
|
||||
&visitor_adapter);
|
||||
isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds(visitor);
|
||||
}
|
||||
|
||||
|
||||
void Isolate::VisitWeakHandles(PersistentHandleVisitor* visitor) {
|
||||
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
|
||||
i::DisallowHeapAllocation no_allocation;
|
||||
VisitorAdapter visitor_adapter(visitor);
|
||||
isolate->global_handles()->IterateWeakRootsInNewSpaceWithClassIds(
|
||||
&visitor_adapter);
|
||||
isolate->global_handles()->IterateWeakRootsInNewSpaceWithClassIds(visitor);
|
||||
}
|
||||
|
||||
|
||||
|
@ -949,34 +949,44 @@ void GlobalHandles::IterateAllRoots(ObjectVisitor* v) {
|
||||
|
||||
|
||||
DISABLE_CFI_PERF
|
||||
void GlobalHandles::IterateAllRootsWithClassIds(ObjectVisitor* v) {
|
||||
void GlobalHandles::ApplyPersistentHandleVisitor(
|
||||
v8::PersistentHandleVisitor* visitor, GlobalHandles::Node* node) {
|
||||
v8::Value* value = ToApi<v8::Value>(Handle<Object>(node->location()));
|
||||
visitor->VisitPersistentHandle(
|
||||
reinterpret_cast<v8::Persistent<v8::Value>*>(&value),
|
||||
node->wrapper_class_id());
|
||||
}
|
||||
|
||||
DISABLE_CFI_PERF
|
||||
void GlobalHandles::IterateAllRootsWithClassIds(
|
||||
v8::PersistentHandleVisitor* visitor) {
|
||||
for (NodeIterator it(this); !it.done(); it.Advance()) {
|
||||
if (it.node()->IsRetainer() && it.node()->has_wrapper_class_id()) {
|
||||
v->VisitEmbedderReference(it.node()->location(),
|
||||
it.node()->wrapper_class_id());
|
||||
ApplyPersistentHandleVisitor(visitor, it.node());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DISABLE_CFI_PERF
|
||||
void GlobalHandles::IterateAllRootsInNewSpaceWithClassIds(ObjectVisitor* v) {
|
||||
void GlobalHandles::IterateAllRootsInNewSpaceWithClassIds(
|
||||
v8::PersistentHandleVisitor* visitor) {
|
||||
for (int i = 0; i < new_space_nodes_.length(); ++i) {
|
||||
Node* node = new_space_nodes_[i];
|
||||
if (node->IsRetainer() && node->has_wrapper_class_id()) {
|
||||
v->VisitEmbedderReference(node->location(),
|
||||
node->wrapper_class_id());
|
||||
ApplyPersistentHandleVisitor(visitor, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DISABLE_CFI_PERF
|
||||
void GlobalHandles::IterateWeakRootsInNewSpaceWithClassIds(ObjectVisitor* v) {
|
||||
void GlobalHandles::IterateWeakRootsInNewSpaceWithClassIds(
|
||||
v8::PersistentHandleVisitor* visitor) {
|
||||
for (int i = 0; i < new_space_nodes_.length(); ++i) {
|
||||
Node* node = new_space_nodes_[i];
|
||||
if (node->has_wrapper_class_id() && node->IsWeak()) {
|
||||
v->VisitEmbedderReference(node->location(), node->wrapper_class_id());
|
||||
ApplyPersistentHandleVisitor(visitor, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -131,15 +131,15 @@ class GlobalHandles {
|
||||
void IterateAllRoots(ObjectVisitor* v);
|
||||
|
||||
// Iterates over all handles that have embedder-assigned class ID.
|
||||
void IterateAllRootsWithClassIds(ObjectVisitor* v);
|
||||
void IterateAllRootsWithClassIds(v8::PersistentHandleVisitor* v);
|
||||
|
||||
// Iterates over all handles in the new space that have embedder-assigned
|
||||
// class ID.
|
||||
void IterateAllRootsInNewSpaceWithClassIds(ObjectVisitor* v);
|
||||
void IterateAllRootsInNewSpaceWithClassIds(v8::PersistentHandleVisitor* v);
|
||||
|
||||
// Iterate over all handles in the new space that are weak, unmodified
|
||||
// and have class IDs
|
||||
void IterateWeakRootsInNewSpaceWithClassIds(ObjectVisitor* v);
|
||||
void IterateWeakRootsInNewSpaceWithClassIds(v8::PersistentHandleVisitor* v);
|
||||
|
||||
// Iterates over all weak roots in heap.
|
||||
void IterateWeakRoots(ObjectVisitor* v);
|
||||
@ -189,9 +189,14 @@ class GlobalHandles {
|
||||
#endif // DEBUG
|
||||
|
||||
private:
|
||||
explicit GlobalHandles(Isolate* isolate);
|
||||
|
||||
// Internal node structures.
|
||||
class Node;
|
||||
class NodeBlock;
|
||||
class NodeIterator;
|
||||
class PendingPhantomCallback;
|
||||
class PendingPhantomCallbacksSecondPassTask;
|
||||
|
||||
explicit GlobalHandles(Isolate* isolate);
|
||||
|
||||
// Helpers for PostGarbageCollectionProcessing.
|
||||
static void InvokeSecondPassPhantomCallbacks(
|
||||
@ -200,12 +205,8 @@ class GlobalHandles {
|
||||
int PostMarkSweepProcessing(int initial_post_gc_processing_count);
|
||||
int DispatchPendingPhantomCallbacks(bool synchronous_second_pass);
|
||||
void UpdateListOfNewSpaceNodes();
|
||||
|
||||
// Internal node structures.
|
||||
class Node;
|
||||
class NodeBlock;
|
||||
class NodeIterator;
|
||||
class PendingPhantomCallbacksSecondPassTask;
|
||||
void ApplyPersistentHandleVisitor(v8::PersistentHandleVisitor* visitor,
|
||||
Node* node);
|
||||
|
||||
Isolate* isolate_;
|
||||
|
||||
|
@ -1684,7 +1684,6 @@ class RecordMigratedSlotVisitor final : public ObjectVisitor {
|
||||
inline void VisitExternalTwoByteString(
|
||||
v8::String::ExternalStringResource** resource) final {}
|
||||
inline void VisitInternalReference(RelocInfo* rinfo) final {}
|
||||
inline void VisitEmbedderReference(Object** p, uint16_t class_id) final {}
|
||||
|
||||
private:
|
||||
inline void RecordMigratedSlot(Object* value, Address slot) {
|
||||
|
@ -10226,9 +10226,6 @@ class ObjectVisitor BASE_EMBEDDED {
|
||||
// Visits an (encoded) internal reference.
|
||||
virtual void VisitInternalReference(RelocInfo* rinfo) {}
|
||||
|
||||
// Visits a handle that has an embedder-assigned class ID.
|
||||
virtual void VisitEmbedderReference(Object** p, uint16_t class_id) {}
|
||||
|
||||
// Intended for serialization/deserialization checking: insert, or
|
||||
// check for the presence of, a tag at this position in the stream.
|
||||
// Also used for marking up GC roots in heap snapshots.
|
||||
|
@ -2197,16 +2197,17 @@ void V8HeapExplorer::TagGlobalObjects() {
|
||||
DeleteArray(urls);
|
||||
}
|
||||
|
||||
|
||||
class GlobalHandlesExtractor : public ObjectVisitor {
|
||||
class GlobalHandlesExtractor : public PersistentHandleVisitor {
|
||||
public:
|
||||
explicit GlobalHandlesExtractor(NativeObjectsExplorer* explorer)
|
||||
: explorer_(explorer) {}
|
||||
~GlobalHandlesExtractor() override {}
|
||||
void VisitPointers(Object** start, Object** end) override { UNREACHABLE(); }
|
||||
void VisitEmbedderReference(Object** p, uint16_t class_id) override {
|
||||
explorer_->VisitSubtreeWrapper(p, class_id);
|
||||
void VisitPersistentHandle(Persistent<Value>* value,
|
||||
uint16_t class_id) override {
|
||||
Handle<Object> object = Utils::OpenPersistent(value);
|
||||
explorer_->VisitSubtreeWrapper(object.location(), class_id);
|
||||
}
|
||||
|
||||
private:
|
||||
NativeObjectsExplorer* explorer_;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user