| 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 #ifndef VM_PROFILER_H_ | 5 #ifndef VM_PROFILER_H_ |
| 6 #define VM_PROFILER_H_ | 6 #define 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" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 152 } |
| 153 | 153 |
| 154 void Clear() { | 154 void Clear() { |
| 155 isolate_ = NULL; | 155 isolate_ = NULL; |
| 156 pc_marker_ = 0; | 156 pc_marker_ = 0; |
| 157 for (intptr_t i = 0; i < kStackBufferSizeInWords; i++) { | 157 for (intptr_t i = 0; i < kStackBufferSizeInWords; i++) { |
| 158 stack_buffer_[i] = 0; | 158 stack_buffer_[i] = 0; |
| 159 } | 159 } |
| 160 vm_tag_ = VMTag::kInvalidTagId; | 160 vm_tag_ = VMTag::kInvalidTagId; |
| 161 user_tag_ = UserTags::kDefaultUserTag; | 161 user_tag_ = UserTags::kDefaultUserTag; |
| 162 sp_ = 0; | |
| 163 lr_ = 0; | 162 lr_ = 0; |
| 164 fp_ = 0; | 163 metadata_ = 0; |
| 165 state_ = 0; | 164 state_ = 0; |
| 166 uword* pcs = GetPCArray(); | 165 uword* pcs = GetPCArray(); |
| 167 for (intptr_t i = 0; i < pcs_length_; i++) { | 166 for (intptr_t i = 0; i < pcs_length_; i++) { |
| 168 pcs[i] = 0; | 167 pcs[i] = 0; |
| 169 } | 168 } |
| 170 } | 169 } |
| 171 | 170 |
| 172 // Timestamp sample was taken at. | 171 // Timestamp sample was taken at. |
| 173 int64_t timestamp() const { | 172 int64_t timestamp() const { |
| 174 return timestamp_; | 173 return timestamp_; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 210 } |
| 212 | 211 |
| 213 uword pc_marker() const { | 212 uword pc_marker() const { |
| 214 return pc_marker_; | 213 return pc_marker_; |
| 215 } | 214 } |
| 216 | 215 |
| 217 void set_pc_marker(uword pc_marker) { | 216 void set_pc_marker(uword pc_marker) { |
| 218 pc_marker_ = pc_marker; | 217 pc_marker_ = pc_marker; |
| 219 } | 218 } |
| 220 | 219 |
| 221 uword sp() const { | |
| 222 return sp_; | |
| 223 } | |
| 224 | |
| 225 void set_sp(uword sp) { | |
| 226 sp_ = sp; | |
| 227 } | |
| 228 | |
| 229 uword fp() const { | |
| 230 return fp_; | |
| 231 } | |
| 232 | |
| 233 void set_fp(uword fp) { | |
| 234 fp_ = fp; | |
| 235 } | |
| 236 | |
| 237 uword lr() const { | 220 uword lr() const { |
| 238 return lr_; | 221 return lr_; |
| 239 } | 222 } |
| 240 | 223 |
| 241 void set_lr(uword link_register) { | 224 void set_lr(uword link_register) { |
| 242 lr_ = link_register; | 225 lr_ = link_register; |
| 243 } | 226 } |
| 244 | 227 |
| 245 void InsertCallerForTopFrame(uword pc) { | 228 void InsertCallerForTopFrame(uword pc) { |
| 246 if (pcs_length_ == 1) { | 229 if (pcs_length_ == 1) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 } | 282 } |
| 300 | 283 |
| 301 bool truncated_trace() const { | 284 bool truncated_trace() const { |
| 302 return TruncatedTraceBit::decode(state_); | 285 return TruncatedTraceBit::decode(state_); |
| 303 } | 286 } |
| 304 | 287 |
| 305 void set_truncated_trace(bool truncated_trace) { | 288 void set_truncated_trace(bool truncated_trace) { |
| 306 state_ = TruncatedTraceBit::update(truncated_trace, state_); | 289 state_ = TruncatedTraceBit::update(truncated_trace, state_); |
| 307 } | 290 } |
| 308 | 291 |
| 292 bool is_allocation_sample() const { |
| 293 return ClassAllocationSampleBit::decode(state_); |
| 294 } |
| 295 |
| 296 void set_is_allocation_sample(bool allocation_sample) { |
| 297 state_ = ClassAllocationSampleBit::update(allocation_sample, state_); |
| 298 } |
| 299 |
| 300 intptr_t allocation_cid() const { |
| 301 ASSERT(is_allocation_sample()); |
| 302 return metadata_; |
| 303 } |
| 304 |
| 305 void set_metadata(intptr_t metadata) { |
| 306 metadata_ = metadata; |
| 307 } |
| 308 |
| 309 static void InitOnce(); | 309 static void InitOnce(); |
| 310 | 310 |
| 311 static intptr_t instance_size() { | 311 static intptr_t instance_size() { |
| 312 return instance_size_; | 312 return instance_size_; |
| 313 } | 313 } |
| 314 | 314 |
| 315 uword* GetPCArray() const; | 315 uword* GetPCArray() const; |
| 316 | 316 |
| 317 static const int kStackBufferSizeInWords = 2; | 317 static const int kStackBufferSizeInWords = 2; |
| 318 uword* GetStackBuffer() { | 318 uword* GetStackBuffer() { |
| 319 return &stack_buffer_[0]; | 319 return &stack_buffer_[0]; |
| 320 } | 320 } |
| 321 | 321 |
| 322 private: | 322 private: |
| 323 static intptr_t instance_size_; | 323 static intptr_t instance_size_; |
| 324 static intptr_t pcs_length_; | 324 static intptr_t pcs_length_; |
| 325 enum StateBits { | 325 enum StateBits { |
| 326 kProcessedBit = 0, | 326 kProcessedBit = 0, |
| 327 kLeafFrameIsDartBit = 1, | 327 kLeafFrameIsDartBit = 1, |
| 328 kIgnoreBit = 2, | 328 kIgnoreBit = 2, |
| 329 kExitFrameBit = 3, | 329 kExitFrameBit = 3, |
| 330 kMissingFrameInsertedBit = 4, | 330 kMissingFrameInsertedBit = 4, |
| 331 kTruncatedTrace = 5, | 331 kTruncatedTrace = 5, |
| 332 kClassAllocationSample = 6, |
| 332 }; | 333 }; |
| 333 class ProcessedBit : public BitField<bool, kProcessedBit, 1> {}; | 334 class ProcessedBit : public BitField<bool, kProcessedBit, 1> {}; |
| 334 class LeafFrameIsDart : public BitField<bool, kLeafFrameIsDartBit, 1> {}; | 335 class LeafFrameIsDart : public BitField<bool, kLeafFrameIsDartBit, 1> {}; |
| 335 class IgnoreBit : public BitField<bool, kIgnoreBit, 1> {}; | 336 class IgnoreBit : public BitField<bool, kIgnoreBit, 1> {}; |
| 336 class ExitFrameBit : public BitField<bool, kExitFrameBit, 1> {}; | 337 class ExitFrameBit : public BitField<bool, kExitFrameBit, 1> {}; |
| 337 class MissingFrameInsertedBit | 338 class MissingFrameInsertedBit |
| 338 : public BitField<bool, kMissingFrameInsertedBit, 1> {}; | 339 : public BitField<bool, kMissingFrameInsertedBit, 1> {}; |
| 339 class TruncatedTraceBit : public BitField<bool, kTruncatedTrace, 1> {}; | 340 class TruncatedTraceBit : public BitField<bool, kTruncatedTrace, 1> {}; |
| 341 class ClassAllocationSampleBit |
| 342 : public BitField<bool, kClassAllocationSample, 1> {}; |
| 340 | 343 |
| 341 int64_t timestamp_; | 344 int64_t timestamp_; |
| 342 ThreadId tid_; | 345 ThreadId tid_; |
| 343 Isolate* isolate_; | 346 Isolate* isolate_; |
| 344 uword pc_marker_; | 347 uword pc_marker_; |
| 345 uword stack_buffer_[kStackBufferSizeInWords]; | 348 uword stack_buffer_[kStackBufferSizeInWords]; |
| 346 uword vm_tag_; | 349 uword vm_tag_; |
| 347 uword user_tag_; | 350 uword user_tag_; |
| 348 uword sp_; | 351 uword metadata_; |
| 349 uword fp_; | |
| 350 uword lr_; | 352 uword lr_; |
| 351 uword state_; | 353 uword state_; |
| 352 | 354 |
| 353 /* There are a variable number of words that follow, the words hold the | 355 /* There are a variable number of words that follow, the words hold the |
| 354 * sampled pc values. Access via GetPCArray() */ | 356 * sampled pc values. Access via GetPCArray() */ |
| 355 | 357 |
| 356 DISALLOW_COPY_AND_ASSIGN(Sample); | 358 DISALLOW_COPY_AND_ASSIGN(Sample); |
| 357 }; | 359 }; |
| 358 | 360 |
| 359 | 361 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 intptr_t capacity_; | 411 intptr_t capacity_; |
| 410 uintptr_t cursor_; | 412 uintptr_t cursor_; |
| 411 | 413 |
| 412 DISALLOW_COPY_AND_ASSIGN(SampleBuffer); | 414 DISALLOW_COPY_AND_ASSIGN(SampleBuffer); |
| 413 }; | 415 }; |
| 414 | 416 |
| 415 | 417 |
| 416 } // namespace dart | 418 } // namespace dart |
| 417 | 419 |
| 418 #endif // VM_PROFILER_H_ | 420 #endif // VM_PROFILER_H_ |
| OLD | NEW |