| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/assert.h" | 5 #include "platform/assert.h" |
| 6 | 6 |
| 7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #include "vm/profiler.h" | 10 #include "vm/profiler.h" |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 Profile profile(isolate); | 309 Profile profile(isolate); |
| 310 AllocationFilter filter(isolate->main_port(), class_a.id(), | 310 AllocationFilter filter(isolate->main_port(), class_a.id(), |
| 311 Dart_TimelineGetMicros(), 16000); | 311 Dart_TimelineGetMicros(), 16000); |
| 312 profile.Build(thread, &filter, Profile::kNoTags); | 312 profile.Build(thread, &filter, Profile::kNoTags); |
| 313 // We should have no allocation samples because none occured within | 313 // We should have no allocation samples because none occured within |
| 314 // the specified time range. | 314 // the specified time range. |
| 315 EXPECT_EQ(0, profile.sample_count()); | 315 EXPECT_EQ(0, profile.sample_count()); |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 | 318 |
| 319 #if defined(DART_USE_TCMALLOC) && defined(HOST_OS_LINUX) && defined(DEBUG) && \ |
| 320 defined(HOST_ARCH_x64) |
| 319 | 321 |
| 320 DART_NOINLINE static void NativeAllocationSampleHelper(char** result) { | 322 DART_NOINLINE static void NativeAllocationSampleHelper(char** result) { |
| 321 ASSERT(result != NULL); | 323 ASSERT(result != NULL); |
| 322 *result = static_cast<char*>(malloc(sizeof(char) * 1024)); | 324 *result = static_cast<char*>(malloc(sizeof(char) * 1024)); |
| 323 } | 325 } |
| 324 | 326 |
| 325 | 327 |
| 326 ISOLATE_UNIT_TEST_CASE(Profiler_NativeAllocation) { | 328 ISOLATE_UNIT_TEST_CASE(Profiler_NativeAllocation) { |
| 327 bool enable_malloc_hooks_saved = FLAG_enable_malloc_hooks; | 329 bool enable_malloc_hooks_saved = FLAG_enable_malloc_hooks; |
| 328 FLAG_enable_malloc_hooks = true; | 330 FLAG_enable_malloc_hooks = true; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 // We should have no allocation samples because none occured within | 517 // We should have no allocation samples because none occured within |
| 516 // the specified time range. | 518 // the specified time range. |
| 517 EXPECT_EQ(0, profile.sample_count()); | 519 EXPECT_EQ(0, profile.sample_count()); |
| 518 } | 520 } |
| 519 | 521 |
| 520 MallocHooks::set_stack_trace_collection_enabled( | 522 MallocHooks::set_stack_trace_collection_enabled( |
| 521 stack_trace_collection_enabled); | 523 stack_trace_collection_enabled); |
| 522 MallocHooks::TearDown(); | 524 MallocHooks::TearDown(); |
| 523 FLAG_enable_malloc_hooks = enable_malloc_hooks_saved; | 525 FLAG_enable_malloc_hooks = enable_malloc_hooks_saved; |
| 524 } | 526 } |
| 527 #endif // defined(DART_USE_TCMALLOC) && !defined(PRODUCT) && |
| 528 // !defined(TARGET_ARCH_DBC) && !defined(HOST_OS_FUCHSIA) |
| 525 | 529 |
| 526 | 530 |
| 527 TEST_CASE(Profiler_ToggleRecordAllocation) { | 531 TEST_CASE(Profiler_ToggleRecordAllocation) { |
| 528 DisableNativeProfileScope dnps; | 532 DisableNativeProfileScope dnps; |
| 529 const char* kScript = | 533 const char* kScript = |
| 530 "class A {\n" | 534 "class A {\n" |
| 531 " var a;\n" | 535 " var a;\n" |
| 532 " var b;\n" | 536 " var b;\n" |
| 533 "}\n" | 537 "}\n" |
| 534 "class B {\n" | 538 "class B {\n" |
| (...skipping 2266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2801 EXPECT_SUBSTRING("\"positions\":[\"TempMove\",39]", js.ToCString()); | 2805 EXPECT_SUBSTRING("\"positions\":[\"TempMove\",39]", js.ToCString()); |
| 2802 // Verify exclusive ticks in main. | 2806 // Verify exclusive ticks in main. |
| 2803 EXPECT_SUBSTRING("\"exclusiveTicks\":[1,0]", js.ToCString()); | 2807 EXPECT_SUBSTRING("\"exclusiveTicks\":[1,0]", js.ToCString()); |
| 2804 // Verify inclusive ticks in main. | 2808 // Verify inclusive ticks in main. |
| 2805 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString()); | 2809 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString()); |
| 2806 } | 2810 } |
| 2807 | 2811 |
| 2808 #endif // !PRODUCT | 2812 #endif // !PRODUCT |
| 2809 | 2813 |
| 2810 } // namespace dart | 2814 } // namespace dart |
| OLD | NEW |