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

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

Issue 2771293003: Resubmission of native memory allocation info surfacing in Observatory. Fixed crashing tests and st… (Closed)
Patch Set: Removed garbage code, updated status file to skip service test not supported 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
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(HOST_OS_FUCHSIA) 8 !defined(TARGET_ARCH_DBC) && !defined(HOST_OS_FUCHSIA)
9 9
10 #include "vm/malloc_hooks.h" 10 #include "vm/malloc_hooks.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 Sample* sample_; 154 Sample* sample_;
155 uword address_; 155 uword address_;
156 intptr_t allocation_size_; 156 intptr_t allocation_size_;
157 157
158 // The number of frames that are generated by the malloc hooks and collection 158 // The number of frames that are generated by the malloc hooks and collection
159 // of the stack trace. These frames are ignored when collecting the stack 159 // of the stack trace. These frames are ignored when collecting the stack
160 // trace for a memory allocation. If this number is incorrect, some tests in 160 // trace for a memory allocation. If this number is incorrect, some tests in
161 // malloc_hook_tests.cc might fail, particularily 161 // malloc_hook_tests.cc might fail, particularily
162 // StackTraceMallocHookLengthTest. If this value is updated, please make sure 162 // StackTraceMallocHookLengthTest. If this value is updated, please make sure
163 // that the MallocHooks test cases pass on all platforms. 163 // that the MallocHooks test cases pass on all platforms.
164 #if defined(DEBUG) && defined(HOST_ARCH_X64)
164 static const intptr_t kSkipCount = 6; 165 static const intptr_t kSkipCount = 6;
166 #elif defined(DEBUG) && defined(HOST_ARCH_IA32)
167 static const intptr_t kSkipCount = 5;
168 #elif !(defined(PRODUCT) || defined(DEBUG)) && \
169 (defined(HOST_ARCH_X64) || defined(HOST_ARCH_IA32))
170 static const intptr_t kSkipCount = 5;
171 #else
172 #error Previously unsupported MallocHooks configuration. New kSkipCount may \
173 need to be added.
174 #endif
siva 2017/03/24 22:51:00 Adding such target #ifs in a common file just make
bkonyi 2017/03/27 17:50:25 Done.
165 }; 175 };
166 176
167 177
168 // Custom key/value trait specifically for address/size pairs. Unlike 178 // Custom key/value trait specifically for address/size pairs. Unlike
169 // RawPointerKeyValueTrait, the default value is -1 as 0 can be a valid entry. 179 // RawPointerKeyValueTrait, the default value is -1 as 0 can be a valid entry.
170 class AddressKeyValueTrait : public AllStatic { 180 class AddressKeyValueTrait : public AllStatic {
171 public: 181 public:
172 typedef const void* Key; 182 typedef const void* Key;
173 typedef AllocationInfo* Value; 183 typedef AllocationInfo* Value;
174 184
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 } 446 }
437 447
438 MallocLocker ml(MallocHooksState::malloc_hook_mutex(), 448 MallocLocker ml(MallocHooksState::malloc_hook_mutex(),
439 MallocHooksState::malloc_hook_mutex_owner()); 449 MallocHooksState::malloc_hook_mutex_owner());
440 // Now that we hold the lock, check to make sure everything is still active. 450 // Now that we hold the lock, check to make sure everything is still active.
441 if ((ptr != NULL) && MallocHooksState::Active()) { 451 if ((ptr != NULL) && MallocHooksState::Active()) {
442 AllocationInfo* allocation_info = NULL; 452 AllocationInfo* allocation_info = NULL;
443 if (MallocHooksState::address_map()->Lookup(ptr, &allocation_info)) { 453 if (MallocHooksState::address_map()->Lookup(ptr, &allocation_info)) {
444 MallocHooksState::DecrementHeapAllocatedMemoryInBytes( 454 MallocHooksState::DecrementHeapAllocatedMemoryInBytes(
445 allocation_info->allocation_size()); 455 allocation_info->allocation_size());
446 ASSERT(MallocHooksState::address_map()->Remove(ptr)); 456 bool result = MallocHooksState::address_map()->Remove(ptr);
457 ASSERT(result);
447 delete allocation_info; 458 delete allocation_info;
448 } 459 }
449 } 460 }
450 } 461 }
451 462
452 } // namespace dart 463 } // namespace dart
453 464
454 #endif // defined(DART_USE_TCMALLOC) && !defined(PRODUCT) && 465 #endif // defined(DART_USE_TCMALLOC) && !defined(PRODUCT) &&
455 // !defined(TARGET_ARCH_DBC) && !defined(HOST_OS_FUCHSIA) 466 // !defined(TARGET_ARCH_DBC) && !defined(HOST_OS_FUCHSIA)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698