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/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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 (time_extent_micros_ == -1)) { | 300 (time_extent_micros_ == -1)) { |
301 // No time filter passed in, always pass. | 301 // No time filter passed in, always pass. |
302 return true; | 302 return true; |
303 } | 303 } |
304 const int64_t timestamp = sample->timestamp(); | 304 const int64_t timestamp = sample->timestamp(); |
305 int64_t delta = timestamp - time_origin_micros_; | 305 int64_t delta = timestamp - time_origin_micros_; |
306 return (delta >= 0) && (delta <= time_extent_micros_); | 306 return (delta >= 0) && (delta <= time_extent_micros_); |
307 } | 307 } |
308 | 308 |
309 | 309 |
| 310 bool SampleFilter::TaskFilterSample(Sample* sample) { |
| 311 const intptr_t task = static_cast<intptr_t>(sample->thread_task()); |
| 312 return (task & thread_task_mask_) != 0; |
| 313 } |
| 314 |
| 315 |
310 ClearProfileVisitor::ClearProfileVisitor(Isolate* isolate) | 316 ClearProfileVisitor::ClearProfileVisitor(Isolate* isolate) |
311 : SampleVisitor(isolate) { | 317 : SampleVisitor(isolate) { |
312 } | 318 } |
313 | 319 |
314 | 320 |
315 void ClearProfileVisitor::VisitSample(Sample* sample) { | 321 void ClearProfileVisitor::VisitSample(Sample* sample) { |
316 sample->Clear(); | 322 sample->Clear(); |
317 } | 323 } |
318 | 324 |
319 | 325 |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 // When running in the simulator, the runtime entry function address | 843 // When running in the simulator, the runtime entry function address |
838 // (stored as the vm tag) is the address of a redirect function. | 844 // (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. | 845 // Attempt to find the real runtime entry function address and use that. |
840 uword redirect_vm_tag = Simulator::FunctionForRedirect(vm_tag); | 846 uword redirect_vm_tag = Simulator::FunctionForRedirect(vm_tag); |
841 if (redirect_vm_tag != 0) { | 847 if (redirect_vm_tag != 0) { |
842 vm_tag = redirect_vm_tag; | 848 vm_tag = redirect_vm_tag; |
843 } | 849 } |
844 #endif | 850 #endif |
845 sample->set_vm_tag(vm_tag); | 851 sample->set_vm_tag(vm_tag); |
846 sample->set_user_tag(isolate->user_tag()); | 852 sample->set_user_tag(isolate->user_tag()); |
847 // TODO(rmacnak): Consider tracking the current Task kind so the profiler | 853 sample->set_thread_task(thread->task_kind()); |
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()); | |
851 return sample; | 854 return sample; |
852 } | 855 } |
853 | 856 |
854 | 857 |
855 static bool CheckIsolate(Isolate* isolate) { | 858 static bool CheckIsolate(Isolate* isolate) { |
856 if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) { | 859 if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) { |
857 // No isolate. | 860 // No isolate. |
858 return false; | 861 return false; |
859 } | 862 } |
860 return isolate != Dart::vm_isolate(); | 863 return isolate != Dart::vm_isolate(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 } | 985 } |
983 | 986 |
984 if (!InitialRegisterCheck(pc, fp, sp)) { | 987 if (!InitialRegisterCheck(pc, fp, sp)) { |
985 return; | 988 return; |
986 } | 989 } |
987 | 990 |
988 if (!CheckIsolate(isolate)) { | 991 if (!CheckIsolate(isolate)) { |
989 return; | 992 return; |
990 } | 993 } |
991 | 994 |
| 995 // Thread is not doing VM work. |
| 996 if (thread->task_kind() == Thread::kUnknownTask) { |
| 997 return; |
| 998 } |
| 999 |
992 uword stack_lower = 0; | 1000 uword stack_lower = 0; |
993 uword stack_upper = 0; | 1001 uword stack_upper = 0; |
994 if (!GetAndValidateIsolateStackBounds(thread, | 1002 if (!GetAndValidateIsolateStackBounds(thread, |
995 fp, | 1003 fp, |
996 sp, | 1004 sp, |
997 &stack_lower, | 1005 &stack_lower, |
998 &stack_upper)) { | 1006 &stack_upper)) { |
999 // Could not get stack boundary. | 1007 // Could not get stack boundary. |
1000 return; | 1008 return; |
1001 } | 1009 } |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 continue; | 1224 continue; |
1217 } | 1225 } |
1218 if (sample->At(0) == 0) { | 1226 if (sample->At(0) == 0) { |
1219 // No frames. | 1227 // No frames. |
1220 continue; | 1228 continue; |
1221 } | 1229 } |
1222 if (!filter->TimeFilterSample(sample)) { | 1230 if (!filter->TimeFilterSample(sample)) { |
1223 // Did not pass time filter. | 1231 // Did not pass time filter. |
1224 continue; | 1232 continue; |
1225 } | 1233 } |
| 1234 if (!filter->TaskFilterSample(sample)) { |
| 1235 // Did not pass task filter. |
| 1236 continue; |
| 1237 } |
1226 if (!filter->FilterSample(sample)) { | 1238 if (!filter->FilterSample(sample)) { |
1227 // Did not pass filter. | 1239 // Did not pass filter. |
1228 continue; | 1240 continue; |
1229 } | 1241 } |
1230 buffer->Add(BuildProcessedSample(sample, buffer->code_lookup_table())); | 1242 buffer->Add(BuildProcessedSample(sample, buffer->code_lookup_table())); |
1231 } | 1243 } |
1232 return buffer; | 1244 return buffer; |
1233 } | 1245 } |
1234 | 1246 |
1235 | 1247 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 | 1392 |
1381 | 1393 |
1382 ProcessedSampleBuffer::ProcessedSampleBuffer() | 1394 ProcessedSampleBuffer::ProcessedSampleBuffer() |
1383 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { | 1395 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { |
1384 ASSERT(code_lookup_table_ != NULL); | 1396 ASSERT(code_lookup_table_ != NULL); |
1385 } | 1397 } |
1386 | 1398 |
1387 #endif // !PRODUCT | 1399 #endif // !PRODUCT |
1388 | 1400 |
1389 } // namespace dart | 1401 } // namespace dart |
OLD | NEW |