Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/allocator/allocator_shim.h" | 5 #include "base/allocator/allocator_shim.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <unistd.h> | 8 #include <unistd.h> |
| 9 | 9 |
| 10 #include <new> | 10 #include <new> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 } | 65 } |
| 66 if (!nh) | 66 if (!nh) |
| 67 return false; | 67 return false; |
| 68 (*nh)(); | 68 (*nh)(); |
| 69 // Assume the new_handler will abort if it fails. Exception are disabled and | 69 // Assume the new_handler will abort if it fails. Exception are disabled and |
| 70 // we don't support the case of a new_handler throwing std::bad_balloc. | 70 // we don't support the case of a new_handler throwing std::bad_balloc. |
| 71 return true; | 71 return true; |
| 72 } | 72 } |
| 73 | 73 |
| 74 inline const allocator::AllocatorDispatch* GetChainHead() { | 74 inline const allocator::AllocatorDispatch* GetChainHead() { |
| 75 // TODO(primiano): Just use NoBarrier_Load once crbug.com/593344 is fixed. | |
|
Nico
2016/03/10 22:50:00
(filed crbug.com/593874 today and made 3344 blocke
Primiano Tucci (use gerrit)
2016/03/11 00:11:08
Seen that. Thanks.
| |
| 76 // Unfortunately due to that bug NoBarrier_Load() is mistakenly fully | |
| 77 // barriered on Linux+Clang, and that causes visible perf regressons. | |
| 75 return reinterpret_cast<const allocator::AllocatorDispatch*>( | 78 return reinterpret_cast<const allocator::AllocatorDispatch*>( |
| 76 subtle::NoBarrier_Load(&g_chain_head)); | 79 #if defined(OS_LINUX) && defined(__clang__) |
|
Nico
2016/03/10 22:50:00
Do we want to check for x86 too?
Primiano Tucci (use gerrit)
2016/03/11 00:11:08
Especially for x86, which is where I saw the bug :
Nico
2016/03/11 15:42:04
I mean on ARM fences are pretty different, so I'm
| |
| 80 *static_cast<const volatile subtle::AtomicWord*>(&g_chain_head) | |
| 81 #else | |
| 82 subtle::NoBarrier_Load(&g_chain_head) | |
| 83 #endif | |
| 84 ); | |
| 77 } | 85 } |
| 78 | 86 |
| 79 } // namespace | 87 } // namespace |
| 80 | 88 |
| 81 namespace base { | 89 namespace base { |
| 82 namespace allocator { | 90 namespace allocator { |
| 83 | 91 |
| 84 void SetCallNewHandlerOnMallocFailure(bool value) { | 92 void SetCallNewHandlerOnMallocFailure(bool value) { |
| 85 g_call_new_handler_on_malloc_failure = value; | 93 g_call_new_handler_on_malloc_failure = value; |
| 86 } | 94 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 // Cross-checks. | 245 // Cross-checks. |
| 238 | 246 |
| 239 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 247 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
| 240 #error The allocator shim should not be compiled when building for memory tools. | 248 #error The allocator shim should not be compiled when building for memory tools. |
| 241 #endif | 249 #endif |
| 242 | 250 |
| 243 #if (defined(__GNUC__) && defined(__EXCEPTIONS)) || \ | 251 #if (defined(__GNUC__) && defined(__EXCEPTIONS)) || \ |
| 244 (defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS) | 252 (defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS) |
| 245 #error This code cannot be used when exceptions are turned on. | 253 #error This code cannot be used when exceptions are turned on. |
| 246 #endif | 254 #endif |
| OLD | NEW |