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

Unified Diff: src/log.cc

Issue 28112: Adding unit tests for profiler's stack tracer. (Closed)
Patch Set: Changes according to comments 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 | « src/log.h ('k') | test/cctest/SConscript » ('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 74b92890873c90c5ede41f37041793b7a5540929..283530358494d80187095668aeb0f24defbb387c 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -134,6 +134,22 @@ bool Profiler::paused_ = false;
//
+// StackTracer implementation
+//
+void StackTracer::Trace(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);
+ }
+}
+
+
+//
// Ticker used to provide ticks to the profiler and the sliding state
// window.
//
@@ -141,12 +157,12 @@ class Ticker: public Sampler {
public:
explicit Ticker(int interval, unsigned int low_stack_bound):
Sampler(interval, FLAG_prof), window_(NULL), profiler_(NULL),
- low_stack_bound_(low_stack_bound) {}
+ stack_tracer_(low_stack_bound) {}
~Ticker() { if (IsActive()) Stop(); }
void Tick(TickSample* sample) {
- if (IsProfiling()) SampleStack(sample);
+ if (IsProfiling()) stack_tracer_.Trace(sample);
if (profiler_) profiler_->Insert(sample);
if (window_) window_->AddState(sample->state);
}
@@ -172,21 +188,9 @@ 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_;
+ StackTracer stack_tracer_;
};
« no previous file with comments | « src/log.h ('k') | test/cctest/SConscript » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698