Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: Source/wtf/InstanceCounter.cpp

Issue 1203493004: [tracing] Adding class-wise memory statistics to blink gc memory dumps (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove useless check. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/wtf/InstanceCounter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 17 matching lines...) Expand all
28 28
29 #include "wtf/HashMap.h" 29 #include "wtf/HashMap.h"
30 #include "wtf/StdLibExtras.h" 30 #include "wtf/StdLibExtras.h"
31 #include "wtf/ThreadingPrimitives.h" 31 #include "wtf/ThreadingPrimitives.h"
32 #include "wtf/text/StringBuilder.h" 32 #include "wtf/text/StringBuilder.h"
33 #include "wtf/text/StringHash.h" 33 #include "wtf/text/StringHash.h"
34 #include "wtf/text/WTFString.h" 34 #include "wtf/text/WTFString.h"
35 35
36 namespace WTF { 36 namespace WTF {
37 37
38 #if ENABLE(INSTANCE_COUNTER) || ENABLE(GC_PROFILING)
39
40 #if COMPILER(CLANG) 38 #if COMPILER(CLANG)
41 const size_t extractNameFunctionPrefixLength = sizeof("const char *WTF::extractN ameFunction() [T = ") - 1; 39 const size_t extractNameFunctionPrefixLength = sizeof("const char *WTF::extractN ameFunction() [T = ") - 1;
42 const size_t extractNameFunctionPostfixLength = sizeof("]") - 1; 40 const size_t extractNameFunctionPostfixLength = sizeof("]") - 1;
43 #elif COMPILER(GCC) 41 #elif COMPILER(GCC)
44 const size_t extractNameFunctionPrefixLength = sizeof("const char* WTF::extractN ameFunction() [with T = ") - 1; 42 const size_t extractNameFunctionPrefixLength = sizeof("const char* WTF::extractN ameFunction() [with T = ") - 1;
45 const size_t extractNameFunctionPostfixLength = sizeof("]") - 1; 43 const size_t extractNameFunctionPostfixLength = sizeof("]") - 1;
46 #elif COMPILER(MSVC) 44 #elif COMPILER(MSVC)
47 const size_t extractNameFunctionPrefixLength = sizeof("const char *__cdecl WTF:: extractNameFunction<class ") - 1; 45 const size_t extractNameFunctionPrefixLength = sizeof("const char *__cdecl WTF:: extractNameFunction<class ") - 1;
48 const size_t extractNameFunctionPostfixLength = sizeof(">(void)") - 1; 46 const size_t extractNameFunctionPostfixLength = sizeof(">(void)") - 1;
49 #else 47 #else
50 #warning "Extracting typename is supported only in compiler GCC, CLANG and MSVC at this moment" 48 #warning "Extracting typename is supported only in compiler GCC, CLANG and MSVC at this moment"
51 #endif 49 #endif
52 50
53 // This function is used to stringify a typename T without using RTTI. 51 // This function is used to stringify a typename T without using RTTI.
54 // The result of extractNameFunction<T>() is given as |funcName|. |extractTypeNa meFromFunctionName| then extracts a typename string from |funcName|. 52 // The result of extractNameFunction<T>() is given as |funcName|. |extractTypeNa meFromFunctionName| then extracts a typename string from |funcName|.
55 String extractTypeNameFromFunctionName(const char* funcName) 53 String extractTypeNameFromFunctionName(const char* funcName)
56 { 54 {
57 #if COMPILER(CLANG) || COMPILER(GCC) || COMPILER(MSVC) 55 #if COMPILER(CLANG) || COMPILER(GCC) || COMPILER(MSVC)
58 size_t funcNameLength = strlen(funcName); 56 size_t funcNameLength = strlen(funcName);
59 ASSERT(funcNameLength > extractNameFunctionPrefixLength + extractNameFunctio nPostfixLength); 57 ASSERT(funcNameLength > extractNameFunctionPrefixLength + extractNameFunctio nPostfixLength);
60 58
61 const char* funcNameWithoutPrefix = funcName + extractNameFunctionPrefixLeng th; 59 const char* funcNameWithoutPrefix = funcName + extractNameFunctionPrefixLeng th;
62 return String(funcNameWithoutPrefix, funcNameLength - extractNameFunctionPre fixLength - extractNameFunctionPostfixLength); 60 return String(funcNameWithoutPrefix, funcNameLength - extractNameFunctionPre fixLength - extractNameFunctionPostfixLength);
63 #else 61 #else
64 return String("unknown"); 62 return String("unknown");
65 #endif 63 #endif
66 } 64 }
67 65
66 #if ENABLE(INSTANCE_COUNTER) || ENABLE(GC_PROFILING)
67
68 class InstanceCounter { 68 class InstanceCounter {
69 public: 69 public:
70 void incrementInstanceCount(const String& instanceName, void* ptr); 70 void incrementInstanceCount(const String& instanceName, void* ptr);
71 void decrementInstanceCount(const String& instanceName, void* ptr); 71 void decrementInstanceCount(const String& instanceName, void* ptr);
72 String dump(); 72 String dump();
73 73
74 static InstanceCounter* instance() 74 static InstanceCounter* instance()
75 { 75 {
76 DEFINE_STATIC_LOCAL(InstanceCounter, self, ()); 76 DEFINE_STATIC_LOCAL(InstanceCounter, self, ());
77 return &self; 77 return &self;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 #else 145 #else
146 146
147 String dumpRefCountedInstanceCounts() 147 String dumpRefCountedInstanceCounts()
148 { 148 {
149 return String("{}"); 149 return String("{}");
150 } 150 }
151 151
152 #endif // ENABLE(INSTANCE_COUNTER) || ENABLE(GC_PROFILING) 152 #endif // ENABLE(INSTANCE_COUNTER) || ENABLE(GC_PROFILING)
153 153
154 } // namespace WTF 154 } // namespace WTF
OLDNEW
« no previous file with comments | « Source/wtf/InstanceCounter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698