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

Unified Diff: third_party/tcmalloc/vendor/src/malloc_hook.cc

Issue 9316021: Update the tcmalloc vendor branch to r144 (gperftools 2.0). (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Reuploading Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/tcmalloc/vendor/src/malloc_hook.cc
diff --git a/third_party/tcmalloc/vendor/src/malloc_hook.cc b/third_party/tcmalloc/vendor/src/malloc_hook.cc
index dc4539c2578ecdffe7559ab3e83c5e497a5a6255..2f8608e41b0dac2c22f3bf01189dfda6b37e5a25 100644
--- a/third_party/tcmalloc/vendor/src/malloc_hook.cc
+++ b/third_party/tcmalloc/vendor/src/malloc_hook.cc
@@ -46,12 +46,11 @@
#include <stdint.h>
#endif
#include <algorithm>
-#include "base/basictypes.h"
#include "base/logging.h"
#include "base/spinlock.h"
#include "maybe_threads.h"
#include "malloc_hook-inl.h"
-#include <google/malloc_hook.h>
+#include <gperftools/malloc_hook.h>
// This #ifdef should almost never be set. Set NO_TCMALLOC_SAMPLES if
// you're porting to a system where you really can't get a stacktrace.
@@ -59,7 +58,7 @@
// We use #define so code compiles even if you #include stacktrace.h somehow.
# define GetStackTrace(stack, depth, skip) (0)
#else
-# include <google/stacktrace.h>
+# include <gperftools/stacktrace.h>
#endif
// __THROW is defined in glibc systems. It means, counter-intuitively,
@@ -204,14 +203,8 @@ static SpinLock hooklist_spinlock(base::LINKER_INITIALIZED);
template <typename T>
bool HookList<T>::Add(T value_as_t) {
- // Note: we need to check this _before_ reinterpret_cast, since
- // reinterpret_cast may include random junk from memory.
- if (value_as_t == 0) {
- return false;
- }
- AtomicWord value = reinterpret_cast<const AtomicWord&>(value_as_t);
+ AtomicWord value = bit_cast<AtomicWord>(value_as_t);
if (value == 0) {
- // This should not actually happen, but just to be sure...
return false;
}
SpinLockHolder l(&hooklist_spinlock);
@@ -240,8 +233,7 @@ bool HookList<T>::Remove(T value_as_t) {
SpinLockHolder l(&hooklist_spinlock);
AtomicWord hooks_end = base::subtle::Acquire_Load(&priv_end);
int index = 0;
- // Note: we need to cast back to T since T may be smaller than AtomicWord.
- while (index < hooks_end && value_as_t != reinterpret_cast<T>(
+ while (index < hooks_end && value_as_t != bit_cast<T>(
base::subtle::Acquire_Load(&priv_data[index]))) {
++index;
}
@@ -268,7 +260,7 @@ int HookList<T>::Traverse(T* output_array, int n) const {
for (int i = 0; i < hooks_end && n > 0; ++i) {
AtomicWord data = base::subtle::Acquire_Load(&priv_data[i]);
if (data != 0) {
- *output_array++ = reinterpret_cast<const T&>(data);
+ *output_array++ = bit_cast<T>(data);
++actual_hooks_end;
--n;
}
@@ -705,9 +697,7 @@ extern "C" int MallocHook_GetCallerStackTrace(void** result, int max_depth,
#if defined(__linux)
# include "malloc_hook_mmap_linux.h"
-// This code doesn't even compile on my freebsd 8.1 (x86_64) system,
-// so comment it out for now. TODO(csilvers): fix this!
-#elif 0 && defined(__FreeBSD__)
+#elif defined(__FreeBSD__)
# include "malloc_hook_mmap_freebsd.h"
#else
« no previous file with comments | « third_party/tcmalloc/vendor/src/malloc_extension.cc ('k') | third_party/tcmalloc/vendor/src/malloc_hook-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698