Index: test/cctest/test-lockers.cc |
diff --git a/test/cctest/test-lockers.cc b/test/cctest/test-lockers.cc |
index a619c858849cc973ae250e2b6ba995710f2bb354..8486e21af6a1a15ba27adc9bc06e3342c2365733 100644 |
--- a/test/cctest/test-lockers.cc |
+++ b/test/cctest/test-lockers.cc |
@@ -27,6 +27,9 @@ |
#include <limits.h> |
+// TODO(dcarney): remove |
+#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT |
+ |
#include "v8.h" |
#include "api.h" |
@@ -70,7 +73,7 @@ class KangarooThread : public v8::internal::Thread { |
v8::Isolate::Scope isolate_scope(isolate_); |
CHECK_EQ(isolate_, v8::internal::Isolate::Current()); |
v8::HandleScope scope(isolate_); |
- v8::Context::Scope context_scope(context_); |
+ v8::Context::Scope context_scope(isolate_, context_); |
Local<Value> v = CompileRun("getValue()"); |
CHECK(v->IsNumber()); |
CHECK_EQ(30, static_cast<int>(v->NumberValue())); |
@@ -78,8 +81,8 @@ class KangarooThread : public v8::internal::Thread { |
{ |
v8::Locker locker(isolate_); |
v8::Isolate::Scope isolate_scope(isolate_); |
- v8::Context::Scope context_scope(context_); |
v8::HandleScope scope(isolate_); |
+ v8::Context::Scope context_scope(isolate_, context_); |
Local<Value> v = CompileRun("getValue()"); |
CHECK(v->IsNumber()); |
CHECK_EQ(30, static_cast<int>(v->NumberValue())); |
@@ -228,7 +231,7 @@ class IsolateNonlockingThread : public JoinableThread { |
{ |
v8::Isolate::Scope isolate_scope(isolate); |
v8::HandleScope handle_scope(isolate); |
- v8::Handle<v8::Context> context = v8::Context::New(); |
+ v8::Handle<v8::Context> context = v8::Context::New(isolate); |
v8::Context::Scope context_scope(context); |
CHECK_EQ(isolate, v8::internal::Isolate::Current()); |
CalcFibAndCheck(); |
@@ -349,7 +352,7 @@ class LockIsolateAndCalculateFibSharedContextThread : public JoinableThread { |
v8::Locker lock(isolate_); |
v8::Isolate::Scope isolate_scope(isolate_); |
HandleScope handle_scope(isolate_); |
- v8::Context::Scope context_scope(context_); |
+ v8::Context::Scope context_scope(isolate_, context_); |
CalcFibAndCheck(); |
} |
private: |
@@ -470,19 +473,20 @@ class LockAndUnlockDifferentIsolatesThread : public JoinableThread { |
} |
virtual void Run() { |
- Persistent<v8::Context> context1; |
- Persistent<v8::Context> context2; |
+ i::SmartPointer<LockIsolateAndCalculateFibSharedContextThread> thread; |
v8::Locker lock1(isolate1_); |
CHECK(v8::Locker::IsLocked(isolate1_)); |
CHECK(!v8::Locker::IsLocked(isolate2_)); |
{ |
v8::Isolate::Scope isolate_scope(isolate1_); |
v8::HandleScope handle_scope(isolate1_); |
- context1 = v8::Context::New(); |
+ v8::Handle<v8::Context> context1 = v8::Context::New(isolate1_); |
{ |
v8::Context::Scope context_scope(context1); |
CalcFibAndCheck(); |
} |
+ thread.Reset(new LockIsolateAndCalculateFibSharedContextThread( |
+ isolate1_, context1)); |
} |
v8::Locker lock2(isolate2_); |
CHECK(v8::Locker::IsLocked(isolate1_)); |
@@ -490,26 +494,14 @@ class LockAndUnlockDifferentIsolatesThread : public JoinableThread { |
{ |
v8::Isolate::Scope isolate_scope(isolate2_); |
v8::HandleScope handle_scope(isolate2_); |
- context2 = v8::Context::New(); |
+ v8::Handle<v8::Context> context2 = v8::Context::New(isolate2_); |
{ |
v8::Context::Scope context_scope(context2); |
CalcFibAndCheck(); |
} |
- } |
- { |
- i::SmartPointer<LockIsolateAndCalculateFibSharedContextThread> thread; |
- { |
- CHECK(v8::Locker::IsLocked(isolate1_)); |
- v8::Isolate::Scope isolate_scope(isolate1_); |
- v8::HandleScope handle_scope(isolate1_); |
- thread.Reset(new LockIsolateAndCalculateFibSharedContextThread( |
- isolate1_, v8::Local<v8::Context>::New(isolate1_, context1))); |
- } |
v8::Unlocker unlock1(isolate1_); |
CHECK(!v8::Locker::IsLocked(isolate1_)); |
CHECK(v8::Locker::IsLocked(isolate2_)); |
- v8::Isolate::Scope isolate_scope(isolate2_); |
- v8::HandleScope handle_scope(isolate2_); |
v8::Context::Scope context_scope(context2); |
thread->Start(); |
CalcFibAndCheck(); |
@@ -535,7 +527,7 @@ TEST(LockAndUnlockDifferentIsolates) { |
class LockUnlockLockThread : public JoinableThread { |
public: |
- LockUnlockLockThread(v8::Isolate* isolate, v8::Local<v8::Context> context) |
+ LockUnlockLockThread(v8::Isolate* isolate, v8::Handle<v8::Context> context) |
: JoinableThread("LockUnlockLockThread"), |
isolate_(isolate), |
context_(isolate, context) { |
@@ -548,7 +540,7 @@ class LockUnlockLockThread : public JoinableThread { |
{ |
v8::Isolate::Scope isolate_scope(isolate_); |
v8::HandleScope handle_scope(isolate_); |
- v8::Context::Scope context_scope(context_); |
+ v8::Context::Scope context_scope(isolate_, context_); |
CalcFibAndCheck(); |
} |
{ |
@@ -561,7 +553,7 @@ class LockUnlockLockThread : public JoinableThread { |
v8::HandleScope handle_scope(isolate_); |
CHECK(v8::Locker::IsLocked(isolate_)); |
CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); |
- v8::Context::Scope context_scope(context_); |
+ v8::Context::Scope context_scope(isolate_, context_); |
CalcFibAndCheck(); |
} |
} |
@@ -580,16 +572,15 @@ TEST(LockUnlockLockMultithreaded) { |
const int kNThreads = 100; |
#endif |
v8::Isolate* isolate = v8::Isolate::New(); |
- Persistent<v8::Context> context; |
i::List<JoinableThread*> threads(kNThreads); |
{ |
v8::Locker locker_(isolate); |
v8::Isolate::Scope isolate_scope(isolate); |
v8::HandleScope handle_scope(isolate); |
- context = v8::Context::New(); |
+ v8::Handle<v8::Context> context = v8::Context::New(isolate); |
for (int i = 0; i < kNThreads; i++) { |
threads.Add(new LockUnlockLockThread( |
- isolate, v8::Local<v8::Context>::New(isolate, context))); |
+ isolate, context)); |
} |
} |
StartJoinAndDeleteThreads(threads); |
@@ -598,7 +589,7 @@ TEST(LockUnlockLockMultithreaded) { |
class LockUnlockLockDefaultIsolateThread : public JoinableThread { |
public: |
- explicit LockUnlockLockDefaultIsolateThread(v8::Local<v8::Context> context) |
+ explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context) |
: JoinableThread("LockUnlockLockDefaultIsolateThread"), |
context_(CcTest::default_isolate(), context) {} |
@@ -606,7 +597,7 @@ class LockUnlockLockDefaultIsolateThread : public JoinableThread { |
v8::Locker lock1(CcTest::default_isolate()); |
{ |
v8::HandleScope handle_scope(CcTest::default_isolate()); |
- v8::Context::Scope context_scope(context_); |
+ v8::Context::Scope context_scope(CcTest::default_isolate(), context_); |
CalcFibAndCheck(); |
} |
{ |
@@ -614,7 +605,7 @@ class LockUnlockLockDefaultIsolateThread : public JoinableThread { |
{ |
v8::Locker lock2(CcTest::default_isolate()); |
v8::HandleScope handle_scope(CcTest::default_isolate()); |
- v8::Context::Scope context_scope(context_); |
+ v8::Context::Scope context_scope(CcTest::default_isolate(), context_); |
CalcFibAndCheck(); |
} |
} |
@@ -653,13 +644,12 @@ TEST(Regress1433) { |
v8::Locker lock(isolate); |
v8::Isolate::Scope isolate_scope(isolate); |
v8::HandleScope handle_scope(isolate); |
- v8::Persistent<Context> context = v8::Context::New(); |
+ v8::Handle<Context> context = v8::Context::New(isolate); |
v8::Context::Scope context_scope(context); |
v8::Handle<String> source = v8::String::New("1+1"); |
v8::Handle<Script> script = v8::Script::Compile(source); |
v8::Handle<Value> result = script->Run(); |
v8::String::AsciiValue ascii(result); |
- context.Dispose(isolate); |
} |
isolate->Dispose(); |
} |