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

Side by Side Diff: base/allocator/allocator_shim.cc

Issue 2572593002: [counting_allocator] Chrome changes.
Patch Set: Surface max_size; instrument flat_set. Created 3 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 unified diff | Download patch
« no previous file with comments | « base/allocator/allocator_shim.h ('k') | base/allocator/allocator_shim_override_cpp_symbols.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 #include <new> 9 #include <new>
10 10
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 do { 166 do {
167 void* context = nullptr; 167 void* context = nullptr;
168 #if defined(OS_MACOSX) 168 #if defined(OS_MACOSX)
169 context = malloc_default_zone(); 169 context = malloc_default_zone();
170 #endif 170 #endif
171 ptr = chain_head->alloc_function(chain_head, size, context); 171 ptr = chain_head->alloc_function(chain_head, size, context);
172 } while (!ptr && CallNewHandler(size)); 172 } while (!ptr && CallNewHandler(size));
173 return ptr; 173 return ptr;
174 } 174 }
175 175
176 #if defined(_LIBCPP_COUNTING_ALLOCATOR)
177
178 void* ShimTaggedCppNew(size_t size, std::new_tag tag) {
179 const allocator::AllocatorDispatch* const chain_head = GetChainHead();
180 void* ptr;
181 do {
182 if (chain_head->tagged_alloc_function) {
183 ptr = chain_head->tagged_alloc_function(chain_head, size, tag.value);
184 } else {
185 ptr = chain_head->alloc_function(chain_head, size, nullptr);
186 }
187 } while (!ptr && CallNewHandler(size));
188 return ptr;
189 }
190
191 #endif // _LIBCPP_COUNTING_ALLOCATOR
192
176 ALWAYS_INLINE void ShimCppDelete(void* address) { 193 ALWAYS_INLINE void ShimCppDelete(void* address) {
177 void* context = nullptr; 194 void* context = nullptr;
178 #if defined(OS_MACOSX) 195 #if defined(OS_MACOSX)
179 context = malloc_default_zone(); 196 context = malloc_default_zone();
180 #endif 197 #endif
181 const allocator::AllocatorDispatch* const chain_head = GetChainHead(); 198 const allocator::AllocatorDispatch* const chain_head = GetChainHead();
182 return chain_head->free_function(chain_head, address, context); 199 return chain_head->free_function(chain_head, address, context);
183 } 200 }
184 201
185 ALWAYS_INLINE void* ShimMalloc(size_t size, void* context) { 202 ALWAYS_INLINE void* ShimMalloc(size_t size, void* context) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // Cross-checks. 354 // Cross-checks.
338 355
339 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) 356 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
340 #error The allocator shim should not be compiled when building for memory tools. 357 #error The allocator shim should not be compiled when building for memory tools.
341 #endif 358 #endif
342 359
343 #if (defined(__GNUC__) && defined(__EXCEPTIONS)) || \ 360 #if (defined(__GNUC__) && defined(__EXCEPTIONS)) || \
344 (defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS) 361 (defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS)
345 #error This code cannot be used when exceptions are turned on. 362 #error This code cannot be used when exceptions are turned on.
346 #endif 363 #endif
OLDNEW
« no previous file with comments | « base/allocator/allocator_shim.h ('k') | base/allocator/allocator_shim_override_cpp_symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698