diff --git a/include/v8-util.h b/include/v8-util.h index 475026fe2c..7f12ead16b 100644 --- a/include/v8-util.h +++ b/include/v8-util.h @@ -287,7 +287,10 @@ class PersistentValueMapBase { } protected: - explicit PersistentValueMapBase(Isolate* isolate) : isolate_(isolate) {} + explicit PersistentValueMapBase(Isolate* isolate) + : isolate_(isolate), label_(nullptr) {} + PersistentValueMapBase(Isolate* isolate, const char* label) + : isolate_(isolate), label_(label) {} ~PersistentValueMapBase() { Clear(); } @@ -329,6 +332,10 @@ class PersistentValueMapBase { p.Reset(); } + void AnnotateStrongRetainer(Global* persistent) { + persistent->AnnotateStrongRetainer(label_); + } + private: PersistentValueMapBase(PersistentValueMapBase&); void operator=(PersistentValueMapBase&); @@ -345,6 +352,7 @@ class PersistentValueMapBase { Isolate* isolate_; typename Traits::Impl impl_; + const char* label_; }; @@ -353,6 +361,8 @@ class PersistentValueMap : public PersistentValueMapBase { public: explicit PersistentValueMap(Isolate* isolate) : PersistentValueMapBase(isolate) {} + PersistentValueMap(Isolate* isolate, const char* label) + : PersistentValueMapBase(isolate, label) {} typedef typename PersistentValueMapBase::PersistentValueReference @@ -380,7 +390,9 @@ class PersistentValueMap : public PersistentValueMapBase { * by the Traits class. */ Global SetUnique(const K& key, Global* persistent) { - if (Traits::kCallbackType != kNotWeak) { + if (Traits::kCallbackType == kNotWeak) { + this->AnnotateStrongRetainer(persistent); + } else { WeakCallbackType callback_type = Traits::kCallbackType == kWeakWithInternalFields ? WeakCallbackType::kInternalFields @@ -425,6 +437,8 @@ class GlobalValueMap : public PersistentValueMapBase { public: explicit GlobalValueMap(Isolate* isolate) : PersistentValueMapBase(isolate) {} + GlobalValueMap(Isolate* isolate, const char* label) + : PersistentValueMapBase(isolate, label) {} typedef typename PersistentValueMapBase::PersistentValueReference @@ -452,7 +466,9 @@ class GlobalValueMap : public PersistentValueMapBase { * by the Traits class. */ Global SetUnique(const K& key, Global* persistent) { - if (Traits::kCallbackType != kNotWeak) { + if (Traits::kCallbackType == kNotWeak) { + this->AnnotateStrongRetainer(persistent); + } else { WeakCallbackType callback_type = Traits::kCallbackType == kWeakWithInternalFields ? WeakCallbackType::kInternalFields