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

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

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

Powered by Google App Engine
This is Rietveld 408576698