Ensure V8 is initialized before locking and unlocking threads.
authorwhesse@chromium.org <whesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 2 Oct 2009 11:39:56 +0000 (11:39 +0000)
committerwhesse@chromium.org <whesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 2 Oct 2009 11:39:56 +0000 (11:39 +0000)
Review URL: http://codereview.chromium.org/242123

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3008 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/v8threads.cc

index 375afb1..80a7cd9 100644 (file)
@@ -56,6 +56,12 @@ Locker::Locker() : has_lock_(false), top_level_(true) {
   if (!internal::ThreadManager::IsLockedByCurrentThread()) {
     internal::ThreadManager::Lock();
     has_lock_ = true;
+    // Make sure that V8 is initialized.  Archiving of threads interferes
+    // with deserialization by adding additional root pointers, so we must
+    // initialize here, before anyone can call ~Locker() or Unlocker().
+    if (!internal::V8::IsRunning()) {
+      V8::Initialize();
+    }
     // This may be a locker within an unlocker in which case we have to
     // get the saved state for this thread and restore it.
     if (internal::ThreadManager::RestoreThread()) {