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