| Index: third_party/tcmalloc/chromium/src/metadata_encode.h
|
| diff --git a/third_party/tcmalloc/chromium/src/static_vars.cc b/third_party/tcmalloc/chromium/src/metadata_encode.h
|
| similarity index 53%
|
| copy from third_party/tcmalloc/chromium/src/static_vars.cc
|
| copy to third_party/tcmalloc/chromium/src/metadata_encode.h
|
| index 2ca132e46eab49da5e2c91fa2544d282ad260a0c..dc0ec9eb37c52cd173feabb7e9c64b10a7ec7b12 100644
|
| --- a/third_party/tcmalloc/chromium/src/static_vars.cc
|
| +++ b/third_party/tcmalloc/chromium/src/metadata_encode.h
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2008, Google Inc.
|
| +// Copyright (c) 2011, Google Inc.
|
| // All rights reserved.
|
| //
|
| // Redistribution and use in source and binary forms, with or without
|
| @@ -28,41 +28,47 @@
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| // ---
|
| -// Author: Ken Ashcraft <opensource@google.com>
|
| +// Author: Rebecca Shapiro
|
| +//
|
| +// Here lies code that aids in encoding allocator metadata. Because
|
| +// some, but not all operating systems provide metadata encoding
|
| +// facilities, this header file is used to determine which encoding
|
| +// implementation gets included in the build.
|
| +
|
| +
|
| +#ifndef TCMALLOC_METADATA_ENCODE_H_
|
| +#define TCMALLOC_METADATA_ENCODE_H_
|
| +
|
| +#include "config.h"
|
| +#ifdef HAVE_STDINT_H
|
| +#include <stdint.h> // for uintptr_t
|
| +#endif
|
|
|
| -#include "static_vars.h"
|
| -#include <stddef.h> // for NULL
|
| -#include <new> // for operator new
|
| -#include "internal_logging.h" // for CHECK_CONDITION
|
| -#include "sampler.h" // for Sampler
|
| +#include "config_hardening.h"
|
| +#ifndef TCMALLOC_SPAN_ENCODE
|
| +#include "metadata_encode_disabled.h"
|
| +#else
|
| +#ifdef OS_WIN
|
| +#include "metadata_encode_disabled.h"
|
| +#else // TCMALLOC_SPAN_ENCODE and not OS_WIN.
|
| +#include "metadata_encode_posix.h"
|
| +#endif // OS_WIN
|
| +#endif // TCMALLOC_SPAN_ENCODE
|
|
|
| namespace tcmalloc {
|
|
|
| -SpinLock Static::pageheap_lock_(SpinLock::LINKER_INITIALIZED);
|
| -SizeMap Static::sizemap_;
|
| -CentralFreeListPadded Static::central_cache_[kNumClasses];
|
| -PageHeapAllocator<Span> Static::span_allocator_;
|
| -PageHeapAllocator<StackTrace> Static::stacktrace_allocator_;
|
| -Span Static::sampled_objects_;
|
| -PageHeapAllocator<StackTraceTable::Bucket> Static::bucket_allocator_;
|
| -StackTrace* Static::growth_stacks_ = NULL;
|
| -char Static::pageheap_memory_[sizeof(PageHeap)];
|
| +template <typename T>
|
| +inline T EncodePtr(T ptr){
|
| + return reinterpret_cast<T>(
|
| + EncodeUintptr(reinterpret_cast<uintptr_t>(ptr)));
|
| +}
|
| +
|
| +template <typename T>
|
| +inline T DecodePtr(T ptr){
|
| + return reinterpret_cast<T>(
|
| + DecodeUintptr(reinterpret_cast<uintptr_t>(ptr)));
|
| +}
|
|
|
| -void Static::InitStaticVars() {
|
| - sizemap_.Init();
|
| - span_allocator_.Init();
|
| - span_allocator_.New(); // Reduce cache conflicts
|
| - span_allocator_.New(); // Reduce cache conflicts
|
| - stacktrace_allocator_.Init();
|
| - bucket_allocator_.Init();
|
| - // Do a bit of sanitizing: make sure central_cache is aligned properly
|
| - CHECK_CONDITION((sizeof(central_cache_[0]) % 64) == 0);
|
| - for (int i = 0; i < kNumClasses; ++i) {
|
| - central_cache_[i].Init(i);
|
| - }
|
| - new ((void*)pageheap_memory_) PageHeap;
|
| - DLL_Init(&sampled_objects_);
|
| - Sampler::InitStatics();
|
| }
|
|
|
| -} // namespace tcmalloc
|
| +#endif // TCMALLOC_METADATA_ENCODE_H_
|
|
|