Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1154)

Unified Diff: test/cctest/test-lockers.cc

Issue 12729023: first step to remove unsafe handles (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: issue with debug build Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-heap-profiler.cc ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « test/cctest/test-heap-profiler.cc ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698