OLD | NEW |
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) && !defined(TARGET_ARCH_DBC) | 7 #if defined(DART_USE_TCMALLOC) && !defined(PRODUCT) && !defined(TARGET_ARCH_DBC) |
8 | 8 |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 for (uintptr_t i = 0; i < size; ++i) { | 23 for (uintptr_t i = 0; i < size; ++i) { |
24 buffer[i] = i; | 24 buffer[i] = i; |
25 } | 25 } |
26 } | 26 } |
27 | 27 |
28 class EnableMallocHooksScope : public ValueObject { | 28 class EnableMallocHooksScope : public ValueObject { |
29 public: | 29 public: |
30 EnableMallocHooksScope() { | 30 EnableMallocHooksScope() { |
31 saved_enable_malloc_hooks_ = FLAG_profiler_native_memory; | 31 saved_enable_malloc_hooks_ = FLAG_profiler_native_memory; |
32 FLAG_profiler_native_memory = true; | 32 FLAG_profiler_native_memory = true; |
33 Profiler::InitAllocationSampleBuffer(); | |
34 MallocHooks::InitOnce(); | 33 MallocHooks::InitOnce(); |
35 MallocHooks::ResetStats(); | 34 MallocHooks::ResetStats(); |
36 } | 35 } |
37 | 36 |
38 ~EnableMallocHooksScope() { | 37 ~EnableMallocHooksScope() { |
39 MallocHooks::TearDown(); | 38 MallocHooks::TearDown(); |
40 FLAG_profiler_native_memory = saved_enable_malloc_hooks_; | 39 FLAG_profiler_native_memory = saved_enable_malloc_hooks_; |
41 } | 40 } |
42 | 41 |
43 private: | 42 private: |
44 bool saved_enable_malloc_hooks_; | 43 bool saved_enable_malloc_hooks_; |
45 }; | 44 }; |
46 | 45 |
47 class EnableMallocHooksAndStacksScope : public EnableMallocHooksScope { | 46 class EnableMallocHooksAndStacksScope : public EnableMallocHooksScope { |
48 public: | 47 public: |
49 EnableMallocHooksAndStacksScope() { | 48 EnableMallocHooksAndStacksScope() { |
50 saved_enable_stack_traces_ = MallocHooks::stack_trace_collection_enabled(); | 49 saved_enable_stack_traces_ = MallocHooks::stack_trace_collection_enabled(); |
51 MallocHooks::set_stack_trace_collection_enabled(true); | 50 MallocHooks::set_stack_trace_collection_enabled(true); |
52 if (!FLAG_profiler) { | 51 if (!FLAG_profiler) { |
53 FLAG_profiler = true; | 52 FLAG_profiler = true; |
54 Profiler::InitOnce(); | 53 Profiler::InitOnce(); |
55 } | 54 } |
| 55 MallocHooks::ResetStats(); |
56 } | 56 } |
57 | 57 |
58 ~EnableMallocHooksAndStacksScope() { | 58 ~EnableMallocHooksAndStacksScope() { |
59 MallocHooks::set_stack_trace_collection_enabled(saved_enable_stack_traces_); | 59 MallocHooks::set_stack_trace_collection_enabled(saved_enable_stack_traces_); |
60 } | 60 } |
61 | 61 |
62 private: | 62 private: |
63 bool saved_enable_stack_traces_; | 63 bool saved_enable_stack_traces_; |
64 }; | 64 }; |
65 | 65 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 EXPECT_SUBSTRING("\"dart::TestCase::Run()\"", json); | 190 EXPECT_SUBSTRING("\"dart::TestCase::Run()\"", json); |
191 EXPECT_SUBSTRING("\"dart::TestCaseBase::RunTest()\"", json); | 191 EXPECT_SUBSTRING("\"dart::TestCaseBase::RunTest()\"", json); |
192 EXPECT_SUBSTRING("\"main\"", json); | 192 EXPECT_SUBSTRING("\"main\"", json); |
193 | 193 |
194 free(var); | 194 free(var); |
195 } | 195 } |
196 | 196 |
197 }; // namespace dart | 197 }; // namespace dart |
198 | 198 |
199 #endif // defined(DART_USE_TCMALLOC) && !defined(PRODUCT) | 199 #endif // defined(DART_USE_TCMALLOC) && !defined(PRODUCT) |
OLD | NEW |