OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "vm/code_observers.h" | 5 #include "vm/code_observers.h" |
6 | 6 |
7 #include "vm/dart.h" | 7 #include "vm/dart.h" |
8 #include "vm/debuginfo.h" | 8 #include "vm/debuginfo.h" |
9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 for (intptr_t i = 0; i < observers_length_; i++) { | 50 for (intptr_t i = 0; i < observers_length_; i++) { |
51 if (observers_[i]->IsActive()) return true; | 51 if (observers_[i]->IsActive()) return true; |
52 } | 52 } |
53 return false; | 53 return false; |
54 } | 54 } |
55 | 55 |
56 | 56 |
57 class PerfCodeObserver : public CodeObserver { | 57 class PerfCodeObserver : public CodeObserver { |
58 public: | 58 public: |
59 virtual bool IsActive() const { | 59 virtual bool IsActive() const { |
60 return Dart::perf_events_writer() != NULL; | 60 return Dart::perf_events_file() != NULL; |
61 } | 61 } |
62 | 62 |
63 virtual void Notify(const char* name, | 63 virtual void Notify(const char* name, |
64 uword base, | 64 uword base, |
65 uword prologue_offset, | 65 uword prologue_offset, |
66 uword size, | 66 uword size, |
67 bool optimized) { | 67 bool optimized) { |
68 Dart_FileWriterFunction perf_events_writer = Dart::perf_events_writer(); | |
69 ASSERT(perf_events_writer != NULL); | |
70 | |
71 const char* format = "%"Px" %"Px" %s%s\n"; | 68 const char* format = "%"Px" %"Px" %s%s\n"; |
72 const char* marker = optimized ? "*" : ""; | 69 const char* marker = optimized ? "*" : ""; |
73 intptr_t len = OS::SNPrint(NULL, 0, format, base, size, marker, name); | 70 intptr_t len = OS::SNPrint(NULL, 0, format, base, size, marker, name); |
74 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 71 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1); |
75 OS::SNPrint(buffer, len + 1, format, base, size, marker, name); | 72 OS::SNPrint(buffer, len + 1, format, base, size, marker, name); |
76 (*perf_events_writer)(buffer, len); | 73 Dart_FileWriteCallback file_write = Isolate::file_write_callback(); |
| 74 ASSERT(file_write != NULL); |
| 75 void* file = Dart::perf_events_file(); |
| 76 ASSERT(file != NULL); |
| 77 (*file_write)(buffer, len, file); |
77 } | 78 } |
78 }; | 79 }; |
79 | 80 |
80 | 81 |
81 class PprofCodeObserver : public CodeObserver { | 82 class PprofCodeObserver : public CodeObserver { |
82 public: | 83 public: |
83 virtual bool IsActive() const { | 84 virtual bool IsActive() const { |
84 return Dart::pprof_symbol_generator() != NULL; | 85 return Dart::pprof_symbol_generator() != NULL; |
85 } | 86 } |
86 | 87 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 Register(new PerfCodeObserver); | 134 Register(new PerfCodeObserver); |
134 Register(new PprofCodeObserver); | 135 Register(new PprofCodeObserver); |
135 Register(new GdbCodeObserver); | 136 Register(new GdbCodeObserver); |
136 #if defined(DART_VTUNE_SUPPORT) | 137 #if defined(DART_VTUNE_SUPPORT) |
137 Register(new VTuneCodeObserver); | 138 Register(new VTuneCodeObserver); |
138 #endif | 139 #endif |
139 } | 140 } |
140 | 141 |
141 | 142 |
142 } // namespace dart | 143 } // namespace dart |
OLD | NEW |