Revision: 8157
Author:   [email protected]
Date:     Wed Jun  1 16:31:37 2011
Log:      Merge revisions r8152,8153 from bleeding_edge into 3.3 branch.
This fixes issues 1344,crbug/79320,crbug/83521

[email protected]
Review URL: http://codereview.chromium.org/7108005
http://code.google.com/p/v8/source/detail?r=8157

Modified:
 /branches/3.3/src/platform-linux.cc
 /branches/3.3/src/version.cc

=======================================
--- /branches/3.3/src/platform-linux.cc Mon May  9 02:42:16 2011
+++ /branches/3.3/src/platform-linux.cc Wed Jun  1 16:31:37 2011
@@ -978,20 +978,29 @@
       : Thread(NULL, "SignalSender"),
         vm_tgid_(getpid()),
         interval_(interval) {}
+
+  static void InstallSignalHandler() {
+    struct sigaction sa;
+    sa.sa_sigaction = ProfilerSignalHandler;
+    sigemptyset(&sa.sa_mask);
+    sa.sa_flags = SA_RESTART | SA_SIGINFO;
+    signal_handler_installed_ =
+        (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0);
+  }
+
+  static void RestoreSignalHandler() {
+    if (signal_handler_installed_) {
+      sigaction(SIGPROF, &old_signal_handler_, 0);
+      signal_handler_installed_ = false;
+    }
+  }

   static void AddActiveSampler(Sampler* sampler) {
     ScopedLock lock(mutex_);
     SamplerRegistry::AddActiveSampler(sampler);
     if (instance_ == NULL) {
-      // Install a signal handler.
-      struct sigaction sa;
-      sa.sa_sigaction = ProfilerSignalHandler;
-      sigemptyset(&sa.sa_mask);
-      sa.sa_flags = SA_RESTART | SA_SIGINFO;
-      signal_handler_installed_ =
-          (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0);
-
-      // Start a thread that sends SIGPROF signal to VM threads.
+      // Start a thread that will send SIGPROF signal to VM threads,
+      // when CPU profiling will be enabled.
       instance_ = new SignalSender(sampler->interval());
       instance_->Start();
     } else {
@@ -1007,12 +1016,7 @@
       instance_->Join();
       delete instance_;
       instance_ = NULL;
-
-      // Restore the old signal handler.
-      if (signal_handler_installed_) {
-        sigaction(SIGPROF, &old_signal_handler_, 0);
-        signal_handler_installed_ = false;
-      }
+      RestoreSignalHandler();
     }
   }

@@ -1024,6 +1028,10 @@
       bool cpu_profiling_enabled =
           (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS);
       bool runtime_profiler_enabled = RuntimeProfiler::IsEnabled();
+      if (cpu_profiling_enabled && !signal_handler_installed_)
+        InstallSignalHandler();
+      else if (!cpu_profiling_enabled && signal_handler_installed_)
+        RestoreSignalHandler();
       // When CPU profiling is enabled both JavaScript and C++ code is
       // profiled. We must not suspend.
       if (!cpu_profiling_enabled) {
=======================================
--- /branches/3.3/src/version.cc        Mon May 30 07:32:41 2011
+++ /branches/3.3/src/version.cc        Wed Jun  1 16:31:37 2011
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     3
 #define MINOR_VERSION     3
 #define BUILD_NUMBER      10
-#define PATCH_LEVEL       4
+#define PATCH_LEVEL       5
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
 #define IS_CANDIDATE_VERSION 0

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to