Reviewers: Søren Gjesse,
Description:
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.
Please review this at http://codereview.chromium.org/660452
Affected files:
M src/platform-freebsd.cc
M src/platform-linux.cc
M src/platform-macos.cc
M src/platform-win32.cc
Index: src/platform-freebsd.cc
diff --git a/src/platform-freebsd.cc b/src/platform-freebsd.cc
index
ff75776856466c5ec47fabb6b550c718d0b3eba8..3617e8af2b4db497cf5c1149b704d0268aa61a50
100644
--- a/src/platform-freebsd.cc
+++ b/src/platform-freebsd.cc
@@ -567,6 +567,9 @@ static void ProfilerSignalHandler(int signal,
siginfo_t* info, void* context) {
TickSample sample;
+ // We always sample the VM state.
+ sample.state = Logger::state();
+
// If profiling, we extract the current pc and sp.
if (active_sampler_->IsProfiling()) {
// Extracting the sample from the context is extremely machine
dependent.
@@ -588,9 +591,6 @@ static void ProfilerSignalHandler(int signal,
siginfo_t* info, void* context) {
active_sampler_->SampleStack(&sample);
}
- // We always sample the VM state.
- sample.state = Logger::state();
-
active_sampler_->Tick(&sample);
}
Index: src/platform-linux.cc
diff --git a/src/platform-linux.cc b/src/platform-linux.cc
index
e890f94aad39190ad78bd2a99338404a7358a8db..7898aba982a513f037993994072029a01510584a
100644
--- a/src/platform-linux.cc
+++ b/src/platform-linux.cc
@@ -728,6 +728,9 @@ static void ProfilerSignalHandler(int signal,
siginfo_t* info, void* context) {
TickSample sample;
+ // We always sample the VM state.
+ sample.state = Logger::state();
+
// If profiling, we extract the current pc and sp.
if (active_sampler_->IsProfiling()) {
// Extracting the sample from the context is extremely machine
dependent.
@@ -760,9 +763,6 @@ static void ProfilerSignalHandler(int signal,
siginfo_t* info, void* context) {
active_sampler_->SampleStack(&sample);
}
- // We always sample the VM state.
- sample.state = Logger::state();
-
active_sampler_->Tick(&sample);
#endif
}
Index: src/platform-macos.cc
diff --git a/src/platform-macos.cc b/src/platform-macos.cc
index
e379ae22671b52846cacaed7dc412b8a5da060f0..45029879f4bcf16cdbaddae2732da971d87582b6
100644
--- a/src/platform-macos.cc
+++ b/src/platform-macos.cc
@@ -548,6 +548,9 @@ class Sampler::PlatformData : public Malloced {
while (sampler_->IsActive()) {
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 (sampler_->IsProfiling()
&& KERN_SUCCESS == thread_suspend(profiled_thread_)) {
@@ -585,8 +588,6 @@ class Sampler::PlatformData : public Malloced {
thread_resume(profiled_thread_);
}
- // We always sample the VM state.
- sample.state = Logger::state();
// Invoke tick handler with program counter and stack pointer.
sampler_->Tick(&sample);
Index: src/platform-win32.cc
diff --git a/src/platform-win32.cc b/src/platform-win32.cc
index
81b0d4c12e0585de4fb2dcc9a8faf38d582c0461..04ffea968c640ba8c9fdb97fb41bd7df16c4a0fe
100644
--- a/src/platform-win32.cc
+++ b/src/platform-win32.cc
@@ -1807,6 +1807,9 @@ class Sampler::PlatformData : public Malloced {
while (sampler_->IsActive()) {
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 (sampler_->IsProfiling()
&& SuspendThread(profiled_thread_) != (DWORD)-1) {
@@ -1826,8 +1829,6 @@ class Sampler::PlatformData : public Malloced {
ResumeThread(profiled_thread_);
}
- // We always sample the VM state.
- sample.state = Logger::state();
// Invoke tick handler with program counter and stack pointer.
sampler_->Tick(&sample);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev