Assign to "sample.state" before reading it.

I noticed a funny thing: in StackTracer::Trace "sample.state" is
checked, but it is only assigned after the check. I've put assignment
before the check.

Review URL: http://codereview.chromium.org/660452

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4017 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent fe3b8755
...@@ -567,6 +567,9 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { ...@@ -567,6 +567,9 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
TickSample sample; TickSample sample;
// We always sample the VM state.
sample.state = Logger::state();
// If profiling, we extract the current pc and sp. // If profiling, we extract the current pc and sp.
if (active_sampler_->IsProfiling()) { if (active_sampler_->IsProfiling()) {
// Extracting the sample from the context is extremely machine dependent. // Extracting the sample from the context is extremely machine dependent.
...@@ -588,9 +591,6 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { ...@@ -588,9 +591,6 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
active_sampler_->SampleStack(&sample); active_sampler_->SampleStack(&sample);
} }
// We always sample the VM state.
sample.state = Logger::state();
active_sampler_->Tick(&sample); active_sampler_->Tick(&sample);
} }
......
...@@ -728,6 +728,9 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { ...@@ -728,6 +728,9 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
TickSample sample; TickSample sample;
// We always sample the VM state.
sample.state = Logger::state();
// If profiling, we extract the current pc and sp. // If profiling, we extract the current pc and sp.
if (active_sampler_->IsProfiling()) { if (active_sampler_->IsProfiling()) {
// Extracting the sample from the context is extremely machine dependent. // Extracting the sample from the context is extremely machine dependent.
...@@ -760,9 +763,6 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { ...@@ -760,9 +763,6 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
active_sampler_->SampleStack(&sample); active_sampler_->SampleStack(&sample);
} }
// We always sample the VM state.
sample.state = Logger::state();
active_sampler_->Tick(&sample); active_sampler_->Tick(&sample);
#endif #endif
} }
......
...@@ -548,6 +548,9 @@ class Sampler::PlatformData : public Malloced { ...@@ -548,6 +548,9 @@ class Sampler::PlatformData : public Malloced {
while (sampler_->IsActive()) { while (sampler_->IsActive()) {
TickSample sample; TickSample sample;
// We always sample the VM state.
sample.state = Logger::state();
// If profiling, we record the pc and sp of the profiled thread. // If profiling, we record the pc and sp of the profiled thread.
if (sampler_->IsProfiling() if (sampler_->IsProfiling()
&& KERN_SUCCESS == thread_suspend(profiled_thread_)) { && KERN_SUCCESS == thread_suspend(profiled_thread_)) {
...@@ -585,8 +588,6 @@ class Sampler::PlatformData : public Malloced { ...@@ -585,8 +588,6 @@ class Sampler::PlatformData : public Malloced {
thread_resume(profiled_thread_); thread_resume(profiled_thread_);
} }
// We always sample the VM state.
sample.state = Logger::state();
// Invoke tick handler with program counter and stack pointer. // Invoke tick handler with program counter and stack pointer.
sampler_->Tick(&sample); sampler_->Tick(&sample);
......
...@@ -1807,6 +1807,9 @@ class Sampler::PlatformData : public Malloced { ...@@ -1807,6 +1807,9 @@ class Sampler::PlatformData : public Malloced {
while (sampler_->IsActive()) { while (sampler_->IsActive()) {
TickSample sample; TickSample sample;
// We always sample the VM state.
sample.state = Logger::state();
// If profiling, we record the pc and sp of the profiled thread. // If profiling, we record the pc and sp of the profiled thread.
if (sampler_->IsProfiling() if (sampler_->IsProfiling()
&& SuspendThread(profiled_thread_) != (DWORD)-1) { && SuspendThread(profiled_thread_) != (DWORD)-1) {
...@@ -1826,8 +1829,6 @@ class Sampler::PlatformData : public Malloced { ...@@ -1826,8 +1829,6 @@ class Sampler::PlatformData : public Malloced {
ResumeThread(profiled_thread_); ResumeThread(profiled_thread_);
} }
// We always sample the VM state.
sample.state = Logger::state();
// Invoke tick handler with program counter and stack pointer. // Invoke tick handler with program counter and stack pointer.
sampler_->Tick(&sample); sampler_->Tick(&sample);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment