make v8::Locker not use Isolate::GetCurrent()
authordcarney@chromium.org <dcarney@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 27 Sep 2013 11:32:13 +0000 (11:32 +0000)
committerdcarney@chromium.org <dcarney@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 27 Sep 2013 11:32:13 +0000 (11:32 +0000)
R=mstarzinger@chromium.org
BUG=

Review URL: https://codereview.chromium.org/25002004

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

include/v8.h
src/d8.cc
src/isolate.cc
src/v8threads.cc
test/cctest/test-api.cc
test/cctest/test-threads.cc

index 70e64a2..864f5d2 100644 (file)
@@ -5203,9 +5203,6 @@ class V8_EXPORT Unlocker {
    */
   V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); }
 
-  /** Deprecated. Use Isolate version instead. */
-  V8_DEPRECATED(Unlocker());
-
   ~Unlocker();
  private:
   void Initialize(Isolate* isolate);
@@ -5221,9 +5218,6 @@ class V8_EXPORT Locker {
    */
   V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); }
 
-  /** Deprecated. Use Isolate version instead. */
-  V8_DEPRECATED(Locker());
-
   ~Locker();
 
   /**
@@ -5233,12 +5227,12 @@ class V8_EXPORT Locker {
    * that will switch between multiple threads that are in contention
    * for the V8 lock.
    */
-  static void StartPreemption(int every_n_ms);
+  static void StartPreemption(Isolate* isolate, int every_n_ms);
 
   /**
    * Stop preemption.
    */
-  static void StopPreemption();
+  static void StopPreemption(Isolate* isolate);
 
   /**
    * Returns whether or not the locker for a given isolate, is locked by the
index 1c6e453..6eb7248 100644 (file)
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1528,7 +1528,7 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) {
     // Start preemption if threads have been created and preemption is enabled.
     if (threads.length() > 0
         && options.use_preemption) {
-      Locker::StartPreemption(options.preemption_interval);
+      Locker::StartPreemption(isolate, options.preemption_interval);
     }
 #endif  // V8_SHARED
   }
@@ -1546,7 +1546,7 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) {
 
   if (threads.length() > 0 && options.use_preemption) {
     Locker lock(isolate);
-    Locker::StopPreemption();
+    Locker::StopPreemption(isolate);
   }
 #endif  // V8_SHARED
   return 0;
index 3e5d2b9..de67a1c 100644 (file)
@@ -1929,7 +1929,7 @@ void Isolate::Deinit() {
     deoptimizer_data_ = NULL;
     if (FLAG_preemption) {
       v8::Locker locker(reinterpret_cast<v8::Isolate*>(this));
-      v8::Locker::StopPreemption();
+      v8::Locker::StopPreemption(reinterpret_cast<v8::Isolate*>(this));
     }
     builtins_.TearDown();
     bootstrapper_->TearDown();
@@ -2271,7 +2271,7 @@ bool Isolate::Init(Deserializer* des) {
 
   if (FLAG_preemption) {
     v8::Locker locker(reinterpret_cast<v8::Isolate*>(this));
-    v8::Locker::StartPreemption(100);
+    v8::Locker::StartPreemption(reinterpret_cast<v8::Isolate*>(this), 100);
   }
 
 #ifdef ENABLE_DEBUGGER_SUPPORT
index 94a5e80..cc4f439 100644 (file)
@@ -42,11 +42,6 @@ namespace v8 {
 bool Locker::active_ = false;
 
 
-Locker::Locker() {
-  Initialize(i::Isolate::GetDefaultIsolateForLocking());
-}
-
-
 // Once the Locker is initialized, the current thread will be guaranteed to have
 // the lock for a given isolate.
 void Locker::Initialize(v8::Isolate* isolate) {
@@ -116,11 +111,6 @@ Locker::~Locker() {
 }
 
 
-Unlocker::Unlocker() {
-  Initialize(i::Isolate::GetDefaultIsolateForLocking());
-}
-
-
 void Unlocker::Initialize(v8::Isolate* isolate) {
   ASSERT(isolate != NULL);
   isolate_ = reinterpret_cast<i::Isolate*>(isolate);
@@ -143,14 +133,15 @@ Unlocker::~Unlocker() {
 }
 
 
-void Locker::StartPreemption(int every_n_ms) {
+void Locker::StartPreemption(v8::Isolate* isolate, int every_n_ms) {
   v8::internal::ContextSwitcher::StartPreemption(
-      i::Isolate::Current(), every_n_ms);
+      reinterpret_cast<i::Isolate*>(isolate), every_n_ms);
 }
 
 
-void Locker::StopPreemption() {
-  v8::internal::ContextSwitcher::StopPreemption(i::Isolate::Current());
+void Locker::StopPreemption(v8::Isolate* isolate) {
+  v8::internal::ContextSwitcher::StopPreemption(
+      reinterpret_cast<i::Isolate*>(isolate));
 }
 
 
index 7a2f9de..a24be6e 100644 (file)
@@ -14218,14 +14218,15 @@ class RegExpInterruptTest {
     gc_success_ = false;
     GCThread gc_thread(this);
     gc_thread.Start();
-    v8::Locker::StartPreemption(1);
+    v8::Isolate* isolate = CcTest::isolate();
+    v8::Locker::StartPreemption(isolate, 1);
 
     LongRunningRegExp();
     {
-      v8::Unlocker unlock(CcTest::isolate());
+      v8::Unlocker unlock(isolate);
       gc_thread.Join();
     }
-    v8::Locker::StopPreemption();
+    v8::Locker::StopPreemption(isolate);
     CHECK(regexp_success_);
     CHECK(gc_success_);
   }
@@ -14340,14 +14341,15 @@ class ApplyInterruptTest {
     gc_success_ = false;
     GCThread gc_thread(this);
     gc_thread.Start();
-    v8::Locker::StartPreemption(1);
+    v8::Isolate* isolate = CcTest::isolate();
+    v8::Locker::StartPreemption(isolate, 1);
 
     LongRunningApply();
     {
-      v8::Unlocker unlock(CcTest::isolate());
+      v8::Unlocker unlock(isolate);
       gc_thread.Join();
     }
-    v8::Locker::StopPreemption();
+    v8::Locker::StopPreemption(isolate);
     CHECK(apply_success_);
     CHECK(gc_success_);
   }
@@ -14627,6 +14629,7 @@ class RegExpStringModificationTest {
         uc16_resource_(i::Vector<const uint16_t>(two_byte_content_, 15)) {}
   ~RegExpStringModificationTest() {}
   void RunTest() {
+    v8::Isolate* isolate = CcTest::isolate();
     i::Factory* factory = CcTest::i_isolate()->factory();
 
     regexp_success_ = false;
@@ -14655,13 +14658,13 @@ class RegExpStringModificationTest {
 
     MorphThread morph_thread(this);
     morph_thread.Start();
-    v8::Locker::StartPreemption(1);
+    v8::Locker::StartPreemption(isolate, 1);
     LongRunningRegExp();
     {
-      v8::Unlocker unlock(CcTest::isolate());
+      v8::Unlocker unlock(isolate);
       morph_thread.Join();
     }
-    v8::Locker::StopPreemption();
+    v8::Locker::StopPreemption(isolate);
     CHECK(regexp_success_);
     CHECK(morph_success_);
   }
index 518d460..4709961 100644 (file)
@@ -41,14 +41,14 @@ TEST(Preemption) {
   v8::Handle<v8::Context> context = v8::Context::New(isolate);
   v8::Context::Scope context_scope(context);
 
-  v8::Locker::StartPreemption(100);
+  v8::Locker::StartPreemption(isolate, 100);
 
   v8::Handle<v8::Script> script = v8::Script::Compile(
       v8::String::New("var count = 0; var obj = new Object(); count++;\n"));
 
   script->Run();
 
-  v8::Locker::StopPreemption();
+  v8::Locker::StopPreemption(isolate);
   v8::internal::OS::Sleep(500);  // Make sure the timer fires.
 
   script->Run();