| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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_SERVICE_H_ | 5 #ifndef RUNTIME_VM_PROFILER_SERVICE_H_ |
| 6 #define RUNTIME_VM_PROFILER_SERVICE_H_ | 6 #define RUNTIME_VM_PROFILER_SERVICE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/code_observers.h" | 9 #include "vm/code_observers.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 const Code& code); | 164 const Code& code); |
| 165 | 165 |
| 166 Kind kind() const { return kind_; } | 166 Kind kind() const { return kind_; } |
| 167 | 167 |
| 168 uword start() const { return start_; } | 168 uword start() const { return start_; } |
| 169 void set_start(uword start) { start_ = start; } | 169 void set_start(uword start) { start_ = start; } |
| 170 | 170 |
| 171 uword end() const { return end_; } | 171 uword end() const { return end_; } |
| 172 void set_end(uword end) { end_ = end; } | 172 void set_end(uword end) { end_ = end; } |
| 173 | 173 |
| 174 void AdjustExtent(uword start, uword end); | 174 void ExpandLower(uword start); |
| 175 void ExpandUpper(uword end); |
| 176 void TruncateLower(uword start); |
| 177 void TruncateUpper(uword end); |
| 175 | 178 |
| 176 bool Contains(uword pc) const { return (pc >= start_) && (pc < end_); } | 179 bool Contains(uword pc) const { return (pc >= start_) && (pc < end_); } |
| 177 | 180 |
| 178 bool Overlaps(const ProfileCode* other) const; | 181 bool Overlaps(const ProfileCode* other) const; |
| 179 | 182 |
| 180 int64_t compile_timestamp() const { return compile_timestamp_; } | 183 int64_t compile_timestamp() const { return compile_timestamp_; } |
| 181 void set_compile_timestamp(int64_t timestamp) { | 184 void set_compile_timestamp(int64_t timestamp) { |
| 182 compile_timestamp_ = timestamp; | 185 compile_timestamp_ = timestamp; |
| 183 } | 186 } |
| 184 | 187 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 char* name_; | 235 char* name_; |
| 233 int64_t compile_timestamp_; | 236 int64_t compile_timestamp_; |
| 234 ProfileFunction* function_; | 237 ProfileFunction* function_; |
| 235 intptr_t code_table_index_; | 238 intptr_t code_table_index_; |
| 236 ZoneGrowableArray<ProfileCodeAddress> address_ticks_; | 239 ZoneGrowableArray<ProfileCodeAddress> address_ticks_; |
| 237 | 240 |
| 238 friend class ProfileBuilder; | 241 friend class ProfileBuilder; |
| 239 }; | 242 }; |
| 240 | 243 |
| 241 | 244 |
| 245 class ProfileCodeTable : public ZoneAllocated { |
| 246 public: |
| 247 ProfileCodeTable() : table_(8) {} |
| 248 |
| 249 intptr_t length() const { return table_.length(); } |
| 250 |
| 251 ProfileCode* At(intptr_t index) const { |
| 252 ASSERT(index >= 0); |
| 253 ASSERT(index < length()); |
| 254 return table_[index]; |
| 255 } |
| 256 |
| 257 // Find the table index to the ProfileCode containing pc. |
| 258 // Returns < 0 if not found. |
| 259 intptr_t FindCodeIndexForPC(uword pc) const; |
| 260 |
| 261 ProfileCode* FindCodeForPC(uword pc) const { |
| 262 intptr_t index = FindCodeIndexForPC(pc); |
| 263 if (index < 0) { |
| 264 return NULL; |
| 265 } |
| 266 return At(index); |
| 267 } |
| 268 |
| 269 // Insert |new_code| into the table. Returns the table index where |new_code| |
| 270 // was inserted. Will merge with an overlapping ProfileCode if one is present. |
| 271 intptr_t InsertCode(ProfileCode* new_code); |
| 272 |
| 273 private: |
| 274 void FindNeighbors(uword pc, |
| 275 intptr_t* lo, |
| 276 intptr_t* hi, |
| 277 ProfileCode** lo_code, |
| 278 ProfileCode** hi_code) const; |
| 279 |
| 280 void VerifyOrder(); |
| 281 void VerifyOverlap(); |
| 282 |
| 283 ZoneGrowableArray<ProfileCode*> table_; |
| 284 }; |
| 285 |
| 286 |
| 242 // Stack traces are organized in a trie. This holds information about one node | 287 // Stack traces are organized in a trie. This holds information about one node |
| 243 // in the trie. A node in a tree represents a stack frame and a path in the tree | 288 // in the trie. A node in a tree represents a stack frame and a path in the tree |
| 244 // represents a stack trace. Each unique stack trace appears in the tree once | 289 // represents a stack trace. Each unique stack trace appears in the tree once |
| 245 // and each node has a count indicating how many times this has been observed. | 290 // and each node has a count indicating how many times this has been observed. |
| 246 // The index can be used to look up a |ProfileFunction| or |ProfileCode|. | 291 // The index can be used to look up a |ProfileFunction| or |ProfileCode|. |
| 247 // A node can have zero or more children. Depending on the kind of trie the | 292 // A node can have zero or more children. Depending on the kind of trie the |
| 248 // children are callers or callees of the current node. | 293 // children are callers or callees of the current node. |
| 249 class ProfileTrieNode : public ZoneAllocated { | 294 class ProfileTrieNode : public ZoneAllocated { |
| 250 public: | 295 public: |
| 251 explicit ProfileTrieNode(intptr_t index); | 296 explicit ProfileTrieNode(intptr_t index); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 JSONStream* stream, | 499 JSONStream* stream, |
| 455 Profile::TagOrder tag_order, | 500 Profile::TagOrder tag_order, |
| 456 intptr_t extra_tags, | 501 intptr_t extra_tags, |
| 457 SampleFilter* filter, | 502 SampleFilter* filter, |
| 458 bool as_timline); | 503 bool as_timline); |
| 459 }; | 504 }; |
| 460 | 505 |
| 461 } // namespace dart | 506 } // namespace dart |
| 462 | 507 |
| 463 #endif // RUNTIME_VM_PROFILER_SERVICE_H_ | 508 #endif // RUNTIME_VM_PROFILER_SERVICE_H_ |
| OLD | NEW |