Reviewers: Michael Starzinger,

Message:
ptal

Description:
make v8::Locker not use Isolate::GetCurrent()

[email protected]
BUG=

Please review this at https://chromiumcodereview.appspot.com/25002004/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+25, -37 lines):
  M include/v8.h
  M src/d8.cc
  M src/isolate.cc
  M src/v8threads.cc
  M test/cctest/test-api.cc
  M test/cctest/test-threads.cc


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 70e64a2285f474573009210382dc80eb51402391..864f5d26a01d45a1f470caa5fabf1b34c1057026 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -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: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 1c6e453f2a96bfcada6ce5e99c3155b7b4c52949..6eb7248b0e8fa0d84b802f59132cf29c1931d0c6 100644
--- 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: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index 3e5d2b909b96f3d8c155a23824dcb1ebc1119b38..de67a1c1f2343b298a95ad59ea2352ed152b8a22 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -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: src/v8threads.cc
diff --git a/src/v8threads.cc b/src/v8threads.cc
index 94a5e8051da9d1a28ab7193cd4f8df7e4e6c69c6..cc4f43965f3528e8272e4ac85beaa5f527f9060f 100644
--- a/src/v8threads.cc
+++ b/src/v8threads.cc
@@ -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: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 7a2f9def679f84b3bea8f9ab4d3a1f52f500c687..a24be6eab0e63e31be8c4be7f999d07e3d245216 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -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: test/cctest/test-threads.cc
diff --git a/test/cctest/test-threads.cc b/test/cctest/test-threads.cc
index 518d46041543a3ed34d5ae26ead2eea716fb424d..4709961636f0995e25c2a57c22ded4ccfddf93d0 100644
--- a/test/cctest/test-threads.cc
+++ b/test/cctest/test-threads.cc
@@ -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();


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to