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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 return true; | 309 return true; |
310 } | 310 } |
311 const int64_t timestamp = sample->timestamp(); | 311 const int64_t timestamp = sample->timestamp(); |
312 int64_t delta = timestamp - time_origin_micros_; | 312 int64_t delta = timestamp - time_origin_micros_; |
313 return (delta >= 0) && (delta <= time_extent_micros_); | 313 return (delta >= 0) && (delta <= time_extent_micros_); |
314 } | 314 } |
315 | 315 |
316 | 316 |
317 bool SampleFilter::TaskFilterSample(Sample* sample) { | 317 bool SampleFilter::TaskFilterSample(Sample* sample) { |
318 const intptr_t task = static_cast<intptr_t>(sample->thread_task()); | 318 const intptr_t task = static_cast<intptr_t>(sample->thread_task()); |
| 319 if (thread_task_mask_ == kNoTaskFilter) { |
| 320 return true; |
| 321 } |
319 return (task & thread_task_mask_) != 0; | 322 return (task & thread_task_mask_) != 0; |
320 } | 323 } |
321 | 324 |
322 | 325 |
323 ClearProfileVisitor::ClearProfileVisitor(Isolate* isolate) | 326 ClearProfileVisitor::ClearProfileVisitor(Isolate* isolate) |
324 : SampleVisitor(isolate->main_port()) {} | 327 : SampleVisitor(isolate->main_port()) {} |
325 | 328 |
326 | 329 |
327 void ClearProfileVisitor::VisitSample(Sample* sample) { | 330 void ClearProfileVisitor::VisitSample(Sample* sample) { |
328 sample->Clear(); | 331 sample->Clear(); |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 sample->set_user_tag(isolate->user_tag()); | 934 sample->set_user_tag(isolate->user_tag()); |
932 sample->set_thread_task(thread->task_kind()); | 935 sample->set_thread_task(thread->task_kind()); |
933 return sample; | 936 return sample; |
934 } | 937 } |
935 | 938 |
936 | 939 |
937 static Sample* SetupSampleNative(SampleBuffer* sample_buffer, ThreadId tid) { | 940 static Sample* SetupSampleNative(SampleBuffer* sample_buffer, ThreadId tid) { |
938 Sample* sample = sample_buffer->ReserveSample(); | 941 Sample* sample = sample_buffer->ReserveSample(); |
939 sample->Init(ILLEGAL_PORT, OS::GetCurrentMonotonicMicros(), tid); | 942 sample->Init(ILLEGAL_PORT, OS::GetCurrentMonotonicMicros(), tid); |
940 sample->set_is_native_allocation_sample(true); | 943 sample->set_is_native_allocation_sample(true); |
941 | |
942 Thread* thread = Thread::Current(); | 944 Thread* thread = Thread::Current(); |
943 | 945 |
944 // TODO(bkonyi) Any samples created while a current thread doesn't exist are | 946 // Note: setting thread task in order to be consistent with other samples. The |
945 // ignored by the NativeAllocationSampleFilter since the default task is | 947 // task kind is not used by NativeAllocationSampleFilter for filtering |
946 // kUnknownTask. Is this what we want to do? | 948 // purposes as some samples may be collected when no thread exists. |
947 if (thread != NULL) { | 949 if (thread != NULL) { |
948 sample->set_thread_task(thread->task_kind()); | 950 sample->set_thread_task(thread->task_kind()); |
949 } | 951 } |
950 return sample; | 952 return sample; |
951 } | 953 } |
952 | 954 |
953 | 955 |
954 static bool CheckIsolate(Isolate* isolate) { | 956 static bool CheckIsolate(Isolate* isolate) { |
955 if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) { | 957 if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) { |
956 // No isolate. | 958 // No isolate. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 } else { | 1087 } else { |
1086 // Fall back. | 1088 // Fall back. |
1087 uintptr_t pc = OS::GetProgramCounter(); | 1089 uintptr_t pc = OS::GetProgramCounter(); |
1088 Sample* sample = SetupSample(thread, sample_buffer, os_thread->trace_id()); | 1090 Sample* sample = SetupSample(thread, sample_buffer, os_thread->trace_id()); |
1089 sample->SetAllocationCid(cid); | 1091 sample->SetAllocationCid(cid); |
1090 sample->SetAt(0, pc); | 1092 sample->SetAt(0, pc); |
1091 } | 1093 } |
1092 } | 1094 } |
1093 | 1095 |
1094 | 1096 |
1095 Sample* Profiler::SampleNativeAllocation(intptr_t skip_count) { | 1097 Sample* Profiler::SampleNativeAllocation(intptr_t skip_count, |
| 1098 uword address, |
| 1099 uintptr_t allocation_size) { |
1096 SampleBuffer* sample_buffer = Profiler::sample_buffer(); | 1100 SampleBuffer* sample_buffer = Profiler::sample_buffer(); |
1097 if (sample_buffer == NULL) { | 1101 if (sample_buffer == NULL) { |
1098 return NULL; | 1102 return NULL; |
1099 } | 1103 } |
1100 | 1104 |
1101 uintptr_t sp = Thread::GetCurrentStackPointer(); | 1105 uintptr_t sp = Thread::GetCurrentStackPointer(); |
1102 uintptr_t fp = 0; | 1106 uintptr_t fp = 0; |
1103 uintptr_t pc = OS::GetProgramCounter(); | 1107 uintptr_t pc = OS::GetProgramCounter(); |
1104 | 1108 |
1105 COPY_FP_REGISTER(fp); | 1109 COPY_FP_REGISTER(fp); |
1106 | 1110 |
1107 uword stack_lower = 0; | 1111 uword stack_lower = 0; |
1108 uword stack_upper = 0; | 1112 uword stack_upper = 0; |
1109 if (!InitialRegisterCheck(pc, fp, sp)) { | 1113 if (!InitialRegisterCheck(pc, fp, sp)) { |
1110 AtomicOperations::IncrementInt64By( | 1114 AtomicOperations::IncrementInt64By( |
1111 &counters_.failure_native_allocation_sample, 1); | 1115 &counters_.failure_native_allocation_sample, 1); |
1112 return NULL; | 1116 return NULL; |
1113 } | 1117 } |
1114 | 1118 |
1115 if (!(OSThread::GetCurrentStackBounds(&stack_lower, &stack_upper) && | 1119 if (!(OSThread::GetCurrentStackBounds(&stack_lower, &stack_upper) && |
1116 ValidateThreadStackBounds(fp, sp, stack_lower, stack_upper))) { | 1120 ValidateThreadStackBounds(fp, sp, stack_lower, stack_upper))) { |
1117 // Could not get stack boundary. | 1121 // Could not get stack boundary. |
1118 AtomicOperations::IncrementInt64By( | 1122 AtomicOperations::IncrementInt64By( |
1119 &counters_.failure_native_allocation_sample, 1); | 1123 &counters_.failure_native_allocation_sample, 1); |
1120 return NULL; | 1124 return NULL; |
1121 } | 1125 } |
1122 | 1126 |
1123 OSThread* os_thread = OSThread::Current(); | 1127 OSThread* os_thread = OSThread::Current(); |
1124 Sample* sample = SetupSampleNative(sample_buffer, os_thread->trace_id()); | 1128 Sample* sample = SetupSampleNative(sample_buffer, os_thread->trace_id()); |
| 1129 sample->set_native_allocation_address(address); |
| 1130 sample->set_native_allocation_size_bytes(allocation_size); |
| 1131 |
1125 ProfilerNativeStackWalker native_stack_walker( | 1132 ProfilerNativeStackWalker native_stack_walker( |
1126 ILLEGAL_PORT, sample, sample_buffer, stack_lower, stack_upper, pc, fp, sp, | 1133 ILLEGAL_PORT, sample, sample_buffer, stack_lower, stack_upper, pc, fp, sp, |
1127 skip_count); | 1134 skip_count); |
| 1135 |
1128 native_stack_walker.walk(); | 1136 native_stack_walker.walk(); |
1129 return sample; | 1137 return sample; |
1130 } | 1138 } |
1131 | 1139 |
1132 | 1140 |
1133 void Profiler::SampleThreadSingleFrame(Thread* thread, uintptr_t pc) { | 1141 void Profiler::SampleThreadSingleFrame(Thread* thread, uintptr_t pc) { |
1134 ASSERT(thread != NULL); | 1142 ASSERT(thread != NULL); |
1135 OSThread* os_thread = thread->os_thread(); | 1143 OSThread* os_thread = thread->os_thread(); |
1136 ASSERT(os_thread != NULL); | 1144 ASSERT(os_thread != NULL); |
1137 Isolate* isolate = thread->isolate(); | 1145 Isolate* isolate = thread->isolate(); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 | 1458 |
1451 ProcessedSample* SampleBuffer::BuildProcessedSample( | 1459 ProcessedSample* SampleBuffer::BuildProcessedSample( |
1452 Sample* sample, | 1460 Sample* sample, |
1453 const CodeLookupTable& clt) { | 1461 const CodeLookupTable& clt) { |
1454 Thread* thread = Thread::Current(); | 1462 Thread* thread = Thread::Current(); |
1455 Zone* zone = thread->zone(); | 1463 Zone* zone = thread->zone(); |
1456 | 1464 |
1457 ProcessedSample* processed_sample = new (zone) ProcessedSample(); | 1465 ProcessedSample* processed_sample = new (zone) ProcessedSample(); |
1458 | 1466 |
1459 // Copy state bits from sample. | 1467 // Copy state bits from sample. |
| 1468 processed_sample->set_native_allocation_size_bytes( |
| 1469 sample->native_allocation_size_bytes()); |
1460 processed_sample->set_timestamp(sample->timestamp()); | 1470 processed_sample->set_timestamp(sample->timestamp()); |
1461 processed_sample->set_tid(sample->tid()); | 1471 processed_sample->set_tid(sample->tid()); |
1462 processed_sample->set_vm_tag(sample->vm_tag()); | 1472 processed_sample->set_vm_tag(sample->vm_tag()); |
1463 processed_sample->set_user_tag(sample->user_tag()); | 1473 processed_sample->set_user_tag(sample->user_tag()); |
1464 if (sample->is_allocation_sample()) { | 1474 if (sample->is_allocation_sample()) { |
1465 processed_sample->set_allocation_cid(sample->allocation_cid()); | 1475 processed_sample->set_allocation_cid(sample->allocation_cid()); |
1466 } | 1476 } |
1467 processed_sample->set_first_frame_executing(!sample->exit_frame_sample()); | 1477 processed_sample->set_first_frame_executing(!sample->exit_frame_sample()); |
1468 | 1478 |
1469 // Copy stack trace from sample(s). | 1479 // Copy stack trace from sample(s). |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 | 1602 |
1593 | 1603 |
1594 ProcessedSampleBuffer::ProcessedSampleBuffer() | 1604 ProcessedSampleBuffer::ProcessedSampleBuffer() |
1595 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { | 1605 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { |
1596 ASSERT(code_lookup_table_ != NULL); | 1606 ASSERT(code_lookup_table_ != NULL); |
1597 } | 1607 } |
1598 | 1608 |
1599 #endif // !PRODUCT | 1609 #endif // !PRODUCT |
1600 | 1610 |
1601 } // namespace dart | 1611 } // namespace dart |
OLD | NEW |