diff options
-rw-r--r-- | base/allocator/generic_allocators.cc | 8 | ||||
-rw-r--r-- | build/all.gyp | 8 | ||||
-rw-r--r-- | build/common.gypi | 49 | ||||
-rw-r--r-- | chrome/app/chrome_dll_main.cc | 4 | ||||
-rw-r--r-- | chrome/browser/memory_purger.cc | 2 | ||||
-rwxr-xr-x | chrome/chrome.gyp | 30 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 4 | ||||
-rw-r--r-- | chrome/test/interactive_ui/interactive_ui_tests.gypi | 8 |
8 files changed, 81 insertions, 32 deletions
diff --git a/base/allocator/generic_allocators.cc b/base/allocator/generic_allocators.cc index 659a061..6ea36ec 100644 --- a/base/allocator/generic_allocators.cc +++ b/base/allocator/generic_allocators.cc @@ -48,10 +48,6 @@ void* operator new[](size_t size, const std::nothrow_t& nt) __THROW { return generic_cpp_alloc(size, true); } -} // extern "C++" - -extern "C" { - // This function behaves similarly to MSVC's _set_new_mode. // If flag is 0 (default), calls to malloc will behave normally. // If flag is 1, calls to malloc will behave like calls to new, @@ -63,6 +59,10 @@ int _set_new_mode(int flag) __THROW { return old_mode; } +} // extern "C++" + +extern "C" { + void* calloc(size_t n, size_t elem_size) __THROW { // Overflow check const size_t size = n * elem_size; diff --git a/build/all.gyp b/build/all.gyp index 85849ed..9bdd75f 100644 --- a/build/all.gyp +++ b/build/all.gyp @@ -85,8 +85,14 @@ ], }], ['OS=="win"', { + 'conditions': [ + ['win_use_allocator_shim==1', { + 'dependencies': [ + '../base/allocator/allocator.gyp:*', + ], + }], + ], 'dependencies': [ - '../base/allocator/allocator.gyp:*', '../breakpad/breakpad.gyp:*', '../chrome/app/locales/locales.gyp:*', '../courgette/courgette.gyp:*', diff --git a/build/common.gypi b/build/common.gypi index 997cd9e..8183893 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -127,6 +127,14 @@ # JavaScript engines. 'javascript_engine%': 'v8', + # Although base/allocator lets you select a heap library via an + # environment variable, the libcmt shim it uses sometimes gets in + # the way. To disable it entirely, and switch to normal msvcrt, do e.g. + # 'win_use_allocator_shim': 0, + # 'win_release_RuntimeLibrary': 2 + # to ~/.gyp/include.gypi, gclient runhooks --force, and do a release build. + 'win_use_allocator_shim%': 1, # 0 = shim allocator via libcmt; 1 = msvcrt + # To do a shared build on linux we need to be able to choose between type # static_library and shared_library. We default to doing a static build # but you can override this with "gyp -Dlibrary=shared_library" or you @@ -280,8 +288,16 @@ }, 'target_defaults': { 'variables': { + # See http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Optimize-Options.html 'mac_release_optimization%': '3', # Use -O3 unless overridden 'mac_debug_optimization%': '0', # Use -O0 unless overridden + # See http://msdn.microsoft.com/en-us/library/aa652360(VS.71).aspx + 'win_release_Optimization%': '2', # 2 = /Os + 'win_debug_Optimization%': '0', # 0 = /Od + # See http://msdn.microsoft.com/en-us/library/aa652367(VS.71).aspx + 'win_release_RuntimeLibrary%': '0', # 0 = /MT (nondebug static) + 'win_debug_RuntimeLibrary%': '1', # 1 = /MTd (debug static) + 'release_extra_cflags%': '', 'debug_extra_cflags%': '', 'release_valgrind_build%': 0, @@ -325,6 +341,13 @@ ['selinux==1', { 'defines': ['CHROMIUM_SELINUX=1'], }], + ['win_use_allocator_shim==0', { + 'conditions': [ + ['OS=="win"', { + 'defines': ['NO_TCMALLOC'], + }], + ], + }], ['coverage!=0', { 'conditions': [ ['OS=="mac"', { @@ -389,10 +412,10 @@ }, 'msvs_settings': { 'VCCLCompilerTool': { - 'Optimization': '0', + 'Optimization': '<(win_debug_Optimization)', 'PreprocessorDefinitions': ['_DEBUG'], 'BasicRuntimeChecks': '3', - 'RuntimeLibrary': '1', + 'RuntimeLibrary': '<(win_debug_RuntimeLibrary)', }, 'VCLinkerTool': { 'LinkIncremental': '<(msvs_debug_link_incremental)', @@ -420,6 +443,10 @@ 'OTHER_CFLAGS': [ '<@(release_extra_cflags)', ], }, 'msvs_settings': { + 'VCCLCompilerTool': { + 'Optimization': '<(win_release_Optimization)', + 'RuntimeLibrary': '<(win_release_RuntimeLibrary)', + }, 'VCLinkerTool': { 'LinkIncremental': '1', }, @@ -428,6 +455,16 @@ ['release_valgrind_build==0', { 'defines': ['NVALGRIND'], }], + ['win_use_allocator_shim==0', { + 'defines': ['NO_TCMALLOC'], + }], + ['win_release_RuntimeLibrary==2', { + # Visual C++ 2008 barfs when building anything with /MD (msvcrt): + # VC\include\typeinfo(139) : warning C4275: non dll-interface + # class 'stdext::exception' used as base for dll-interface + # class 'std::bad_cast' + 'msvs_disabled_warnings': [4275], + }], ['msvs_use_common_release', { 'msvs_props': ['release.vsprops'], }], @@ -459,10 +496,6 @@ }, }, }, - 'Release - no tcmalloc': { - 'inherit_from': ['Release'], - 'defines': ['NO_TCMALLOC'], - }, 'Debug_x64': { 'inherit_from': ['Debug'], 'msvs_configuration_platform': 'x64', @@ -475,10 +508,6 @@ 'inherit_from': ['Purify'], 'msvs_configuration_platform': 'x64', }, - 'Release - no tcmalloc_x64': { - 'inherit_from': ['Release - no tcmalloc'], - 'msvs_configuration_platform': 'x64', - }, }], ], }, diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc index 07ccf6d..7fa4e4e 100644 --- a/chrome/app/chrome_dll_main.cc +++ b/chrome/app/chrome_dll_main.cc @@ -226,10 +226,6 @@ static void SetUpGLibLogHandler() { } #endif // defined(OS_LINUX) -#if defined(OS_WIN) -extern "C" int _set_new_mode(int); -#endif - // Register the invalid param handler and pure call handler to be able to // notify breakpad when it happens. void RegisterInvalidParamHandler() { diff --git a/chrome/browser/memory_purger.cc b/chrome/browser/memory_purger.cc index b66f043..d230e45 100644 --- a/chrome/browser/memory_purger.cc +++ b/chrome/browser/memory_purger.cc @@ -128,7 +128,7 @@ void MemoryPurger::PurgeBrowser() { // * Purge AppCache memory. Not yet implemented sufficiently. // * Browser-side DatabaseTracker. Not implemented sufficiently. -#if defined(OS_WIN) +#if defined(OS_WIN) && 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/chrome.gyp b/chrome/chrome.gyp index 9e531fb..cc428ef 100755 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -1069,13 +1069,17 @@ 'include_dirs': [ 'third_party/wtl/include', ], - 'dependencies': [ - '<(allocator_target)', - ], - 'export_dependent_settings': [ - '<(allocator_target)', + 'conditions': [ + ['win_use_allocator_shim==1', { + 'dependencies': [ + '<(allocator_target)', + ], + 'export_dependent_settings': [ + '<(allocator_target)', + ], + }], ], - },], + }], ], }, { @@ -2748,7 +2752,6 @@ 'installer/mini_installer.gyp:*', 'installer/installer.gyp:*', '../app/app.gyp:*', - '../base/allocator/allocator.gyp:*', '../base/base.gyp:*', '../ipc/ipc.gyp:*', '../media/media.gyp:*', @@ -2788,6 +2791,11 @@ '../v8/tools/gyp/v8.gyp:v8_shell', ], 'conditions': [ + ['win_use_allocator_shim==1', { + 'dependencies': [ + '../base/allocator/allocator.gyp:*', + ], + }], ['chrome_frame_define==1', { 'dependencies': [ '../chrome_frame/chrome_frame.gyp:*', @@ -2922,8 +2930,12 @@ ], 'conditions': [ ['OS=="win"', { - 'dependencies': [ - '<(allocator_target)', + 'conditions': [ + ['win_use_allocator_shim==1', { + 'dependencies': [ + '<(allocator_target)', + ], + }], ], 'configurations': { 'Debug': { diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index 69c8cb2..b30a69c 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -573,7 +573,7 @@ void RenderThread::IdleHandler() { if (!widget_count_ || hidden_widget_count_ < widget_count_) return; -#if defined(OS_WIN) +#if defined(OS_WIN) && defined(USE_TCMALLOC) MallocExtension::instance()->ReleaseFreeMemory(); #endif @@ -628,7 +628,7 @@ void RenderThread::OnPurgeMemory() { while (!v8::V8::IdleNotification()) { } -#if defined(OS_WIN) +#if defined(OS_WIN) && defined(USE_TCMALLOC) // Tell tcmalloc to release any free pages it's still holding. MallocExtension::instance()->ReleaseFreeMemory(); #endif diff --git a/chrome/test/interactive_ui/interactive_ui_tests.gypi b/chrome/test/interactive_ui/interactive_ui_tests.gypi index 6988316..983dc27 100644 --- a/chrome/test/interactive_ui/interactive_ui_tests.gypi +++ b/chrome/test/interactive_ui/interactive_ui_tests.gypi @@ -96,7 +96,6 @@ ], 'dependencies': [ '<(DEPTH)/app/app.gyp:app_resources', - '<(DEPTH)/base/allocator/allocator.gyp:allocator', '<(DEPTH)/chrome/chrome.gyp:chrome_dll_version', '<(DEPTH)/chrome/chrome.gyp:crash_service', # run time dependency '<(DEPTH)/chrome/installer/installer.gyp:installer_util_strings', @@ -128,6 +127,13 @@ '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.rc', '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources.rc', ], + 'conditions': [ + ['win_use_allocator_shim==1', { + 'dependencies': [ + '<(DEPTH)/base/allocator/allocator.gyp:allocator', + ], + }], + ], 'configurations': { 'Debug': { 'msvs_settings': { |