Index: base/allocator/type_profiler.h |
diff --git a/base/allocator/type_profiler.h b/base/allocator/type_profiler.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..babc3d8f4482fac82c984ac6b56465b09fee7301 |
--- /dev/null |
+++ b/base/allocator/type_profiler.h |
@@ -0,0 +1,59 @@ |
+// Copyright 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef BASE_ALLOCATOR_TYPE_PROFILER_H_ |
+#define BASE_ALLOCATOR_TYPE_PROFILER_H_ |
+ |
+#if defined(TYPE_PROFILING) |
+ |
+#include <cstddef> // for size_t |
+#include <typeinfo> // for std::typeinfo |
+ |
+// These two functions wrap all 'new' and 'delete' expressions. |
+// They are called by a modified version of Clang checked-in |
+// at deps/third_party/llvm-allocated-type. |
+// These prototype declarations are required to make them friends of |
+// InterceptFunctions below. |
+ |
+void* __op_new_intercept__(void* ptr, |
+ size_t size, |
+ const std::type_info& type); |
+ |
+void* __op_delete_intercept__(void* ptr, |
+ size_t size, |
+ const std::type_info& type); |
+ |
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
|
+namespace base { |
+namespace type_profiler { |
+ |
+typedef void* InterceptFunction(void*, size_t, const std::type_info&); |
+ |
+class InterceptFunctions { |
+ public: |
+ // It must be called only once in a process while it is in single-thread. |
+ // For now, ContentMainRunnerImpl::Initialize is the only supposed caller |
+ // of this function except for single-threaded unit tests. |
+ static void SetFunctions(InterceptFunction* new_intercept, |
+ 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.
|
+ |
+ private: |
+ friend class TypeProfilerTest; |
+ friend void* ::__op_new_intercept__(void*, size_t, const std::type_info&); |
+ friend void* ::__op_delete_intercept__(void*, size_t, const std::type_info&); |
+ |
+ // These functions are not thread safe. |
+ // They must be used only from single-threaded unit tests. |
+ static void ResetFunctions(); |
+ static bool IsAvailable(); |
+ |
+ static InterceptFunction* new_intercept_; |
+ 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
|
+}; |
+ |
+} // namespace type_profiler |
+} // namespace base |
+ |
+#endif // defined(TYPE_PROFILING) |
+ |
+#endif // BASE_ALLOCATOR_TYPE_PROFILER_H_ |