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

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

Issue 2778463002: Fixed missing method referenced when MallocHooks is unsupported. (Closed)
Patch Set: Fixed missing method referenced when MallocHooks is unsupported. 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/malloc_hooks_unsupported.cc ('k') | runtime/vm/profiler.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 #ifndef RUNTIME_VM_PROFILER_H_ 5 #ifndef RUNTIME_VM_PROFILER_H_
6 #define RUNTIME_VM_PROFILER_H_ 6 #define RUNTIME_VM_PROFILER_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/bitfield.h" 9 #include "vm/bitfield.h"
10 #include "vm/code_observers.h" 10 #include "vm/code_observers.h"
11 #include "vm/globals.h" 11 #include "vm/globals.h"
12 #include "vm/growable_array.h" 12 #include "vm/growable_array.h"
13 #include "vm/malloc_hooks.h"
13 #include "vm/object.h" 14 #include "vm/object.h"
14 #include "vm/tags.h" 15 #include "vm/tags.h"
15 #include "vm/thread_interrupter.h" 16 #include "vm/thread_interrupter.h"
16 17
17 // Profiler sampling and stack walking support. 18 // Profiler sampling and stack walking support.
18 // NOTE: For service related code, see profile_service.h. 19 // NOTE: For service related code, see profile_service.h.
19 20
20 namespace dart { 21 namespace dart {
21 22
22 // Forward declarations. 23 // Forward declarations.
(...skipping 30 matching lines...) Expand all
53 54
54 static void SetSampleDepth(intptr_t depth); 55 static void SetSampleDepth(intptr_t depth);
55 static void SetSamplePeriod(intptr_t period); 56 static void SetSamplePeriod(intptr_t period);
56 57
57 static SampleBuffer* sample_buffer() { return sample_buffer_; } 58 static SampleBuffer* sample_buffer() { return sample_buffer_; }
58 59
59 static void DumpStackTrace(void* context); 60 static void DumpStackTrace(void* context);
60 static void DumpStackTrace(); 61 static void DumpStackTrace();
61 62
62 static void SampleAllocation(Thread* thread, intptr_t cid); 63 static void SampleAllocation(Thread* thread, intptr_t cid);
63 static Sample* SampleNativeAllocation(intptr_t skip_count); 64 static Sample* SampleNativeAllocation(intptr_t skip_count,
65 uword address,
66 uintptr_t allocation_size);
64 67
65 // SampleThread is called from inside the signal handler and hence it is very 68 // SampleThread is called from inside the signal handler and hence it is very
66 // critical that the implementation of SampleThread does not do any of the 69 // critical that the implementation of SampleThread does not do any of the
67 // following: 70 // following:
68 // * Accessing TLS -- Because on Windows the callback will be running in a 71 // * Accessing TLS -- Because on Windows the callback will be running in a
69 // different thread. 72 // different thread.
70 // * Allocating memory -- Because this takes locks which may already be 73 // * Allocating memory -- Because this takes locks which may already be
71 // held, resulting in a dead lock. 74 // held, resulting in a dead lock.
72 // * Taking a lock -- See above. 75 // * Taking a lock -- See above.
73 static void SampleThread(Thread* thread, const InterruptedThreadState& state); 76 static void SampleThread(Thread* thread, const InterruptedThreadState& state);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 virtual bool FilterSample(Sample* sample) { return true; } 137 virtual bool FilterSample(Sample* sample) { return true; }
135 138
136 Dart_Port port() const { return port_; } 139 Dart_Port port() const { return port_; }
137 140
138 // Returns |true| if |sample| passes the time filter. 141 // Returns |true| if |sample| passes the time filter.
139 bool TimeFilterSample(Sample* sample); 142 bool TimeFilterSample(Sample* sample);
140 143
141 // Returns |true| if |sample| passes the thread task filter. 144 // Returns |true| if |sample| passes the thread task filter.
142 bool TaskFilterSample(Sample* sample); 145 bool TaskFilterSample(Sample* sample);
143 146
147 static const intptr_t kNoTaskFilter = -1;
148
144 private: 149 private:
145 Dart_Port port_; 150 Dart_Port port_;
146 intptr_t thread_task_mask_; 151 intptr_t thread_task_mask_;
147 int64_t time_origin_micros_; 152 int64_t time_origin_micros_;
148 int64_t time_extent_micros_; 153 int64_t time_extent_micros_;
149 }; 154 };
150 155
151 156
152 class ClearProfileVisitor : public SampleVisitor { 157 class ClearProfileVisitor : public SampleVisitor {
153 public: 158 public:
(...skipping 22 matching lines...) Expand all
176 port_ = ILLEGAL_PORT; 181 port_ = ILLEGAL_PORT;
177 pc_marker_ = 0; 182 pc_marker_ = 0;
178 for (intptr_t i = 0; i < kStackBufferSizeInWords; i++) { 183 for (intptr_t i = 0; i < kStackBufferSizeInWords; i++) {
179 stack_buffer_[i] = 0; 184 stack_buffer_[i] = 0;
180 } 185 }
181 vm_tag_ = VMTag::kInvalidTagId; 186 vm_tag_ = VMTag::kInvalidTagId;
182 user_tag_ = UserTags::kDefaultUserTag; 187 user_tag_ = UserTags::kDefaultUserTag;
183 lr_ = 0; 188 lr_ = 0;
184 metadata_ = 0; 189 metadata_ = 0;
185 state_ = 0; 190 state_ = 0;
191 native_allocation_address_ = 0;
192 native_allocation_size_bytes_ = 0;
186 continuation_index_ = -1; 193 continuation_index_ = -1;
187 uword* pcs = GetPCArray(); 194 uword* pcs = GetPCArray();
188 for (intptr_t i = 0; i < pcs_length_; i++) { 195 for (intptr_t i = 0; i < pcs_length_; i++) {
189 pcs[i] = 0; 196 pcs[i] = 0;
190 } 197 }
191 set_head_sample(true); 198 set_head_sample(true);
192 } 199 }
193 200
194 // Timestamp sample was taken at. 201 // Timestamp sample was taken at.
195 int64_t timestamp() const { return timestamp_; } 202 int64_t timestamp() const { return timestamp_; }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 279
273 bool is_native_allocation_sample() const { 280 bool is_native_allocation_sample() const {
274 return NativeAllocationSampleBit::decode(state_); 281 return NativeAllocationSampleBit::decode(state_);
275 } 282 }
276 283
277 void set_is_native_allocation_sample(bool native_allocation_sample) { 284 void set_is_native_allocation_sample(bool native_allocation_sample) {
278 state_ = 285 state_ =
279 NativeAllocationSampleBit::update(native_allocation_sample, state_); 286 NativeAllocationSampleBit::update(native_allocation_sample, state_);
280 } 287 }
281 288
289 void set_native_allocation_address(uword address) {
290 native_allocation_address_ = address;
291 }
292
293 uword native_allocation_address() const { return native_allocation_address_; }
294
295 uintptr_t native_allocation_size_bytes() const {
296 return native_allocation_size_bytes_;
297 }
298
299 void set_native_allocation_size_bytes(uintptr_t size) {
300 native_allocation_size_bytes_ = size;
301 }
302
282 Thread::TaskKind thread_task() const { return ThreadTaskBit::decode(state_); } 303 Thread::TaskKind thread_task() const { return ThreadTaskBit::decode(state_); }
283 304
284 void set_thread_task(Thread::TaskKind task) { 305 void set_thread_task(Thread::TaskKind task) {
285 state_ = ThreadTaskBit::update(task, state_); 306 state_ = ThreadTaskBit::update(task, state_);
286 } 307 }
287 308
288 bool is_continuation_sample() const { 309 bool is_continuation_sample() const {
289 return ContinuationSampleBit::decode(state_); 310 return ContinuationSampleBit::decode(state_);
290 } 311 }
291 312
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 int64_t timestamp_; 387 int64_t timestamp_;
367 ThreadId tid_; 388 ThreadId tid_;
368 Dart_Port port_; 389 Dart_Port port_;
369 uword pc_marker_; 390 uword pc_marker_;
370 uword stack_buffer_[kStackBufferSizeInWords]; 391 uword stack_buffer_[kStackBufferSizeInWords];
371 uword vm_tag_; 392 uword vm_tag_;
372 uword user_tag_; 393 uword user_tag_;
373 uword metadata_; 394 uword metadata_;
374 uword lr_; 395 uword lr_;
375 uword state_; 396 uword state_;
397 uword native_allocation_address_;
398 uintptr_t native_allocation_size_bytes_;
376 intptr_t continuation_index_; 399 intptr_t continuation_index_;
377 400
378 /* There are a variable number of words that follow, the words hold the 401 /* There are a variable number of words that follow, the words hold the
379 * sampled pc values. Access via GetPCArray() */ 402 * sampled pc values. Access via GetPCArray() */
380 403
381 DISALLOW_COPY_AND_ASSIGN(Sample); 404 DISALLOW_COPY_AND_ASSIGN(Sample);
382 }; 405 };
383 406
384 407
408 class NativeAllocationSampleFilter : public SampleFilter {
409 public:
410 NativeAllocationSampleFilter(int64_t time_origin_micros,
411 int64_t time_extent_micros)
412 : SampleFilter(ILLEGAL_PORT,
413 SampleFilter::kNoTaskFilter,
414 time_origin_micros,
415 time_extent_micros) {}
416
417 bool FilterSample(Sample* sample) {
418 if (!sample->is_native_allocation_sample()) {
419 return false;
420 }
421 // If the sample is an allocation sample, we need to check that the
422 // memory at the address hasn't been freed, and if the address associated
423 // with the allocation has been freed and then reissued.
424 void* alloc_address =
425 reinterpret_cast<void*>(sample->native_allocation_address());
426 Sample* recorded_sample = MallocHooks::GetSample(alloc_address);
427 return (sample == recorded_sample);
428 }
429 };
430
431
385 // A Code object descriptor. 432 // A Code object descriptor.
386 class CodeDescriptor : public ZoneAllocated { 433 class CodeDescriptor : public ZoneAllocated {
387 public: 434 public:
388 explicit CodeDescriptor(const Code& code); 435 explicit CodeDescriptor(const Code& code);
389 436
390 uword Start() const; 437 uword Start() const;
391 438
392 uword Size() const; 439 uword Size() const;
393 440
394 int64_t CompileTimestamp() const; 441 int64_t CompileTimestamp() const;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 // The user tag. 604 // The user tag.
558 uword user_tag() const { return user_tag_; } 605 uword user_tag() const { return user_tag_; }
559 void set_user_tag(uword tag) { user_tag_ = tag; } 606 void set_user_tag(uword tag) { user_tag_ = tag; }
560 607
561 // The class id if this is an allocation profile sample. -1 otherwise. 608 // The class id if this is an allocation profile sample. -1 otherwise.
562 intptr_t allocation_cid() const { return allocation_cid_; } 609 intptr_t allocation_cid() const { return allocation_cid_; }
563 void set_allocation_cid(intptr_t cid) { allocation_cid_ = cid; } 610 void set_allocation_cid(intptr_t cid) { allocation_cid_ = cid; }
564 611
565 bool IsAllocationSample() const { return allocation_cid_ > 0; } 612 bool IsAllocationSample() const { return allocation_cid_ > 0; }
566 613
614 bool is_native_allocation_sample() const {
615 return native_allocation_size_bytes_ != 0;
616 }
617
618 uintptr_t native_allocation_size_bytes() const {
619 return native_allocation_size_bytes_;
620 }
621 void set_native_allocation_size_bytes(uintptr_t allocation_size) {
622 native_allocation_size_bytes_ = allocation_size;
623 }
624
567 // Was the stack trace truncated? 625 // Was the stack trace truncated?
568 bool truncated() const { return truncated_; } 626 bool truncated() const { return truncated_; }
569 void set_truncated(bool truncated) { truncated_ = truncated; } 627 void set_truncated(bool truncated) { truncated_ = truncated; }
570 628
571 // Was the first frame in the stack trace executing? 629 // Was the first frame in the stack trace executing?
572 bool first_frame_executing() const { return first_frame_executing_; } 630 bool first_frame_executing() const { return first_frame_executing_; }
573 void set_first_frame_executing(bool first_frame_executing) { 631 void set_first_frame_executing(bool first_frame_executing) {
574 first_frame_executing_ = first_frame_executing; 632 first_frame_executing_ = first_frame_executing;
575 } 633 }
576 634
(...skipping 14 matching lines...) Expand all
591 uword* stack_buffer); 649 uword* stack_buffer);
592 650
593 ZoneGrowableArray<uword> pcs_; 651 ZoneGrowableArray<uword> pcs_;
594 int64_t timestamp_; 652 int64_t timestamp_;
595 ThreadId tid_; 653 ThreadId tid_;
596 uword vm_tag_; 654 uword vm_tag_;
597 uword user_tag_; 655 uword user_tag_;
598 intptr_t allocation_cid_; 656 intptr_t allocation_cid_;
599 bool truncated_; 657 bool truncated_;
600 bool first_frame_executing_; 658 bool first_frame_executing_;
659 uword native_allocation_address_;
660 uintptr_t native_allocation_size_bytes_;
601 ProfileTrieNode* timeline_trie_; 661 ProfileTrieNode* timeline_trie_;
602 662
603 friend class SampleBuffer; 663 friend class SampleBuffer;
604 DISALLOW_COPY_AND_ASSIGN(ProcessedSample); 664 DISALLOW_COPY_AND_ASSIGN(ProcessedSample);
605 }; 665 };
606 666
607 667
608 // A collection of |ProcessedSample|s. 668 // A collection of |ProcessedSample|s.
609 class ProcessedSampleBuffer : public ZoneAllocated { 669 class ProcessedSampleBuffer : public ZoneAllocated {
610 public: 670 public:
(...skipping 12 matching lines...) Expand all
623 private: 683 private:
624 ZoneGrowableArray<ProcessedSample*> samples_; 684 ZoneGrowableArray<ProcessedSample*> samples_;
625 CodeLookupTable* code_lookup_table_; 685 CodeLookupTable* code_lookup_table_;
626 686
627 DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer); 687 DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer);
628 }; 688 };
629 689
630 } // namespace dart 690 } // namespace dart
631 691
632 #endif // RUNTIME_VM_PROFILER_H_ 692 #endif // RUNTIME_VM_PROFILER_H_
OLDNEW
« no previous file with comments | « runtime/vm/malloc_hooks_unsupported.cc ('k') | runtime/vm/profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698