OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BASE_ALLOCATOR_TYPE_PROFILER_H_ | |
6 #define BASE_ALLOCATOR_TYPE_PROFILER_H_ | |
7 | |
8 #if defined(TYPE_PROFILING) | |
9 | |
10 #include <cstddef> | |
11 #include <typeinfo> | |
12 | |
13 namespace base { | |
14 namespace type_profiler { | |
15 | |
16 typedef void* InterceptFunction(void*, size_t, const std::type_info&); | |
17 | |
18 void* NopIntercept(void* ptr, size_t size, const std::type_info& type); | |
jar (doing other things)
2012/09/06 19:31:43
Why isn't this private to type_profiler.cc? Is it
Dai Mikurube (NOT FULLTIME)
2012/09/07 08:06:45
Removed from type_profiler.h, and moved it to anon
| |
19 | |
20 class InterceptFunctions { | |
21 public: | |
22 // It must be called only once in a process while it is in single-thread. | |
23 // For now, ContentMainRunnerImpl::Initialize is the only supposed caller | |
24 // of this function except for single-threaded unit tests. | |
25 static bool SetFunctions(InterceptFunction* new_intercept, | |
26 InterceptFunction* delete_intercept); | |
27 | |
28 private: | |
29 friend class TypeProfilerTest; | |
30 | |
31 // This function is not thread safe. Use it only when SetInterceptFunctions() | |
32 // is called in a single-thread such as type_profiler_unittests. | |
33 static bool IsAvailable(); | |
34 }; | |
35 | |
36 } // namespace type_profiler | |
37 } // namespace base | |
38 | |
39 // These functions wrap all 'new' and 'delete' expressions. | |
40 // They are called by a modified version of Clang checked-in | |
41 // at deps/third_party/llvm-allocated-type. | |
42 | |
43 void* __op_new_intercept__(void* ptr, | |
jar (doing other things)
2012/09/06 19:31:43
If these are not called by any code (test code?),
Dai Mikurube (NOT FULLTIME)
2012/09/07 08:06:45
They don't look "called" lexically in source files
jar (doing other things)
2012/09/10 16:33:33
Does the compiler trigger on the *declaration* of
Dai Mikurube (NOT FULLTIME)
2012/09/11 00:57:58
*Declaration" triggers. Calling "__op*" is insert
Dai Mikurube (NOT FULLTIME)
2012/09/11 08:19:28
Finally, we could modify Clang to declare required
| |
44 size_t size, | |
45 const std::type_info& type); | |
46 | |
47 void* __op_delete_intercept__(void* ptr, | |
48 size_t size, | |
49 const std::type_info& type); | |
50 | |
51 #endif // defined(TYPE_PROFILING) | |
52 | |
53 #endif // BASE_ALLOCATOR_TYPE_PROFILER_H_ | |
OLD | NEW |