Commit 4a87608d authored by ulan's avatar ulan Committed by Commit bot

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}
parent d43cebe7
...@@ -8796,30 +8796,10 @@ bool Isolate::IsInUse() { ...@@ -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) { void Isolate::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
i::DisallowHeapAllocation no_allocation; i::DisallowHeapAllocation no_allocation;
VisitorAdapter visitor_adapter(visitor); isolate->global_handles()->IterateAllRootsWithClassIds(visitor);
isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter);
} }
...@@ -8827,18 +8807,14 @@ void Isolate::VisitHandlesForPartialDependence( ...@@ -8827,18 +8807,14 @@ void Isolate::VisitHandlesForPartialDependence(
PersistentHandleVisitor* visitor) { PersistentHandleVisitor* visitor) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
i::DisallowHeapAllocation no_allocation; i::DisallowHeapAllocation no_allocation;
VisitorAdapter visitor_adapter(visitor); isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds(visitor);
isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds(
&visitor_adapter);
} }
void Isolate::VisitWeakHandles(PersistentHandleVisitor* visitor) { void Isolate::VisitWeakHandles(PersistentHandleVisitor* visitor) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
i::DisallowHeapAllocation no_allocation; i::DisallowHeapAllocation no_allocation;
VisitorAdapter visitor_adapter(visitor); isolate->global_handles()->IterateWeakRootsInNewSpaceWithClassIds(visitor);
isolate->global_handles()->IterateWeakRootsInNewSpaceWithClassIds(
&visitor_adapter);
} }
......
...@@ -949,34 +949,44 @@ void GlobalHandles::IterateAllRoots(ObjectVisitor* v) { ...@@ -949,34 +949,44 @@ void GlobalHandles::IterateAllRoots(ObjectVisitor* v) {
DISABLE_CFI_PERF 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()) { for (NodeIterator it(this); !it.done(); it.Advance()) {
if (it.node()->IsRetainer() && it.node()->has_wrapper_class_id()) { if (it.node()->IsRetainer() && it.node()->has_wrapper_class_id()) {
v->VisitEmbedderReference(it.node()->location(), ApplyPersistentHandleVisitor(visitor, it.node());
it.node()->wrapper_class_id());
} }
} }
} }
DISABLE_CFI_PERF DISABLE_CFI_PERF
void GlobalHandles::IterateAllRootsInNewSpaceWithClassIds(ObjectVisitor* v) { void GlobalHandles::IterateAllRootsInNewSpaceWithClassIds(
v8::PersistentHandleVisitor* visitor) {
for (int i = 0; i < new_space_nodes_.length(); ++i) { for (int i = 0; i < new_space_nodes_.length(); ++i) {
Node* node = new_space_nodes_[i]; Node* node = new_space_nodes_[i];
if (node->IsRetainer() && node->has_wrapper_class_id()) { if (node->IsRetainer() && node->has_wrapper_class_id()) {
v->VisitEmbedderReference(node->location(), ApplyPersistentHandleVisitor(visitor, node);
node->wrapper_class_id());
} }
} }
} }
DISABLE_CFI_PERF DISABLE_CFI_PERF
void GlobalHandles::IterateWeakRootsInNewSpaceWithClassIds(ObjectVisitor* v) { void GlobalHandles::IterateWeakRootsInNewSpaceWithClassIds(
v8::PersistentHandleVisitor* visitor) {
for (int i = 0; i < new_space_nodes_.length(); ++i) { for (int i = 0; i < new_space_nodes_.length(); ++i) {
Node* node = new_space_nodes_[i]; Node* node = new_space_nodes_[i];
if (node->has_wrapper_class_id() && node->IsWeak()) { 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 { ...@@ -131,15 +131,15 @@ class GlobalHandles {
void IterateAllRoots(ObjectVisitor* v); void IterateAllRoots(ObjectVisitor* v);
// Iterates over all handles that have embedder-assigned class ID. // 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 // Iterates over all handles in the new space that have embedder-assigned
// class ID. // class ID.
void IterateAllRootsInNewSpaceWithClassIds(ObjectVisitor* v); void IterateAllRootsInNewSpaceWithClassIds(v8::PersistentHandleVisitor* v);
// Iterate over all handles in the new space that are weak, unmodified // Iterate over all handles in the new space that are weak, unmodified
// and have class IDs // and have class IDs
void IterateWeakRootsInNewSpaceWithClassIds(ObjectVisitor* v); void IterateWeakRootsInNewSpaceWithClassIds(v8::PersistentHandleVisitor* v);
// Iterates over all weak roots in heap. // Iterates over all weak roots in heap.
void IterateWeakRoots(ObjectVisitor* v); void IterateWeakRoots(ObjectVisitor* v);
...@@ -189,9 +189,14 @@ class GlobalHandles { ...@@ -189,9 +189,14 @@ class GlobalHandles {
#endif // DEBUG #endif // DEBUG
private: private:
explicit GlobalHandles(Isolate* isolate); // Internal node structures.
class Node;
class NodeBlock;
class NodeIterator;
class PendingPhantomCallback; class PendingPhantomCallback;
class PendingPhantomCallbacksSecondPassTask;
explicit GlobalHandles(Isolate* isolate);
// Helpers for PostGarbageCollectionProcessing. // Helpers for PostGarbageCollectionProcessing.
static void InvokeSecondPassPhantomCallbacks( static void InvokeSecondPassPhantomCallbacks(
...@@ -200,12 +205,8 @@ class GlobalHandles { ...@@ -200,12 +205,8 @@ class GlobalHandles {
int PostMarkSweepProcessing(int initial_post_gc_processing_count); int PostMarkSweepProcessing(int initial_post_gc_processing_count);
int DispatchPendingPhantomCallbacks(bool synchronous_second_pass); int DispatchPendingPhantomCallbacks(bool synchronous_second_pass);
void UpdateListOfNewSpaceNodes(); void UpdateListOfNewSpaceNodes();
void ApplyPersistentHandleVisitor(v8::PersistentHandleVisitor* visitor,
// Internal node structures. Node* node);
class Node;
class NodeBlock;
class NodeIterator;
class PendingPhantomCallbacksSecondPassTask;
Isolate* isolate_; Isolate* isolate_;
......
...@@ -1684,7 +1684,6 @@ class RecordMigratedSlotVisitor final : public ObjectVisitor { ...@@ -1684,7 +1684,6 @@ class RecordMigratedSlotVisitor final : public ObjectVisitor {
inline void VisitExternalTwoByteString( inline void VisitExternalTwoByteString(
v8::String::ExternalStringResource** resource) final {} v8::String::ExternalStringResource** resource) final {}
inline void VisitInternalReference(RelocInfo* rinfo) final {} inline void VisitInternalReference(RelocInfo* rinfo) final {}
inline void VisitEmbedderReference(Object** p, uint16_t class_id) final {}
private: private:
inline void RecordMigratedSlot(Object* value, Address slot) { inline void RecordMigratedSlot(Object* value, Address slot) {
......
...@@ -10226,9 +10226,6 @@ class ObjectVisitor BASE_EMBEDDED { ...@@ -10226,9 +10226,6 @@ class ObjectVisitor BASE_EMBEDDED {
// Visits an (encoded) internal reference. // Visits an (encoded) internal reference.
virtual void VisitInternalReference(RelocInfo* rinfo) {} 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 // Intended for serialization/deserialization checking: insert, or
// check for the presence of, a tag at this position in the stream. // check for the presence of, a tag at this position in the stream.
// Also used for marking up GC roots in heap snapshots. // Also used for marking up GC roots in heap snapshots.
......
...@@ -2197,16 +2197,17 @@ void V8HeapExplorer::TagGlobalObjects() { ...@@ -2197,16 +2197,17 @@ void V8HeapExplorer::TagGlobalObjects() {
DeleteArray(urls); DeleteArray(urls);
} }
class GlobalHandlesExtractor : public PersistentHandleVisitor {
class GlobalHandlesExtractor : public ObjectVisitor {
public: public:
explicit GlobalHandlesExtractor(NativeObjectsExplorer* explorer) explicit GlobalHandlesExtractor(NativeObjectsExplorer* explorer)
: explorer_(explorer) {} : explorer_(explorer) {}
~GlobalHandlesExtractor() override {} ~GlobalHandlesExtractor() override {}
void VisitPointers(Object** start, Object** end) override { UNREACHABLE(); } void VisitPersistentHandle(Persistent<Value>* value,
void VisitEmbedderReference(Object** p, uint16_t class_id) override { uint16_t class_id) override {
explorer_->VisitSubtreeWrapper(p, class_id); Handle<Object> object = Utils::OpenPersistent(value);
explorer_->VisitSubtreeWrapper(object.location(), class_id);
} }
private: private:
NativeObjectsExplorer* explorer_; NativeObjectsExplorer* explorer_;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment