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

Side by Side Diff: base/allocator/type_profiler.h

Issue 10411047: Type profiler by intercepting 'new' and 'delete' expressions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed for jar's comments #72 Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
(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> // for size_t
11 #include <typeinfo> // for std::typeinfo
12
13 // These two functions wrap all 'new' and 'delete' expressions.
14 // They are called by a modified version of Clang checked-in
15 // at deps/third_party/llvm-allocated-type.
16 // These prototype declarations are required to make them friends of
17 // InterceptFunctions below.
18
19 void* __op_new_intercept__(void* ptr,
20 size_t size,
21 const std::type_info& type);
22
23 void* __op_delete_intercept__(void* ptr,
24 size_t size,
25 const std::type_info& type);
26
Ryan Sleevi 2012/09/12 19:13:34 I think I may have to disagree with Jim here, unfo
Ryan Sleevi 2012/09/12 22:04:18 Have you checked in the latest version of your cla
Dai Mikurube (NOT FULLTIME) 2012/09/13 01:12:40 The latest modified compiler has been checked-in.
Ryan Sleevi 2012/09/13 01:34:59 Have you not updated http://src.chromium.org/viewv
27 namespace base {
28 namespace type_profiler {
29
30 typedef void* InterceptFunction(void*, size_t, const std::type_info&);
31
32 class InterceptFunctions {
33 public:
34 // It must be called only once in a process while it is in single-thread.
35 // For now, ContentMainRunnerImpl::Initialize is the only supposed caller
36 // of this function except for single-threaded unit tests.
37 static void SetFunctions(InterceptFunction* new_intercept,
38 InterceptFunction* delete_intercept);
Ryan Sleevi 2012/09/12 19:13:34 It's unclear to me why this is a static class, giv
Ryan Sleevi 2012/09/12 22:04:18 I spoke with Jim, and while we agree both solution
Dai Mikurube (NOT FULLTIME) 2012/09/13 01:12:40 Ok, I keep it as is.
39
40 private:
41 friend class TypeProfilerTest;
42 friend void* ::__op_new_intercept__(void*, size_t, const std::type_info&);
43 friend void* ::__op_delete_intercept__(void*, size_t, const std::type_info&);
44
45 // These functions are not thread safe.
46 // They must be used only from single-threaded unit tests.
47 static void ResetFunctions();
48 static bool IsAvailable();
49
50 static InterceptFunction* new_intercept_;
51 static InterceptFunction* delete_intercept_;
Ryan Sleevi 2012/09/12 22:04:18 However, please remove all static member variables
Dai Mikurube (NOT FULLTIME) 2012/09/13 04:00:12 Done. As a side effect, we could remove forward d
52 };
53
54 } // namespace type_profiler
55 } // namespace base
56
57 #endif // defined(TYPE_PROFILING)
58
59 #endif // BASE_ALLOCATOR_TYPE_PROFILER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698