Commit b81c581b authored by dcarney@chromium.org's avatar dcarney@chromium.org

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

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