diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-26 00:31:08 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-26 00:31:08 +0000 |
commit | 61a9b2d8a766f0eb9e790385939589797bac37f2 (patch) | |
tree | 5d96266683dc64fc6b37e6839f4ed909a9922db7 | |
parent | 00d721c144d35882dfaf24b3869e95a8d6404ee5 (diff) | |
download | chromium_src-61a9b2d8a766f0eb9e790385939589797bac37f2.zip chromium_src-61a9b2d8a766f0eb9e790385939589797bac37f2.tar.gz chromium_src-61a9b2d8a766f0eb9e790385939589797bac37f2.tar.bz2 |
Merge the LINUX_TC_MALLOC #define with the existing TC_MALLOC #define.
BUG=36687
TEST=about:tcmalloc, etc, works when tcmalloc is enabled on Linux.
Review URL: http://codereview.chromium.org/660118
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40080 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/base.gypi | 6 | ||||
-rw-r--r-- | base/leak_annotations.h | 4 | ||||
-rw-r--r-- | base/process_util_linux.cc | 7 | ||||
-rw-r--r-- | base/process_util_unittest.cc | 10 | ||||
-rw-r--r-- | build/build_config.h | 2 | ||||
-rw-r--r-- | build/common.gypi | 4 | ||||
-rw-r--r-- | chrome/app/chrome_exe_main_gtk.cc | 11 | ||||
-rw-r--r-- | chrome/browser/memory_purger.cc | 4 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 7 | ||||
-rw-r--r-- | webkit/extensions/v8/heap_profiler_extension.cc | 4 |
10 files changed, 29 insertions, 30 deletions
diff --git a/base/base.gypi b/base/base.gypi index 1d4b3e0..3948fe4 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -366,13 +366,13 @@ 'sources/': [ ['include', '_chromeos\\.cc$'] ] }, ], - [ 'linux_use_tcmalloc==1', { + [ 'linux_use_tcmalloc==0', { 'defines': [ - 'LINUX_USE_TCMALLOC', + 'NO_TCMALLOC', ], 'direct_dependent_settings': { 'defines': [ - 'LINUX_USE_TCMALLOC', + 'NO_TCMALLOC', ], }, }, diff --git a/base/leak_annotations.h b/base/leak_annotations.h index f3d3677..8b5c2ad 100644 --- a/base/leak_annotations.h +++ b/base/leak_annotations.h @@ -5,7 +5,9 @@ #ifndef BASE_LEAK_ANNOTATIONS_H_ #define BASE_LEAK_ANNOTATIONS_H_ -#if defined(LINUX_USE_TCMALLOC) +#include "build/build_config.h" + +#if defined(OS_LINUX) && defined(USE_TCMALLOC) #include "third_party/tcmalloc/chromium/src/google/heap-checker.h" diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc index 29147f1..45e719c 100644 --- a/base/process_util_linux.cc +++ b/base/process_util_linux.cc @@ -513,8 +513,7 @@ void OnNoMemory() { } // namespace extern "C" { - -#if !defined(LINUX_USE_TCMALLOC) +#if !defined(USE_TCMALLOC) extern "C" { void* __libc_malloc(size_t size); @@ -539,7 +538,7 @@ void* __libc_memalign(size_t alignment, size_t size); // for this in process_util_unittest.cc. // // If we are using tcmalloc, then the problem is moot since tcmalloc handles -// this for us. Thus this code is in a !defined(LINUX_USE_TCMALLOC) block. +// this for us. Thus this code is in a !defined(USE_TCMALLOC) block. // // We call the real libc functions in this code by using __libc_malloc etc. // Previously we tried using dlsym(RTLD_NEXT, ...) but that failed depending on @@ -590,7 +589,7 @@ int posix_memalign(void** ptr, size_t alignment, size_t size) { return 0; } -#endif // !defined(LINUX_USE_TCMALLOC) +#endif // !defined(USE_TCMALLOC) } // extern C void EnableTerminationOnOutOfMemory() { diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc index 6ab081e..f9c0b50 100644 --- a/base/process_util_unittest.cc +++ b/base/process_util_unittest.cc @@ -250,7 +250,7 @@ int ProcessUtilTest::CountOpenFDsInChild() { NOTREACHED(); file_handle_mapping_vector fd_mapping_vec; - fd_mapping_vec.push_back(std::pair<int,int>(fds[1], kChildPipe)); + fd_mapping_vec.push_back(std::pair<int, int>(fds[1], kChildPipe)); ProcessHandle handle = this->SpawnChild(L"ProcessUtilsLeakFDChildProcess", fd_mapping_vec, false); @@ -408,11 +408,11 @@ TEST_F(ProcessUtilTest, ParseProcStatCPU) { // TODO(vandebo) make this work on Windows and Mac too. #if defined(OS_LINUX) -#if defined(LINUX_USE_TCMALLOC) +#if defined(USE_TCMALLOC) extern "C" { int tc_set_new_mode(int mode); } -#endif // defined(LINUX_USE_TCMALLOC) +#endif // defined(USE_TCMALLOC) class OutOfMemoryTest : public testing::Test { public: @@ -427,13 +427,13 @@ class OutOfMemoryTest : public testing::Test { // Must call EnableTerminationOnOutOfMemory() because that is called from // chrome's main function and therefore hasn't been called yet. EnableTerminationOnOutOfMemory(); -#if defined(LINUX_USE_TCMALLOC) +#if defined(USE_TCMALLOC) tc_set_new_mode(1); } virtual void TearDown() { tc_set_new_mode(0); -#endif // defined(LINUX_USE_TCMALLOC) +#endif // defined(USE_TCMALLOC) } void* value_; diff --git a/build/build_config.h b/build/build_config.h index 0c349c0..29d55b3 100644 --- a/build/build_config.h +++ b/build/build_config.h @@ -61,7 +61,7 @@ #endif // Use tcmalloc -#if defined(OS_WIN) && !defined(NO_TCMALLOC) +#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(NO_TCMALLOC) #define USE_TCMALLOC 1 #endif diff --git a/build/common.gypi b/build/common.gypi index df96104..d61c933 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -948,8 +948,8 @@ }] ], }], - ['linux_use_tcmalloc==1', { - 'defines': ['LINUX_USE_TCMALLOC'], + ['linux_use_tcmalloc==0', { + 'defines': ['NO_TCMALLOC'], }], ], }, diff --git a/chrome/app/chrome_exe_main_gtk.cc b/chrome/app/chrome_exe_main_gtk.cc index cd2edcb..0ed9e15 100644 --- a/chrome/app/chrome_exe_main_gtk.cc +++ b/chrome/app/chrome_exe_main_gtk.cc @@ -17,12 +17,11 @@ extern "C" { int ChromeMain(int argc, const char** argv); -#if defined(LINUX_USE_TCMALLOC) +#if defined(OS_LINUX) && defined(USE_TCMALLOC) int tc_set_new_mode(int mode); -#endif // defined(LINUX_USE_TCMALLOC) - +#endif // defined(OS_LINUX) && defined(USE_TCMALLOC) } int main(int argc, const char** argv) { @@ -35,7 +34,7 @@ int main(int argc, const char** argv) { // dependency on TCMalloc. Really, we ought to have our allocator shim code // implement this EnableTerminationOnOutOfMemory() function. Whateverz. This // works for now. -#if defined(LINUX_USE_TCMALLOC) +#if defined(OS_LINUX) && defined(USE_TCMALLOC) // For tcmalloc, we need to tell it to behave like new. tc_set_new_mode(1); #endif @@ -45,9 +44,5 @@ int main(int argc, const char** argv) { // keep it. // base::AtExitManager exit_manager; -#if defined(GOOGLE_CHROME_BUILD) - // TODO(tc): init crash reporter -#endif - return ChromeMain(argc, argv); } diff --git a/chrome/browser/memory_purger.cc b/chrome/browser/memory_purger.cc index fa85c66..60e4bbe 100644 --- a/chrome/browser/memory_purger.cc +++ b/chrome/browser/memory_purger.cc @@ -4,6 +4,8 @@ #include "chrome/browser/memory_purger.h" +#include <set> + #include "base/thread.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" @@ -135,7 +137,7 @@ void MemoryPurger::PurgeBrowser() { // * Purge AppCache memory. Not yet implemented sufficiently. // * Browser-side DatabaseTracker. Not implemented sufficiently. -#if defined(OS_WIN) && defined(USE_TCMALLOC) +#if (defined(OS_WIN) || defined(OS_LINUX)) && defined(USE_TCMALLOC) // Tell tcmalloc to release any free pages it's still holding. // // TODO(pkasting): A lot of the above calls kick off actions on other threads. diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index 30c56fd..58d225f 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -7,6 +7,7 @@ #include <v8.h> #include <algorithm> +#include <limits> #include <map> #include <vector> @@ -372,7 +373,7 @@ void RenderThread::WidgetHidden() { } void RenderThread::WidgetRestored() { - DCHECK(hidden_widget_count_ > 0); + DCHECK_GT(hidden_widget_count_, 0); hidden_widget_count_--; if (!is_extension_process()) idle_timer_.Stop(); @@ -779,7 +780,7 @@ void RenderThread::EnsureWebKitInitialized() { } void RenderThread::IdleHandler() { -#if defined(OS_WIN) && defined(USE_TCMALLOC) +#if (defined(OS_WIN) || defined(OS_LINUX)) && defined(USE_TCMALLOC) MallocExtension::instance()->ReleaseFreeMemory(); #endif @@ -853,7 +854,7 @@ void RenderThread::OnPurgeMemory() { while (!v8::V8::IdleNotification()) { } -#if defined(OS_WIN) && defined(USE_TCMALLOC) +#if (defined(OS_WIN) || defined(OS_LINUX)) && defined(USE_TCMALLOC) // Tell tcmalloc to release any free pages it's still holding. MallocExtension::instance()->ReleaseFreeMemory(); #endif diff --git a/webkit/extensions/v8/heap_profiler_extension.cc b/webkit/extensions/v8/heap_profiler_extension.cc index e52c8a6..d51d4108 100644 --- a/webkit/extensions/v8/heap_profiler_extension.cc +++ b/webkit/extensions/v8/heap_profiler_extension.cc @@ -6,7 +6,7 @@ #include "base/basictypes.h" -#if defined(LINUX_USE_TCMALLOC) +#if defined(OS_LINUX) && defined(USE_TCMALLOC) #include "third_party/tcmalloc/chromium/src/google/heap-profiler.h" #endif @@ -60,7 +60,7 @@ class HeapProfilerWrapper : public v8::Extension { return v8::Handle<v8::FunctionTemplate>(); } -#if defined(LINUX_USE_TCMALLOC) +#if defined(OS_LINUX) && defined(USE_TCMALLOC) static v8::Handle<v8::Value> HeapProfilerStart(const v8::Arguments& args) { if (args.Length() >= 1 && args[0]->IsString()) { v8::Local<v8::String> js_prefix = args[0]->ToString(); |