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

Side by Side Diff: runtime/vm/malloc_hooks.cc

Issue 2718723003: Fixed issue where MallocHooks tests would try and re-initialize the hooks and ended up hitting an a… (Closed)
Patch 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 6
7 #if defined(DART_USE_TCMALLOC) && !defined(PRODUCT) && \ 7 #if defined(DART_USE_TCMALLOC) && !defined(PRODUCT) && \
8 !defined(TARGET_ARCH_DBC) && !defined(TARGET_OS_FUCHSIA) 8 !defined(TARGET_ARCH_DBC) && !defined(TARGET_OS_FUCHSIA)
9 9
10 #include "vm/malloc_hooks.h" 10 #include "vm/malloc_hooks.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 ASSERT(malloc_hook_mutex()->IsOwnedByCurrentThread()); 256 ASSERT(malloc_hook_mutex()->IsOwnedByCurrentThread());
257 active_ = false; 257 active_ = false;
258 original_pid_ = kInvalidPid; 258 original_pid_ = kInvalidPid;
259 ResetStats(); 259 ResetStats();
260 delete address_map_; 260 delete address_map_;
261 address_map_ = NULL; 261 address_map_ = NULL;
262 } 262 }
263 263
264 264
265 void MallocHooks::InitOnce() { 265 void MallocHooks::InitOnce() {
266 if (!FLAG_enable_malloc_hooks) { 266 if (!FLAG_enable_malloc_hooks || MallocHooks::Active()) {
267 return; 267 return;
268 } 268 }
269 MallocLocker ml(MallocHooksState::malloc_hook_mutex(), 269 MallocLocker ml(MallocHooksState::malloc_hook_mutex(),
270 MallocHooksState::malloc_hook_mutex_owner()); 270 MallocHooksState::malloc_hook_mutex_owner());
271 ASSERT(!MallocHooksState::Active()); 271 ASSERT(!MallocHooksState::Active());
272 272
273 MallocHooksState::Init(); 273 MallocHooksState::Init();
274 274
275 // Register malloc hooks. 275 // Register malloc hooks.
276 bool success = false; 276 bool success = false;
277 success = MallocHook::AddNewHook(&MallocHooksState::RecordAllocHook); 277 success = MallocHook::AddNewHook(&MallocHooksState::RecordAllocHook);
278 ASSERT(success); 278 ASSERT(success);
279 success = MallocHook::AddDeleteHook(&MallocHooksState::RecordFreeHook); 279 success = MallocHook::AddDeleteHook(&MallocHooksState::RecordFreeHook);
280 ASSERT(success); 280 ASSERT(success);
281 } 281 }
282 282
283 283
284 void MallocHooks::TearDown() { 284 void MallocHooks::TearDown() {
285 if (!FLAG_enable_malloc_hooks) { 285 if (!FLAG_enable_malloc_hooks || !MallocHooks::Active()) {
286 return; 286 return;
287 } 287 }
288 MallocLocker ml(MallocHooksState::malloc_hook_mutex(), 288 MallocLocker ml(MallocHooksState::malloc_hook_mutex(),
289 MallocHooksState::malloc_hook_mutex_owner()); 289 MallocHooksState::malloc_hook_mutex_owner());
290 ASSERT(MallocHooksState::Active()); 290 ASSERT(MallocHooksState::Active());
291 291
292 // Remove malloc hooks. 292 // Remove malloc hooks.
293 bool success = false; 293 bool success = false;
294 success = MallocHook::RemoveNewHook(&MallocHooksState::RecordAllocHook); 294 success = MallocHook::RemoveNewHook(&MallocHooksState::RecordAllocHook);
295 ASSERT(success); 295 ASSERT(success);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 MallocHooksState::address_map()->Remove(ptr); 438 MallocHooksState::address_map()->Remove(ptr);
439 delete allocation_info; 439 delete allocation_info;
440 } 440 }
441 } 441 }
442 } 442 }
443 443
444 } // namespace dart 444 } // namespace dart
445 445
446 #endif // defined(DART_USE_TCMALLOC) && !defined(PRODUCT) && 446 #endif // defined(DART_USE_TCMALLOC) && !defined(PRODUCT) &&
447 // !defined(TARGET_ARCH_DBC) && !defined(TARGET_OS_FUCHSIA) 447 // !defined(TARGET_ARCH_DBC) && !defined(TARGET_OS_FUCHSIA)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698