| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 40d52fb commit 6772996
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -671,13 +671,19 @@ MaybeLocal<Value> AsyncWrap::MakeCallback(const Local<Function> cb, | |||
| 671 | 671 | return ret; | |
| 672 | 672 | } | |
| 673 | 673 | ||
| 674 | - std::string AsyncWrap::MemoryInfoName() const { | ||
| 674 | + const char* AsyncWrap::MemoryInfoName() const { | ||
| 675 | 675 | return provider_names[provider_type()]; | |
| 676 | 676 | } | |
| 677 | 677 | ||
| 678 | 678 | std::string AsyncWrap::diagnostic_name() const { | |
| 679 | - return MemoryInfoName() + " (" + std::to_string(env()->thread_id()) + ":" + | ||
| 680 | - std::to_string(static_cast<int64_t>(async_id_)) + ")"; | ||
| 679 | + char buf[64]; | ||
| 680 | + snprintf(buf, | ||
| 681 | + sizeof(buf), | ||
| 682 | + "%s(%" PRIu64 ":%.0f)", | ||
| 683 | + MemoryInfoName(), | ||
| 684 | + env()->thread_id(), | ||
| 685 | + async_id_); | ||
| 686 | + return buf; | ||
| 681 | 687 | } | |
| 682 | 688 | ||
| 683 | 689 | Local<Object> AsyncWrap::GetOwner() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -207,7 +207,7 @@ class AsyncWrap : public BaseObject { | |||
| 207 | 207 | v8::Local<v8::Value>* argv); | |
| 208 | 208 | ||
| 209 | 209 | virtual std::string diagnostic_name() const; | |
| 210 | - std::string MemoryInfoName() const override; | ||
| 210 | + const char* MemoryInfoName() const override; | ||
| 211 | 211 | ||
| 212 | 212 | static void WeakCallback(const v8::WeakCallbackInfo<DestroyParam> &info); | |
| 213 | 213 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -398,7 +398,7 @@ class CryptoJob : public AsyncWrap, public ThreadPoolWork { | |||
| 398 | 398 | ||
| 399 | 399 | AdditionalParams* params() { return ¶ms_; } | |
| 400 | 400 | ||
| 401 | - std::string MemoryInfoName() const override { | ||
| 401 | + const char* MemoryInfoName() const override { | ||
| 402 | 402 | return CryptoJobTraits::JobName; | |
| 403 | 403 | } | |
| 404 | 404 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,7 +44,7 @@ class MemoryRetainerNode : public v8::EmbedderGraph::Node { | |||
| 44 | 44 | is_root_node_ = is_root_node; | |
| 45 | 45 | } | |
| 46 | 46 | ||
| 47 | - const char* Name() override { return name_.c_str(); } | ||
| 47 | + const char* Name() override { return name_; } | ||
| 48 | 48 | const char* NamePrefix() override { return "Node /"; } | |
| 49 | 49 | size_t SizeInBytes() override { return size_; } | |
| 50 | 50 | // TODO(addaleax): Merging this with the "official" WrapperNode() method | |
@@ -75,7 +75,7 @@ class MemoryRetainerNode : public v8::EmbedderGraph::Node { | |||
| 75 | 75 | ||
| 76 | 76 | // Otherwise (retainer == nullptr), we set these fields in an ad-hoc way | |
| 77 | 77 | bool is_root_node_ = false; | |
| 78 | - std::string name_; | ||
| 78 | + const char* name_; | ||
| 79 | 79 | size_t size_ = 0; | |
| 80 | 80 | v8::EmbedderGraph::Node::Detachedness detachedness_ = | |
| 81 | 81 | v8::EmbedderGraph::Node::Detachedness::kUnknown; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,7 @@ namespace node { | |||
| 17 | 17 | ||
| 18 | 18 | // Set the node name of a MemoryRetainer to klass | |
| 19 | 19 | #define SET_MEMORY_INFO_NAME(Klass) \ | |
| 20 | - inline std::string MemoryInfoName() const override { return #Klass; } | ||
| 20 | + inline const char* MemoryInfoName() const override { return #Klass; } | ||
| 21 | 21 | ||
| 22 | 22 | // Set the self size of a MemoryRetainer to the stack-allocated size of a | |
| 23 | 23 | // certain class | |
@@ -68,7 +68,7 @@ class CleanupHookCallback; | |||
| 68 | 68 | * } | |
| 69 | 69 | * | |
| 70 | 70 | * // Or use SET_MEMORY_INFO_NAME(ExampleRetainer) | |
| 71 | - * std::string MemoryInfoName() const override { | ||
| 71 | + * const char* MemoryInfoName() const override { | ||
| 72 | 72 | * return "ExampleRetainer"; | |
| 73 | 73 | * } | |
| 74 | 74 | * | |
@@ -119,7 +119,7 @@ class MemoryRetainer { | |||
| 119 | 119 | // where all the edges start from the node of the current retainer, | |
| 120 | 120 | // and point to the nodes as specified by tracker->Track* calls. | |
| 121 | 121 | virtual void MemoryInfo(MemoryTracker* tracker) const = 0; | |
| 122 | - virtual std::string MemoryInfoName() const = 0; | ||
| 122 | + virtual const char* MemoryInfoName() const = 0; | ||
| 123 | 123 | virtual size_t SelfSize() const = 0; | |
| 124 | 124 | ||
| 125 | 125 | virtual v8::Local<v8::Object> WrappedObject() const { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -282,14 +282,14 @@ static void GetActiveResourcesInfo(const FunctionCallbackInfo<Value>& args) { | |||
| 282 | 282 | AsyncWrap* w = req_wrap->GetAsyncWrap(); | |
| 283 | 283 | if (w->persistent().IsEmpty()) continue; | |
| 284 | 284 | resources_info.emplace_back( | |
| 285 | - OneByteString(env->isolate(), w->MemoryInfoName().c_str())); | ||
| 285 | + OneByteString(env->isolate(), w->MemoryInfoName())); | ||
| 286 | 286 | } | |
| 287 | 287 | ||
| 288 | 288 | // Active handles | |
| 289 | 289 | for (HandleWrap* w : *env->handle_wrap_queue()) { | |
| 290 | 290 | if (w->persistent().IsEmpty() || !HandleWrap::HasRef(w)) continue; | |
| 291 | 291 | resources_info.emplace_back( | |
| 292 | - OneByteString(env->isolate(), w->MemoryInfoName().c_str())); | ||
| 292 | + OneByteString(env->isolate(), w->MemoryInfoName())); | ||
| 293 | 293 | } | |
| 294 | 294 | ||
| 295 | 295 | // Active timeouts | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -366,7 +366,7 @@ void Realm::VerifyNoStrongBaseObjects() { | |||
| 366 | 366 | if (obj->IsNotIndicativeOfMemoryLeakAtExit()) return; | |
| 367 | 367 | fprintf(stderr, | |
| 368 | 368 | "Found bad BaseObject during clean exit: %s\n", | |
| 369 | - obj->MemoryInfoName().c_str()); | ||
| 369 | + obj->MemoryInfoName()); | ||
| 370 | 370 | fflush(stderr); | |
| 371 | 371 | ABORT(); | |
| 372 | 372 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,7 +50,7 @@ class TCPWrap : public ConnectionWrap<TCPWrap, uv_tcp_t> { | |||
| 50 | 50 | ||
| 51 | 51 | SET_NO_MEMORY_INFO() | |
| 52 | 52 | SET_SELF_SIZE(TCPWrap) | |
| 53 | - std::string MemoryInfoName() const override { | ||
| 53 | + const char* MemoryInfoName() const override { | ||
| 54 | 54 | switch (provider_type()) { | |
| 55 | 55 | case ProviderType::PROVIDER_TCPWRAP: | |
| 56 | 56 | return "TCPSocketWrap"; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments