| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 946f19b commit 66e4ba5
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -206,6 +206,25 @@ void AliasedBufferBase<NativeT, V8T>::reserve(size_t new_capacity) { | |||
| 206 | 206 | count_ = new_capacity; | |
| 207 | 207 | } | |
| 208 | 208 | ||
| 209 | + template <typename NativeT, typename V8T> | ||
| 210 | + inline size_t AliasedBufferBase<NativeT, V8T>::SelfSize() const { | ||
| 211 | + return sizeof(*this); | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + #define VM(NativeT, V8T) \ | ||
| 215 | + template <> \ | ||
| 216 | + inline const char* AliasedBufferBase<NativeT, v8::V8T>::MemoryInfoName() \ | ||
| 217 | + const { \ | ||
| 218 | + return "Aliased" #V8T; \ | ||
| 219 | + } \ | ||
| 220 | + template <> \ | ||
| 221 | + inline void AliasedBufferBase<NativeT, v8::V8T>::MemoryInfo( \ | ||
| 222 | + node::MemoryTracker* tracker) const { \ | ||
| 223 | + tracker->TrackField("js_array", js_array_); \ | ||
| 224 | + } | ||
| 225 | + ALIASED_BUFFER_LIST(VM) | ||
| 226 | + #undef VM | ||
| 227 | + | ||
| 209 | 228 | } // namespace node | |
| 210 | 229 | ||
| 211 | 230 | #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ | |||
| 4 | 4 | #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | |
| 5 | 5 | ||
| 6 | 6 | #include <cinttypes> | |
| 7 | + #include "memory_tracker.h" | ||
| 7 | 8 | #include "v8.h" | |
| 8 | 9 | ||
| 9 | 10 | namespace node { | |
@@ -28,7 +29,7 @@ typedef size_t AliasedBufferIndex; | |||
| 28 | 29 | * observed. Any notification APIs will be left as a future exercise. | |
| 29 | 30 | */ | |
| 30 | 31 | template <class NativeT, class V8T> | |
| 31 | - class AliasedBufferBase { | ||
| 32 | + class AliasedBufferBase : public MemoryRetainer { | ||
| 32 | 33 | public: | |
| 33 | 34 | static_assert(std::is_scalar<NativeT>::value); | |
| 34 | 35 | ||
@@ -157,6 +158,11 @@ class AliasedBufferBase { | |||
| 157 | 158 | // an owning `AliasedBufferBase`. | |
| 158 | 159 | void reserve(size_t new_capacity); | |
| 159 | 160 | ||
| 161 | + inline size_t SelfSize() const override; | ||
| 162 | + | ||
| 163 | + inline const char* MemoryInfoName() const override; | ||
| 164 | + inline void MemoryInfo(node::MemoryTracker* tracker) const override; | ||
| 165 | + | ||
| 160 | 166 | private: | |
| 161 | 167 | v8::Isolate* isolate_ = nullptr; | |
| 162 | 168 | size_t count_ = 0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | 4 | #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | |
| 5 | 5 | ||
| 6 | - #include "aliased_buffer-inl.h" | ||
| 7 | 6 | #include "memory_tracker.h" | |
| 7 | + #include "util-inl.h" | ||
| 8 | 8 | ||
| 9 | 9 | namespace node { | |
| 10 | 10 | ||
@@ -270,13 +270,6 @@ void MemoryTracker::TrackInlineField(const char* name, | |||
| 270 | 270 | TrackInlineFieldWithSize(name, sizeof(value), "uv_async_t"); | |
| 271 | 271 | } | |
| 272 | 272 | ||
| 273 | - template <class NativeT, class V8T> | ||
| 274 | - void MemoryTracker::TrackField(const char* name, | ||
| 275 | - const AliasedBufferBase<NativeT, V8T>& value, | ||
| 276 | - const char* node_name) { | ||
| 277 | - TrackField(name, value.GetJSArray(), "AliasedBuffer"); | ||
| 278 | - } | ||
| 279 | - | ||
| 280 | 273 | void MemoryTracker::Track(const MemoryRetainer* retainer, | |
| 281 | 274 | const char* edge_name) { | |
| 282 | 275 | v8::HandleScope handle_scope(isolate_); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,6 @@ | |||
| 2 | 2 | ||
| 3 | 3 | #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | |
| 4 | 4 | ||
| 5 | - #include "aliased_buffer.h" | ||
| 6 | 5 | #include "v8-profiler.h" | |
| 7 | 6 | ||
| 8 | 7 | #include <uv.h> | |
@@ -238,10 +237,6 @@ class MemoryTracker { | |||
| 238 | 237 | inline void TrackInlineField(const char* edge_name, | |
| 239 | 238 | const uv_async_t& value, | |
| 240 | 239 | const char* node_name = nullptr); | |
| 241 | - template <class NativeT, class V8T> | ||
| 242 | - inline void TrackField(const char* edge_name, | ||
| 243 | - const AliasedBufferBase<NativeT, V8T>& value, | ||
| 244 | - const char* node_name = nullptr); | ||
| 245 | 240 | ||
| 246 | 241 | // Put a memory container into the graph, create an edge from | |
| 247 | 242 | // the current node if there is one on the stack. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,7 +10,7 @@ validateSnapshotNodes('Node / FSReqPromise', [ | |||
| 10 | 10 | { | |
| 11 | 11 | children: [ | |
| 12 | 12 | { node_name: 'FSReqPromise', edge_name: 'native_to_javascript' }, | |
| 13 | - { node_name: 'Float64Array', edge_name: 'stats_field_array' }, | ||
| 13 | + { node_name: 'Node / AliasedFloat64Array', edge_name: 'stats_field_array' }, | ||
| 14 | 14 | ], | |
| 15 | 15 | }, | |
| 16 | 16 | ]); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments