OLD | NEW |
---|---|
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 16 matching lines...) Expand all Loading... | |
27 #define InstanceCounter_h | 27 #define InstanceCounter_h |
28 | 28 |
29 #include "wtf/Compiler.h" | 29 #include "wtf/Compiler.h" |
30 #include "wtf/WTFExport.h" | 30 #include "wtf/WTFExport.h" |
31 | 31 |
32 namespace WTF { | 32 namespace WTF { |
33 | 33 |
34 class String; | 34 class String; |
35 WTF_EXPORT String dumpRefCountedInstanceCounts(); | 35 WTF_EXPORT String dumpRefCountedInstanceCounts(); |
36 | 36 |
37 // Warning: Using extractTypeNameFromFunctionName bloats binary size. | |
tkent
2015/09/01 01:36:15
Can we warp the function with ENABLE(ASSERT) || EN
| |
38 // This function should be only used for debug and profiling purposes, | |
39 // and should be never enabled on release builds. | |
37 WTF_EXPORT String extractTypeNameFromFunctionName(const char* funcName); | 40 WTF_EXPORT String extractTypeNameFromFunctionName(const char* funcName); |
38 | 41 |
39 template<typename T> | 42 template<typename T> |
40 inline const char* extractNameFunction() | 43 inline const char* extractNameFunction() |
41 { | 44 { |
42 return WTF_PRETTY_FUNCTION; | 45 return WTF_PRETTY_FUNCTION; |
43 } | 46 } |
44 | 47 |
45 #if ENABLE(INSTANCE_COUNTER) || ENABLE(GC_PROFILING) | 48 #if ENABLE(INSTANCE_COUNTER) || ENABLE(GC_PROFILING) |
46 WTF_EXPORT void incrementInstanceCount(const char* extractNameFunctionName, void * ptr); | 49 WTF_EXPORT void incrementInstanceCount(const char* extractNameFunctionName, void * ptr); |
47 WTF_EXPORT void decrementInstanceCount(const char* extractNameFunctionName, void * ptr); | 50 WTF_EXPORT void decrementInstanceCount(const char* extractNameFunctionName, void * ptr); |
48 | 51 |
49 template<typename T> | 52 template<typename T> |
50 inline void incrementInstanceCount(T* p) | 53 inline void incrementInstanceCount(T* p) |
51 { | 54 { |
52 incrementInstanceCount(extractNameFunction<T>(), p); | 55 incrementInstanceCount(extractNameFunction<T>(), p); |
53 } | 56 } |
54 | 57 |
55 template<typename T> | 58 template<typename T> |
56 inline void decrementInstanceCount(T* p) | 59 inline void decrementInstanceCount(T* p) |
57 { | 60 { |
58 decrementInstanceCount(extractNameFunction<T>(), p); | 61 decrementInstanceCount(extractNameFunction<T>(), p); |
59 } | 62 } |
60 | 63 |
61 #endif // ENABLE(INSTANCE_COUNTER) || ENABLE(GC_PROFILING) | 64 #endif // ENABLE(INSTANCE_COUNTER) || ENABLE(GC_PROFILING) |
62 | 65 |
63 } // namespace WTF | 66 } // namespace WTF |
64 | 67 |
65 #endif | 68 #endif |
OLD | NEW |