summaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/test-lockers.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/cctest/test-lockers.cc')
-rw-r--r--deps/v8/test/cctest/test-lockers.cc130
1 files changed, 66 insertions, 64 deletions
diff --git a/deps/v8/test/cctest/test-lockers.cc b/deps/v8/test/cctest/test-lockers.cc
index f1dc5a28b4..385366aa24 100644
--- a/deps/v8/test/cctest/test-lockers.cc
+++ b/deps/v8/test/cctest/test-lockers.cc
@@ -35,7 +35,7 @@
#include "src/compilation-cache.h"
#include "src/execution.h"
#include "src/isolate.h"
-#include "src/parser.h"
+#include "src/parsing/parser.h"
#include "src/unicode-inl.h"
#include "src/utils.h"
#include "test/cctest/cctest.h"
@@ -57,7 +57,7 @@ using ::v8::V8;
// Migrating an isolate
class KangarooThread : public v8::base::Thread {
public:
- KangarooThread(v8::Isolate* isolate, v8::Handle<v8::Context> context)
+ KangarooThread(v8::Isolate* isolate, v8::Local<v8::Context> context)
: Thread(Options("KangarooThread")),
isolate_(isolate),
context_(isolate, context) {}
@@ -66,15 +66,14 @@ class KangarooThread : public v8::base::Thread {
{
v8::Locker locker(isolate_);
v8::Isolate::Scope isolate_scope(isolate_);
- CHECK_EQ(reinterpret_cast<v8::internal::Isolate*>(isolate_),
- v8::internal::Isolate::Current());
+ CHECK_EQ(isolate_, v8::Isolate::GetCurrent());
v8::HandleScope scope(isolate_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
Local<Value> v = CompileRun("getValue()");
CHECK(v->IsNumber());
- CHECK_EQ(30, static_cast<int>(v->NumberValue()));
+ CHECK_EQ(30, static_cast<int>(v->NumberValue(context).FromJust()));
}
{
v8::Locker locker(isolate_);
@@ -85,7 +84,7 @@ class KangarooThread : public v8::base::Thread {
v8::Context::Scope context_scope(context);
Local<Value> v = CompileRun("getValue()");
CHECK(v->IsNumber());
- CHECK_EQ(30, static_cast<int>(v->NumberValue()));
+ CHECK_EQ(30, static_cast<int>(v->NumberValue(context).FromJust()));
}
isolate_->Dispose();
}
@@ -108,8 +107,7 @@ TEST(KangarooIsolates) {
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context);
- CHECK_EQ(reinterpret_cast<v8::internal::Isolate*>(isolate),
- v8::internal::Isolate::Current());
+ CHECK_EQ(isolate, v8::Isolate::GetCurrent());
CompileRun("function getValue() { return 30; }");
thread1.Reset(new KangarooThread(isolate, context));
}
@@ -118,14 +116,14 @@ TEST(KangarooIsolates) {
}
-static void CalcFibAndCheck() {
+static void CalcFibAndCheck(v8::Local<v8::Context> context) {
Local<Value> v = CompileRun("function fib(n) {"
" if (n <= 2) return 1;"
" return fib(n-1) + fib(n-2);"
"}"
"fib(10)");
CHECK(v->IsNumber());
- CHECK_EQ(55, static_cast<int>(v->NumberValue()));
+ CHECK_EQ(55, static_cast<int>(v->NumberValue(context).FromJust()));
}
class JoinableThread {
@@ -187,9 +185,8 @@ class IsolateLockingThreadWithLocalContext : public JoinableThread {
v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope handle_scope(isolate_);
LocalContext local_context(isolate_);
- CHECK_EQ(reinterpret_cast<v8::internal::Isolate*>(isolate_),
- v8::internal::Isolate::Current());
- CalcFibAndCheck();
+ CHECK_EQ(isolate_, v8::Isolate::GetCurrent());
+ CalcFibAndCheck(local_context.local());
}
private:
v8::Isolate* isolate_;
@@ -241,11 +238,11 @@ class IsolateNestedLockingThread : public JoinableThread {
LocalContext local_context(isolate_);
{
v8::Locker another_lock(isolate_);
- CalcFibAndCheck();
+ CalcFibAndCheck(local_context.local());
}
{
v8::Locker another_lock(isolate_);
- CalcFibAndCheck();
+ CalcFibAndCheck(local_context.local());
}
}
private:
@@ -289,7 +286,7 @@ class SeparateIsolatesLocksNonexclusiveThread : public JoinableThread {
IsolateLockingThreadWithLocalContext threadB(isolate2_);
threadB.Start();
- CalcFibAndCheck();
+ CalcFibAndCheck(local_context.local());
threadB.Join();
}
private:
@@ -323,11 +320,10 @@ TEST(SeparateIsolatesLocksNonexclusive) {
class LockIsolateAndCalculateFibSharedContextThread : public JoinableThread {
public:
explicit LockIsolateAndCalculateFibSharedContextThread(
- v8::Isolate* isolate, v8::Handle<v8::Context> context)
- : JoinableThread("LockIsolateAndCalculateFibThread"),
- isolate_(isolate),
- context_(isolate, context) {
- }
+ v8::Isolate* isolate, v8::Local<v8::Context> context)
+ : JoinableThread("LockIsolateAndCalculateFibThread"),
+ isolate_(isolate),
+ context_(isolate, context) {}
virtual void Run() {
v8::Locker lock(isolate_);
@@ -336,7 +332,7 @@ class LockIsolateAndCalculateFibSharedContextThread : public JoinableThread {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
- CalcFibAndCheck();
+ CalcFibAndCheck(context);
}
private:
v8::Isolate* isolate_;
@@ -351,26 +347,31 @@ class LockerUnlockerThread : public JoinableThread {
}
virtual void Run() {
- v8::Locker lock(isolate_);
- v8::Isolate::Scope isolate_scope(isolate_);
- v8::HandleScope handle_scope(isolate_);
- v8::Local<v8::Context> context = v8::Context::New(isolate_);
+ isolate_->DiscardThreadSpecificMetadata(); // No-op
{
- v8::Context::Scope context_scope(context);
- CalcFibAndCheck();
- }
- {
- LockIsolateAndCalculateFibSharedContextThread thread(isolate_, context);
- isolate_->Exit();
- v8::Unlocker unlocker(isolate_);
- thread.Start();
- thread.Join();
- }
- isolate_->Enter();
- {
- v8::Context::Scope context_scope(context);
- CalcFibAndCheck();
+ v8::Locker lock(isolate_);
+ v8::Isolate::Scope isolate_scope(isolate_);
+ v8::HandleScope handle_scope(isolate_);
+ v8::Local<v8::Context> context = v8::Context::New(isolate_);
+ {
+ v8::Context::Scope context_scope(context);
+ CalcFibAndCheck(context);
+ }
+ {
+ LockIsolateAndCalculateFibSharedContextThread thread(isolate_, context);
+ isolate_->Exit();
+ v8::Unlocker unlocker(isolate_);
+ thread.Start();
+ thread.Join();
+ }
+ isolate_->Enter();
+ {
+ v8::Context::Scope context_scope(context);
+ CalcFibAndCheck(context);
+ }
}
+ isolate_->DiscardThreadSpecificMetadata();
+ isolate_->DiscardThreadSpecificMetadata(); // No-op
}
private:
@@ -411,7 +412,7 @@ class LockTwiceAndUnlockThread : public JoinableThread {
v8::Local<v8::Context> context = v8::Context::New(isolate_);
{
v8::Context::Scope context_scope(context);
- CalcFibAndCheck();
+ CalcFibAndCheck(context);
}
{
v8::Locker second_lock(isolate_);
@@ -426,7 +427,7 @@ class LockTwiceAndUnlockThread : public JoinableThread {
isolate_->Enter();
{
v8::Context::Scope context_scope(context);
- CalcFibAndCheck();
+ CalcFibAndCheck(context);
}
}
@@ -472,10 +473,10 @@ class LockAndUnlockDifferentIsolatesThread : public JoinableThread {
{
v8::Isolate::Scope isolate_scope(isolate1_);
v8::HandleScope handle_scope(isolate1_);
- v8::Handle<v8::Context> context1 = v8::Context::New(isolate1_);
+ v8::Local<v8::Context> context1 = v8::Context::New(isolate1_);
{
v8::Context::Scope context_scope(context1);
- CalcFibAndCheck();
+ CalcFibAndCheck(context1);
}
thread.Reset(new LockIsolateAndCalculateFibSharedContextThread(
isolate1_, context1));
@@ -486,17 +487,17 @@ class LockAndUnlockDifferentIsolatesThread : public JoinableThread {
{
v8::Isolate::Scope isolate_scope(isolate2_);
v8::HandleScope handle_scope(isolate2_);
- v8::Handle<v8::Context> context2 = v8::Context::New(isolate2_);
+ v8::Local<v8::Context> context2 = v8::Context::New(isolate2_);
{
v8::Context::Scope context_scope(context2);
- CalcFibAndCheck();
+ CalcFibAndCheck(context2);
}
v8::Unlocker unlock1(isolate1_);
CHECK(!v8::Locker::IsLocked(isolate1_));
CHECK(v8::Locker::IsLocked(isolate2_));
v8::Context::Scope context_scope(context2);
thread->Start();
- CalcFibAndCheck();
+ CalcFibAndCheck(context2);
thread->Join();
}
}
@@ -522,11 +523,10 @@ TEST(LockAndUnlockDifferentIsolates) {
class LockUnlockLockThread : public JoinableThread {
public:
- LockUnlockLockThread(v8::Isolate* isolate, v8::Handle<v8::Context> context)
- : JoinableThread("LockUnlockLockThread"),
- isolate_(isolate),
- context_(isolate, context) {
- }
+ LockUnlockLockThread(v8::Isolate* isolate, v8::Local<v8::Context> context)
+ : JoinableThread("LockUnlockLockThread"),
+ isolate_(isolate),
+ context_(isolate, context) {}
virtual void Run() {
v8::Locker lock1(isolate_);
@@ -538,7 +538,7 @@ class LockUnlockLockThread : public JoinableThread {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
- CalcFibAndCheck();
+ CalcFibAndCheck(context);
}
{
v8::Unlocker unlock1(isolate_);
@@ -553,7 +553,7 @@ class LockUnlockLockThread : public JoinableThread {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
- CalcFibAndCheck();
+ CalcFibAndCheck(context);
}
}
}
@@ -579,7 +579,7 @@ TEST(LockUnlockLockMultithreaded) {
v8::Locker locker_(isolate);
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::Context> context = v8::Context::New(isolate);
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
for (int i = 0; i < kNThreads; i++) {
threads.Add(new LockUnlockLockThread(
isolate, context));
@@ -591,7 +591,7 @@ TEST(LockUnlockLockMultithreaded) {
class LockUnlockLockDefaultIsolateThread : public JoinableThread {
public:
- explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context)
+ explicit LockUnlockLockDefaultIsolateThread(v8::Local<v8::Context> context)
: JoinableThread("LockUnlockLockDefaultIsolateThread"),
context_(CcTest::isolate(), context) {}
@@ -603,7 +603,7 @@ class LockUnlockLockDefaultIsolateThread : public JoinableThread {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(CcTest::isolate(), context_);
v8::Context::Scope context_scope(context);
- CalcFibAndCheck();
+ CalcFibAndCheck(context);
}
{
v8::Unlocker unlock1(CcTest::isolate());
@@ -614,7 +614,7 @@ class LockUnlockLockDefaultIsolateThread : public JoinableThread {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(CcTest::isolate(), context_);
v8::Context::Scope context_scope(context);
- CalcFibAndCheck();
+ CalcFibAndCheck(context);
}
}
}
@@ -655,11 +655,12 @@ TEST(Regress1433) {
v8::Locker lock(isolate);
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
- v8::Handle<Context> context = v8::Context::New(isolate);
+ v8::Local<Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context);
- v8::Handle<String> source = v8::String::NewFromUtf8(isolate, "1+1");
- v8::Handle<Script> script = v8::Script::Compile(source);
- v8::Handle<Value> result = script->Run();
+ v8::Local<String> source = v8_str("1+1");
+ v8::Local<Script> script =
+ v8::Script::Compile(context, source).ToLocalChecked();
+ v8::Local<Value> result = script->Run(context).ToLocalChecked();
v8::String::Utf8Value utf8(result);
}
isolate->Dispose();
@@ -686,11 +687,12 @@ class IsolateGenesisThread : public JoinableThread {
v8::Isolate* isolate = v8::Isolate::New(create_params);
{
v8::Isolate::Scope isolate_scope(isolate);
- CHECK(!i::Isolate::Current()->has_installed_extensions());
+ CHECK(
+ !reinterpret_cast<i::Isolate*>(isolate)->has_installed_extensions());
v8::ExtensionConfiguration extensions(count_, extension_names_);
v8::HandleScope handle_scope(isolate);
v8::Context::New(isolate, &extensions);
- CHECK(i::Isolate::Current()->has_installed_extensions());
+ CHECK(reinterpret_cast<i::Isolate*>(isolate)->has_installed_extensions());
}
isolate->Dispose();
}