OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 Address function; // The last called JS function. | 547 Address function; // The last called JS function. |
548 static const int kMaxFramesCount = 64; | 548 static const int kMaxFramesCount = 64; |
549 Address stack[kMaxFramesCount]; // Call stack. | 549 Address stack[kMaxFramesCount]; // Call stack. |
550 int frames_count; // Number of captured frames. | 550 int frames_count; // Number of captured frames. |
551 }; | 551 }; |
552 | 552 |
553 #ifdef ENABLE_LOGGING_AND_PROFILING | 553 #ifdef ENABLE_LOGGING_AND_PROFILING |
554 class Sampler { | 554 class Sampler { |
555 public: | 555 public: |
556 // Initialize sampler. | 556 // Initialize sampler. |
557 explicit Sampler(int interval, bool profiling); | 557 Sampler(int interval, bool profiling); |
558 virtual ~Sampler(); | 558 virtual ~Sampler(); |
559 | 559 |
560 // Performs stack sampling. | 560 // Performs stack sampling. |
561 virtual void SampleStack(TickSample* sample) = 0; | 561 virtual void SampleStack(TickSample* sample) = 0; |
562 | 562 |
563 // This method is called for each sampling period with the current | 563 // This method is called for each sampling period with the current |
564 // program counter. | 564 // program counter. |
565 virtual void Tick(TickSample* sample) = 0; | 565 virtual void Tick(TickSample* sample) = 0; |
566 | 566 |
567 // Start and stop sampler. | 567 // Start and stop sampler. |
568 void Start(); | 568 void Start(); |
569 void Stop(); | 569 void Stop(); |
570 | 570 |
571 // Is the sampler used for profiling? | 571 // Is the sampler used for profiling? |
572 bool IsProfiling() const { return profiling_; } | 572 bool IsProfiling() const { return profiling_; } |
573 | 573 |
574 // Is the sampler running in sync with the JS thread? On platforms | 574 // Is the sampler running in sync with the JS thread? On platforms |
575 // where the sampler is implemented with a thread that wakes up | 575 // where the sampler is implemented with a thread that wakes up |
576 // every now and then, having a synchronous sampler implies | 576 // every now and then, having a synchronous sampler implies |
577 // suspending/resuming the JS thread. | 577 // suspending/resuming the JS thread. |
578 bool IsSynchronous() const { return synchronous_; } | 578 bool IsSynchronous() const { return synchronous_; } |
579 | 579 |
580 // Whether the sampler is running (that is, consumes resources). | 580 // Whether the sampler is running (that is, consumes resources). |
581 bool IsActive() const { return active_; } | 581 bool IsActive() const { return active_; } |
582 | 582 |
583 unsigned int samples_taken() { return samples_taken_; } | |
Vitaly Repeshko
2010/11/25 15:01:20
Please document what this counter means and that i
mnaganov (inactive)
2010/11/25 15:26:56
Done.
| |
584 void inc_samples_taken() { ++samples_taken_; } | |
Vitaly Repeshko
2010/11/25 15:01:20
Do we have to expose increment? Can't we do this b
mnaganov (inactive)
2010/11/25 15:26:56
Ticker is a module-private class, it can't be used
| |
585 void reset_samples_taken() { samples_taken_ = 0; } | |
586 | |
583 class PlatformData; | 587 class PlatformData; |
584 | 588 |
585 private: | 589 private: |
586 const int interval_; | 590 const int interval_; |
587 const bool profiling_; | 591 const bool profiling_; |
588 const bool synchronous_; | 592 const bool synchronous_; |
589 bool active_; | 593 bool active_; |
590 PlatformData* data_; // Platform specific data. | 594 PlatformData* data_; // Platform specific data. |
595 unsigned int samples_taken_; | |
Vitaly Repeshko
2010/11/25 15:01:20
Unsigned is banned by the style guide (http://goog
mnaganov (inactive)
2010/11/25 15:26:56
I care about the possibility of having negative va
| |
591 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 596 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
592 }; | 597 }; |
593 | 598 |
594 #endif // ENABLE_LOGGING_AND_PROFILING | 599 #endif // ENABLE_LOGGING_AND_PROFILING |
595 | 600 |
596 } } // namespace v8::internal | 601 } } // namespace v8::internal |
597 | 602 |
598 #endif // V8_PLATFORM_H_ | 603 #endif // V8_PLATFORM_H_ |
OLD | NEW |