summaryrefslogtreecommitdiff
path: root/src/env-inl.h
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-03-27 15:46:03 -0400
committerJoyee Cheung <joyeec9h3@gmail.com>2019-04-04 11:09:29 +0800
commitf59ec2abee82f22822b7b3231ca2056fc028a279 (patch)
tree3be1fa8fa8b2be425ecc29254b9e8fcb1df111af /src/env-inl.h
parentceb80f415798818a059051537132bba691c68db7 (diff)
downloadandroid-node-v8-f59ec2abee82f22822b7b3231ca2056fc028a279.tar.gz
android-node-v8-f59ec2abee82f22822b7b3231ca2056fc028a279.tar.bz2
android-node-v8-f59ec2abee82f22822b7b3231ca2056fc028a279.zip
src: implement MemoryRetainer in Environment
This allows us to track the essentially-global objects in Environment in the heap snapshot. Note that this patch only tracks the fields that can be tracked correctly. There are still several types of fields that cannot be tracked: - v8::Data including v8::Private, v8::ObjectTemplate etc. - Internal types that do not implement MemoryRetainer yet - STL containers with MemoryRetainer* inside - STL containers with numeric types inside that should not have their nodes elided e.g. numeric keys in maps. The `BaseObject`s are now no longer globals. They are tracked as arguments in CleanupHookCallbacks referenced by the Environment node. This model is closer to how their lifetime is managed internally. To track the per-environment strong persistent properties, this patch divides them into those that are also `v8::Value` and those that are just `v8::Data`. The values can be tracked by the current memory tracker while the data cannot. This patch also implements the `MemoryRetainer` interface in several internal classes so that they can be tracked in the heap snapshot. PR-URL: https://github.com/nodejs/node/pull/27018 Refs: https://github.com/nodejs/node/issues/26776 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/env-inl.h')
-rw-r--r--src/env-inl.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/env-inl.h b/src/env-inl.h
index bce36c0f69..ef054be4cb 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -980,17 +980,17 @@ void Environment::RemoveCleanupHook(void (*fn)(void*), void* arg) {
cleanup_hooks_.erase(search);
}
-size_t Environment::CleanupHookCallback::Hash::operator()(
+size_t CleanupHookCallback::Hash::operator()(
const CleanupHookCallback& cb) const {
return std::hash<void*>()(cb.arg_);
}
-bool Environment::CleanupHookCallback::Equal::operator()(
+bool CleanupHookCallback::Equal::operator()(
const CleanupHookCallback& a, const CleanupHookCallback& b) const {
return a.fn_ == b.fn_ && a.arg_ == b.arg_;
}
-BaseObject* Environment::CleanupHookCallback::GetBaseObject() const {
+BaseObject* CleanupHookCallback::GetBaseObject() const {
if (fn_ == BaseObject::DeleteMe)
return static_cast<BaseObject*>(arg_);
else
@@ -1054,6 +1054,7 @@ void AsyncRequest::set_stopped(bool flag) {
PropertyName ## _.Reset(isolate(), value); \
}
ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)
+ ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
#undef V
} // namespace node