Merge r7612 "In ProfilerSignalHandler ensure that thread we are trying
to sample locked the isolate" to trunk.

BUG=http://crbug.com/77725
TBR=vegorov@chromium.org
Review URL: http://codereview.chromium.org/6875016

git-svn-id: http://v8.googlecode.com/svn/trunk@7638 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/platform-freebsd.cc b/src/platform-freebsd.cc
index ca4e54f..8b83f2b 100644
--- a/src/platform-freebsd.cc
+++ b/src/platform-freebsd.cc
@@ -642,6 +642,11 @@
     // We require a fully initialized and entered isolate.
     return;
   }
+  if (v8::Locker::IsActive() &&
+      !isolate->thread_manager()->IsLockedByCurrentThread()) {
+    return;
+  }
+
   Sampler* sampler = isolate->logger()->sampler();
   if (sampler == NULL || !sampler->IsActive()) return;
 
diff --git a/src/platform-linux.cc b/src/platform-linux.cc
index e2ab9d8..1ecd8fc 100644
--- a/src/platform-linux.cc
+++ b/src/platform-linux.cc
@@ -853,6 +853,11 @@
     // We require a fully initialized and entered isolate.
     return;
   }
+  if (v8::Locker::IsActive() &&
+      !isolate->thread_manager()->IsLockedByCurrentThread()) {
+    return;
+  }
+
   Sampler* sampler = isolate->logger()->sampler();
   if (sampler == NULL || !sampler->IsActive()) return;