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

Unified Diff: src/log.cc

Issue 21403: Added the simplest call stack sampling and call profile in tick processor output. (Closed)
Patch Set: Merged after Soren's changes to logging Created 11 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/platform.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index a5c89b9b7dad9ceb59af0b265ec277cd02d8dbc9..d0aea7949543bf7bd08d9248df466178b04797f6 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -139,12 +139,14 @@ bool Profiler::paused_ = false;
//
class Ticker: public Sampler {
public:
- explicit Ticker(int interval):
- Sampler(interval, FLAG_prof), window_(NULL), profiler_(NULL) {}
+ explicit Ticker(int interval, unsigned int low_stack_bound):
+ Sampler(interval, FLAG_prof), window_(NULL), profiler_(NULL),
+ low_stack_bound_(low_stack_bound) {}
~Ticker() { if (IsActive()) Stop(); }
void Tick(TickSample* sample) {
+ if (IsProfiling()) SampleStack(sample);
if (profiler_) profiler_->Insert(sample);
if (window_) window_->AddState(sample->state);
}
@@ -170,8 +172,21 @@ class Ticker: public Sampler {
}
private:
+ void SampleStack(TickSample* sample) {
+ // Assuming that stack grows from lower addresses
+ if (sample->sp < sample->fp && sample->fp < low_stack_bound_) {
+ sample->InitStack(1);
+ sample->stack[0] = Memory::Address_at(
+ (Address)(sample->fp + StandardFrameConstants::kCallerPCOffset));
+ } else {
+ // FP seems to be in some intermediate state, better discard this sample
+ sample->InitStack(0);
+ }
+ }
+
SlidingStateWindow* window_;
Profiler* profiler_;
+ unsigned int low_stack_bound_;
};
@@ -239,9 +254,6 @@ void Profiler::Disengage() {
// the thread to terminate.
running_ = false;
TickSample sample;
- sample.pc = 0;
- sample.sp = 0;
- sample.state = OTHER;
Insert(&sample);
Join();
@@ -900,6 +912,11 @@ void Logger::TickEvent(TickSample* sample, bool overflow) {
if (overflow) {
msg.Append(",overflow");
}
+ if (*(sample->stack)) {
+ for (size_t i = 0; sample->stack[i]; ++i) {
+ msg.Append(",0x%x", reinterpret_cast<unsigned int>(sample->stack[i]));
+ }
+ }
msg.Append('\n');
msg.WriteToLogFile();
}
@@ -990,7 +1007,10 @@ bool Logger::Setup() {
current_state_ = new VMState(OTHER);
- ticker_ = new Ticker(10);
+ // as log is initialized early with V8, we can assume that JS execution
+ // frames can never reach this point on stack
+ int stack_var;
+ ticker_ = new Ticker(10, reinterpret_cast<unsigned int>(&stack_var));
if (FLAG_sliding_state_window && sliding_state_window_ == NULL) {
sliding_state_window_ = new SlidingStateWindow();
« no previous file with comments | « no previous file | src/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698