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

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

Issue 1814813003: Collect samples for background threads. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 | « runtime/vm/profiler.h ('k') | runtime/vm/profiler_service.cc » ('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 (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/address_sanitizer.h" 5 #include "platform/address_sanitizer.h"
6 #include "platform/memory_sanitizer.h" 6 #include "platform/memory_sanitizer.h"
7 #include "platform/utils.h" 7 #include "platform/utils.h"
8 8
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/atomic.h" 10 #include "vm/atomic.h"
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 // When running in the simulator, the runtime entry function address 837 // When running in the simulator, the runtime entry function address
838 // (stored as the vm tag) is the address of a redirect function. 838 // (stored as the vm tag) is the address of a redirect function.
839 // Attempt to find the real runtime entry function address and use that. 839 // Attempt to find the real runtime entry function address and use that.
840 uword redirect_vm_tag = Simulator::FunctionForRedirect(vm_tag); 840 uword redirect_vm_tag = Simulator::FunctionForRedirect(vm_tag);
841 if (redirect_vm_tag != 0) { 841 if (redirect_vm_tag != 0) {
842 vm_tag = redirect_vm_tag; 842 vm_tag = redirect_vm_tag;
843 } 843 }
844 #endif 844 #endif
845 sample->set_vm_tag(vm_tag); 845 sample->set_vm_tag(vm_tag);
846 sample->set_user_tag(isolate->user_tag()); 846 sample->set_user_tag(isolate->user_tag());
847 // TODO(rmacnak): Consider tracking the current Task kind so the profiler
848 // can say the program spent x% of cpu time in the main thread, GC,
849 // background compilation, etc.
850 sample->set_is_mutator_thread(thread->IsMutatorThread());
847 return sample; 851 return sample;
848 } 852 }
849 853
850 854
851 static bool CheckIsolate(Isolate* isolate) { 855 static bool CheckIsolate(Isolate* isolate) {
852 if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) { 856 if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) {
853 // No isolate. 857 // No isolate.
854 return false; 858 return false;
855 } 859 }
856 return isolate != Dart::vm_isolate(); 860 return isolate != Dart::vm_isolate();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 } 982 }
979 983
980 if (!InitialRegisterCheck(pc, fp, sp)) { 984 if (!InitialRegisterCheck(pc, fp, sp)) {
981 return; 985 return;
982 } 986 }
983 987
984 if (!CheckIsolate(isolate)) { 988 if (!CheckIsolate(isolate)) {
985 return; 989 return;
986 } 990 }
987 991
988 if (!thread->IsMutatorThread()) {
989 // Not a mutator thread.
990 // TODO(johnmccutchan): Profile all threads with an isolate.
991 return;
992 }
993
994 uword stack_lower = 0; 992 uword stack_lower = 0;
995 uword stack_upper = 0; 993 uword stack_upper = 0;
996 if (!GetAndValidateIsolateStackBounds(thread, 994 if (!GetAndValidateIsolateStackBounds(thread,
997 fp, 995 fp,
998 sp, 996 sp,
999 &stack_lower, 997 &stack_lower,
1000 &stack_upper)) { 998 &stack_upper)) {
1001 // Could not get stack boundary. 999 // Could not get stack boundary.
1002 return; 1000 return;
1003 } 1001 }
1004 1002
1005 // At this point we have a valid stack boundary for this isolate and 1003 // At this point we have a valid stack boundary for this isolate and
1006 // know that our initial stack and frame pointers are within the boundary. 1004 // know that our initial stack and frame pointers are within the boundary.
1007 SampleBuffer* sample_buffer = Profiler::sample_buffer(); 1005 SampleBuffer* sample_buffer = Profiler::sample_buffer();
1008 if (sample_buffer == NULL) { 1006 if (sample_buffer == NULL) {
1009 // Profiler not initialized. 1007 // Profiler not initialized.
1010 return; 1008 return;
1011 } 1009 }
1012 1010
1013 // Setup sample. 1011 // Setup sample.
1014 Sample* sample = SetupSample(thread, sample_buffer, os_thread->trace_id()); 1012 Sample* sample = SetupSample(thread, sample_buffer, os_thread->trace_id());
1015 // Increment counter for vm tag. 1013 // Increment counter for vm tag.
1016 VMTagCounters* counters = isolate->vm_tag_counters(); 1014 VMTagCounters* counters = isolate->vm_tag_counters();
1017 ASSERT(counters != NULL); 1015 ASSERT(counters != NULL);
1018 counters->Increment(sample->vm_tag()); 1016 if (thread->IsMutatorThread()) {
1017 counters->Increment(sample->vm_tag());
1018 }
1019 1019
1020 ProfilerNativeStackWalker native_stack_walker(isolate, 1020 ProfilerNativeStackWalker native_stack_walker(isolate,
1021 sample, 1021 sample,
1022 sample_buffer, 1022 sample_buffer,
1023 stack_lower, 1023 stack_lower,
1024 stack_upper, 1024 stack_upper,
1025 pc, 1025 pc,
1026 fp, 1026 fp,
1027 sp); 1027 sp);
1028 1028
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 1380
1381 1381
1382 ProcessedSampleBuffer::ProcessedSampleBuffer() 1382 ProcessedSampleBuffer::ProcessedSampleBuffer()
1383 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { 1383 : code_lookup_table_(new CodeLookupTable(Thread::Current())) {
1384 ASSERT(code_lookup_table_ != NULL); 1384 ASSERT(code_lookup_table_ != NULL);
1385 } 1385 }
1386 1386
1387 #endif // !PRODUCT 1387 #endif // !PRODUCT
1388 1388
1389 } // namespace dart 1389 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/profiler.h ('k') | runtime/vm/profiler_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698