summaryrefslogtreecommitdiff
path: root/src/memory_tracker-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/memory_tracker-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/memory_tracker-inl.h')
-rw-r--r--src/memory_tracker-inl.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/memory_tracker-inl.h b/src/memory_tracker-inl.h
index 95d623c2b4..72117d2f6a 100644
--- a/src/memory_tracker-inl.h
+++ b/src/memory_tracker-inl.h
@@ -177,6 +177,13 @@ void MemoryTracker::TrackField(const char* edge_name,
TrackFieldWithSize(edge_name, value.size() * sizeof(T), "std::basic_string");
}
+template <typename T>
+void MemoryTracker::TrackField(const char* edge_name,
+ const v8::Eternal<T>& value,
+ const char* node_name) {
+ TrackField(edge_name, value.Get(isolate_));
+}
+
template <typename T, typename Traits>
void MemoryTracker::TrackField(const char* edge_name,
const v8::Persistent<T, Traits>& value,