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

Unified Diff: test/cctest/test-thread-termination.cc

Issue 1344583002: Continuing removing deprecated function from cctest (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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
Index: test/cctest/test-thread-termination.cc
diff --git a/test/cctest/test-thread-termination.cc b/test/cctest/test-thread-termination.cc
index c0cc1cb8d18ff2366f2630ae7958cc0ddf4c34b9..e92467380703fadd5655f50204e22fc3178b3989 100644
--- a/test/cctest/test-thread-termination.cc
+++ b/test/cctest/test-thread-termination.cc
@@ -25,6 +25,9 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// TODO(mythria): Remove this define after this flag is turned on globally
+#define V8_IMMINENT_DEPRECATION_WARNINGS
+
#include "src/v8.h"
#include "test/cctest/cctest.h"
@@ -40,8 +43,8 @@ void Signal(const v8::FunctionCallbackInfo<v8::Value>& args) {
void TerminateCurrentThread(const v8::FunctionCallbackInfo<v8::Value>& args) {
- CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
- v8::V8::TerminateExecution(args.GetIsolate());
+ CHECK(!args.GetIsolate()->IsExecutionTerminating());
+ args.GetIsolate()->TerminateExecution();
}
@@ -51,70 +54,97 @@ void Fail(const v8::FunctionCallbackInfo<v8::Value>& args) {
void Loop(const v8::FunctionCallbackInfo<v8::Value>& args) {
- CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
- v8::Handle<v8::String> source = v8::String::NewFromUtf8(
- args.GetIsolate(), "try { doloop(); fail(); } catch(e) { fail(); }");
- v8::Handle<v8::Value> result = v8::Script::Compile(source)->Run();
+ CHECK(!args.GetIsolate()->IsExecutionTerminating());
+ v8::Local<v8::String> source =
+ v8::String::NewFromUtf8(args.GetIsolate(),
+ "try { doloop(); fail(); } catch(e) { fail(); }",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked();
+ v8::MaybeLocal<v8::Value> result =
+ v8::Script::Compile(args.GetIsolate()->GetCurrentContext(), source)
+ .ToLocalChecked()
+ ->Run(args.GetIsolate()->GetCurrentContext());
CHECK(result.IsEmpty());
- CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate()));
+ CHECK(args.GetIsolate()->IsExecutionTerminating());
}
void DoLoop(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch(args.GetIsolate());
- CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
- v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
- "function f() {"
- " var term = true;"
- " try {"
- " while(true) {"
- " if (term) terminate();"
- " term = false;"
- " }"
- " fail();"
- " } catch(e) {"
- " fail();"
- " }"
- "}"
- "f()"))->Run();
+ CHECK(!args.GetIsolate()->IsExecutionTerminating());
+ v8::MaybeLocal<v8::Value> result =
+ v8::Script::Compile(args.GetIsolate()->GetCurrentContext(),
+ v8::String::NewFromUtf8(args.GetIsolate(),
+ "function f() {"
+ " var term = true;"
+ " try {"
+ " while(true) {"
+ " if (term) terminate();"
+ " term = false;"
+ " }"
+ " fail();"
+ " } catch(e) {"
+ " fail();"
+ " }"
+ "}"
+ "f()",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked())
+ .ToLocalChecked()
+ ->Run(args.GetIsolate()->GetCurrentContext());
+ CHECK(result.IsEmpty());
mythria 2015/09/14 15:43:59 Added a check to see if the result is empty here i
rmcilroy 2015/09/15 10:29:47 This seems correct to me. The test seems like it i
CHECK(try_catch.HasCaught());
CHECK(try_catch.Exception()->IsNull());
CHECK(try_catch.Message().IsEmpty());
CHECK(!try_catch.CanContinue());
- CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate()));
+ CHECK(args.GetIsolate()->IsExecutionTerminating());
}
void DoLoopNoCall(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch(args.GetIsolate());
- CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
- v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
- "var term = true;"
- "while(true) {"
- " if (term) terminate();"
- " term = false;"
- "}"))->Run();
+ CHECK(!args.GetIsolate()->IsExecutionTerminating());
+ v8::MaybeLocal<v8::Value> result =
+ v8::Script::Compile(args.GetIsolate()->GetCurrentContext(),
+ v8::String::NewFromUtf8(args.GetIsolate(),
+ "var term = true;"
+ "while(true) {"
+ " if (term) terminate();"
+ " term = false;"
+ "}",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked())
+ .ToLocalChecked()
+ ->Run(args.GetIsolate()->GetCurrentContext());
+ CHECK(result.IsEmpty());
CHECK(try_catch.HasCaught());
CHECK(try_catch.Exception()->IsNull());
CHECK(try_catch.Message().IsEmpty());
CHECK(!try_catch.CanContinue());
- CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate()));
+ CHECK(args.GetIsolate()->IsExecutionTerminating());
}
-v8::Handle<v8::ObjectTemplate> CreateGlobalTemplate(
- v8::Isolate* isolate,
- v8::FunctionCallback terminate,
+v8::Local<v8::ObjectTemplate> CreateGlobalTemplate(
+ v8::Isolate* isolate, v8::FunctionCallback terminate,
v8::FunctionCallback doloop) {
- v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
- global->Set(v8::String::NewFromUtf8(isolate, "terminate"),
- v8::FunctionTemplate::New(isolate, terminate));
- global->Set(v8::String::NewFromUtf8(isolate, "fail"),
- v8::FunctionTemplate::New(isolate, Fail));
- global->Set(v8::String::NewFromUtf8(isolate, "loop"),
- v8::FunctionTemplate::New(isolate, Loop));
- global->Set(v8::String::NewFromUtf8(isolate, "doloop"),
- v8::FunctionTemplate::New(isolate, doloop));
+ v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
+ global->Set(
+ v8::String::NewFromUtf8(isolate, "terminate", v8::NewStringType::kNormal)
+ .ToLocalChecked(),
+ v8::FunctionTemplate::New(isolate, terminate));
+ global->Set(
+ v8::String::NewFromUtf8(isolate, "fail", v8::NewStringType::kNormal)
+ .ToLocalChecked(),
+ v8::FunctionTemplate::New(isolate, Fail));
+ global->Set(
+ v8::String::NewFromUtf8(isolate, "loop", v8::NewStringType::kNormal)
+ .ToLocalChecked(),
+ v8::FunctionTemplate::New(isolate, Loop));
+ global->Set(
+ v8::String::NewFromUtf8(isolate, "doloop", v8::NewStringType::kNormal)
+ .ToLocalChecked(),
+ v8::FunctionTemplate::New(isolate, doloop));
return global;
}
@@ -123,19 +153,29 @@ v8::Handle<v8::ObjectTemplate> CreateGlobalTemplate(
// itself.
TEST(TerminateOnlyV8ThreadFromThreadItself) {
v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::ObjectTemplate> global =
+ v8::Local<v8::ObjectTemplate> global =
CreateGlobalTemplate(CcTest::isolate(), TerminateCurrentThread, DoLoop);
- v8::Handle<v8::Context> context =
+ v8::Local<v8::Context> context =
v8::Context::New(CcTest::isolate(), NULL, global);
v8::Context::Scope context_scope(context);
- CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
+ CHECK(!CcTest::isolate()->IsExecutionTerminating());
// Run a loop that will be infinite if thread termination does not work.
- v8::Handle<v8::String> source = v8::String::NewFromUtf8(
- CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }");
- v8::Script::Compile(source)->Run();
+ v8::Local<v8::String> source =
+ v8::String::NewFromUtf8(CcTest::isolate(),
+ "try { loop(); fail(); } catch(e) { fail(); }",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked();
+ v8::MaybeLocal<v8::Value> result =
+ v8::Script::Compile(CcTest::isolate()->GetCurrentContext(), source)
+ .ToLocalChecked()
+ ->Run(CcTest::isolate()->GetCurrentContext());
+ CHECK(result.IsEmpty());
// Test that we can run the code again after thread termination.
- CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
- v8::Script::Compile(source)->Run();
+ CHECK(!CcTest::isolate()->IsExecutionTerminating());
+ result = v8::Script::Compile(CcTest::isolate()->GetCurrentContext(), source)
+ .ToLocalChecked()
+ ->Run(CcTest::isolate()->GetCurrentContext());
rmcilroy 2015/09/15 10:29:47 nit - how about having a helper CompileAndRun func
mythria 2015/09/17 11:21:48 Done.
+ CHECK(result.IsEmpty());
}
@@ -143,19 +183,29 @@ TEST(TerminateOnlyV8ThreadFromThreadItself) {
// itself in a loop that performs no calls.
TEST(TerminateOnlyV8ThreadFromThreadItselfNoLoop) {
v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(
+ v8::Local<v8::ObjectTemplate> global = CreateGlobalTemplate(
CcTest::isolate(), TerminateCurrentThread, DoLoopNoCall);
- v8::Handle<v8::Context> context =
+ v8::Local<v8::Context> context =
v8::Context::New(CcTest::isolate(), NULL, global);
v8::Context::Scope context_scope(context);
- CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
+ CHECK(!CcTest::isolate()->IsExecutionTerminating());
// Run a loop that will be infinite if thread termination does not work.
- v8::Handle<v8::String> source = v8::String::NewFromUtf8(
- CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }");
- v8::Script::Compile(source)->Run();
- CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
+ v8::Local<v8::String> source =
+ v8::String::NewFromUtf8(CcTest::isolate(),
+ "try { loop(); fail(); } catch(e) { fail(); }",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked();
+ v8::MaybeLocal<v8::Value> result =
+ v8::Script::Compile(CcTest::isolate()->GetCurrentContext(), source)
+ .ToLocalChecked()
+ ->Run(CcTest::isolate()->GetCurrentContext());
+ CHECK(result.IsEmpty());
+ CHECK(!CcTest::isolate()->IsExecutionTerminating());
// Test that we can run the code again after thread termination.
- v8::Script::Compile(source)->Run();
+ result = v8::Script::Compile(CcTest::isolate()->GetCurrentContext(), source)
+ .ToLocalChecked()
+ ->Run(CcTest::isolate()->GetCurrentContext());
+ CHECK(result.IsEmpty());
}
@@ -166,8 +216,8 @@ class TerminatorThread : public v8::base::Thread {
isolate_(reinterpret_cast<v8::Isolate*>(isolate)) {}
void Run() {
semaphore->Wait();
- CHECK(!v8::V8::IsExecutionTerminating(isolate_));
- v8::V8::TerminateExecution(isolate_);
+ CHECK(!isolate_->IsExecutionTerminating());
+ isolate_->TerminateExecution();
}
private:
@@ -183,17 +233,23 @@ TEST(TerminateOnlyV8ThreadFromOtherThread) {
thread.Start();
v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::ObjectTemplate> global =
+ v8::Local<v8::ObjectTemplate> global =
CreateGlobalTemplate(CcTest::isolate(), Signal, DoLoop);
- v8::Handle<v8::Context> context =
+ v8::Local<v8::Context> context =
v8::Context::New(CcTest::isolate(), NULL, global);
v8::Context::Scope context_scope(context);
- CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
+ CHECK(!CcTest::isolate()->IsExecutionTerminating());
// Run a loop that will be infinite if thread termination does not work.
- v8::Handle<v8::String> source = v8::String::NewFromUtf8(
- CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }");
- v8::Script::Compile(source)->Run();
-
+ v8::Local<v8::String> source =
+ v8::String::NewFromUtf8(CcTest::isolate(),
+ "try { loop(); fail(); } catch(e) { fail(); }",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked();
+ v8::MaybeLocal<v8::Value> result =
+ v8::Script::Compile(CcTest::isolate()->GetCurrentContext(), source)
+ .ToLocalChecked()
+ ->Run(CcTest::isolate()->GetCurrentContext());
+ CHECK(result.IsEmpty());
thread.Join();
delete semaphore;
semaphore = NULL;
@@ -205,22 +261,28 @@ int call_count = 0;
void TerminateOrReturnObject(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (++call_count == 10) {
- CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
- v8::V8::TerminateExecution(args.GetIsolate());
+ CHECK(!args.GetIsolate()->IsExecutionTerminating());
+ args.GetIsolate()->TerminateExecution();
return;
}
v8::Local<v8::Object> result = v8::Object::New(args.GetIsolate());
- result->Set(v8::String::NewFromUtf8(args.GetIsolate(), "x"),
- v8::Integer::New(args.GetIsolate(), 42));
+ CHECK(result->Set(args.GetIsolate()->GetCurrentContext(),
+ v8::String::NewFromUtf8(args.GetIsolate(), "x",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked(),
+ v8::Integer::New(args.GetIsolate(), 42))
+ .FromJust());
args.GetReturnValue().Set(result);
}
void LoopGetProperty(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch(args.GetIsolate());
- CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
- v8::Script::Compile(
- v8::String::NewFromUtf8(args.GetIsolate(),
+ CHECK(!args.GetIsolate()->IsExecutionTerminating());
+ v8::MaybeLocal<v8::Value> result =
+ v8::Script::Compile(args.GetIsolate()->GetCurrentContext(),
+ v8::String::NewFromUtf8(
+ args.GetIsolate(),
"function f() {"
" try {"
" while(true) {"
@@ -232,12 +294,17 @@ void LoopGetProperty(const v8::FunctionCallbackInfo<v8::Value>& args) {
" fail();"
" }"
"}"
- "f()"))->Run();
+ "f()",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked())
+ .ToLocalChecked()
+ ->Run(args.GetIsolate()->GetCurrentContext());
+ CHECK(result.IsEmpty());
CHECK(try_catch.HasCaught());
CHECK(try_catch.Exception()->IsNull());
CHECK(try_catch.Message().IsEmpty());
CHECK(!try_catch.CanContinue());
- CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate()));
+ CHECK(args.GetIsolate()->IsExecutionTerminating());
}
@@ -246,28 +313,42 @@ void LoopGetProperty(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(TerminateLoadICException) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
+ global->Set(v8::String::NewFromUtf8(isolate, "terminate_or_return_object",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked(),
rmcilroy 2015/09/15 10:29:47 nit - you could also have a helper for: v8::Local
mythria 2015/09/17 11:21:48 There was already a helper function. I did not not
mythria 2015/09/17 11:21:48 Done.
+ v8::FunctionTemplate::New(isolate, TerminateOrReturnObject));
+ global->Set(
+ v8::String::NewFromUtf8(isolate, "fail", v8::NewStringType::kNormal)
+ .ToLocalChecked(),
+ v8::FunctionTemplate::New(isolate, Fail));
global->Set(
- v8::String::NewFromUtf8(isolate, "terminate_or_return_object"),
- v8::FunctionTemplate::New(isolate, TerminateOrReturnObject));
- global->Set(v8::String::NewFromUtf8(isolate, "fail"),
- v8::FunctionTemplate::New(isolate, Fail));
- global->Set(v8::String::NewFromUtf8(isolate, "loop"),
- v8::FunctionTemplate::New(isolate, LoopGetProperty));
-
- v8::Handle<v8::Context> context =
- v8::Context::New(isolate, NULL, global);
+ v8::String::NewFromUtf8(isolate, "loop", v8::NewStringType::kNormal)
+ .ToLocalChecked(),
+ v8::FunctionTemplate::New(isolate, LoopGetProperty));
+
+ v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
v8::Context::Scope context_scope(context);
- CHECK(!v8::V8::IsExecutionTerminating(isolate));
+ CHECK(!isolate->IsExecutionTerminating());
// Run a loop that will be infinite if thread termination does not work.
- v8::Handle<v8::String> source = v8::String::NewFromUtf8(
- isolate, "try { loop(); fail(); } catch(e) { fail(); }");
+ v8::Local<v8::String> source =
+ v8::String::NewFromUtf8(isolate,
+ "try { loop(); fail(); } catch(e) { fail(); }",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked();
call_count = 0;
- v8::Script::Compile(source)->Run();
+ v8::MaybeLocal<v8::Value> result =
+ v8::Script::Compile(isolate->GetCurrentContext(), source)
+ .ToLocalChecked()
+ ->Run(isolate->GetCurrentContext());
+ CHECK(result.IsEmpty());
// Test that we can run the code again after thread termination.
- CHECK(!v8::V8::IsExecutionTerminating(isolate));
+ CHECK(!isolate->IsExecutionTerminating());
call_count = 0;
- v8::Script::Compile(source)->Run();
+ result = v8::Script::Compile(isolate->GetCurrentContext(), source)
+ .ToLocalChecked()
+ ->Run(isolate->GetCurrentContext());
+ CHECK(result.IsEmpty());
}
@@ -277,17 +358,23 @@ v8::Persistent<v8::String> reenter_script_2;
void ReenterAfterTermination(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch(args.GetIsolate());
v8::Isolate* isolate = args.GetIsolate();
- CHECK(!v8::V8::IsExecutionTerminating(isolate));
+ CHECK(!isolate->IsExecutionTerminating());
v8::Local<v8::String> script =
v8::Local<v8::String>::New(isolate, reenter_script_1);
- v8::Script::Compile(script)->Run();
+ v8::MaybeLocal<v8::Value> result =
+ v8::Script::Compile(isolate->GetCurrentContext(), script)
+ .ToLocalChecked()
+ ->Run(isolate->GetCurrentContext());
+ CHECK(result.IsEmpty());
CHECK(try_catch.HasCaught());
CHECK(try_catch.Exception()->IsNull());
CHECK(try_catch.Message().IsEmpty());
CHECK(!try_catch.CanContinue());
- CHECK(v8::V8::IsExecutionTerminating(isolate));
+ CHECK(isolate->IsExecutionTerminating());
script = v8::Local<v8::String>::New(isolate, reenter_script_2);
- v8::Script::Compile(script)->Run();
+ v8::MaybeLocal<v8::Script> compiled_script =
+ v8::Script::Compile(isolate->GetCurrentContext(), script);
+ CHECK(compiled_script.IsEmpty());
}
@@ -296,12 +383,11 @@ void ReenterAfterTermination(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(TerminateAndReenterFromThreadItself) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(
+ v8::Local<v8::ObjectTemplate> global = CreateGlobalTemplate(
isolate, TerminateCurrentThread, ReenterAfterTermination);
- v8::Handle<v8::Context> context =
- v8::Context::New(isolate, NULL, global);
+ v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
v8::Context::Scope context_scope(context);
- CHECK(!v8::V8::IsExecutionTerminating());
+ CHECK(!v8::Isolate::GetCurrent()->IsExecutionTerminating());
// Create script strings upfront as it won't work when terminating.
reenter_script_1.Reset(isolate, v8_str(
"function f() {"
@@ -319,7 +405,7 @@ TEST(TerminateAndReenterFromThreadItself) {
"f()"));
reenter_script_2.Reset(isolate, v8_str("function f() { fail(); } f()"));
CompileRun("try { loop(); fail(); } catch(e) { fail(); }");
- CHECK(!v8::V8::IsExecutionTerminating(isolate));
+ CHECK(!isolate->IsExecutionTerminating());
// Check we can run JS again after termination.
CHECK(CompileRun("function f() { return true; } f()")->IsTrue());
reenter_script_1.Reset();
@@ -329,22 +415,29 @@ TEST(TerminateAndReenterFromThreadItself) {
void DoLoopCancelTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch(args.GetIsolate());
- CHECK(!v8::V8::IsExecutionTerminating());
- v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
- "var term = true;"
- "while(true) {"
- " if (term) terminate();"
- " term = false;"
- "}"
- "fail();"))->Run();
+ CHECK(!v8::Isolate::GetCurrent()->IsExecutionTerminating());
+ v8::MaybeLocal<v8::Value> result =
+ v8::Script::Compile(args.GetIsolate()->GetCurrentContext(),
+ v8::String::NewFromUtf8(args.GetIsolate(),
+ "var term = true;"
+ "while(true) {"
+ " if (term) terminate();"
+ " term = false;"
+ "}"
+ "fail();",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked())
+ .ToLocalChecked()
+ ->Run(args.GetIsolate()->GetCurrentContext());
+ CHECK(result.IsEmpty());
CHECK(try_catch.HasCaught());
CHECK(try_catch.Exception()->IsNull());
CHECK(try_catch.Message().IsEmpty());
CHECK(!try_catch.CanContinue());
- CHECK(v8::V8::IsExecutionTerminating());
+ CHECK(v8::Isolate::GetCurrent()->IsExecutionTerminating());
CHECK(try_catch.HasTerminated());
- v8::V8::CancelTerminateExecution(CcTest::isolate());
- CHECK(!v8::V8::IsExecutionTerminating());
+ CcTest::isolate()->CancelTerminateExecution();
+ CHECK(!v8::Isolate::GetCurrent()->IsExecutionTerminating());
}
@@ -353,15 +446,23 @@ void DoLoopCancelTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(TerminateCancelTerminateFromThreadItself) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(
+ v8::Local<v8::ObjectTemplate> global = CreateGlobalTemplate(
isolate, TerminateCurrentThread, DoLoopCancelTerminate);
- v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, global);
+ v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
v8::Context::Scope context_scope(context);
- CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
- v8::Handle<v8::String> source = v8::String::NewFromUtf8(
- isolate, "try { doloop(); } catch(e) { fail(); } 'completed';");
+ CHECK(!CcTest::isolate()->IsExecutionTerminating());
+ v8::Local<v8::String> source =
+ v8::String::NewFromUtf8(
+ isolate, "try { doloop(); } catch(e) { fail(); } 'completed';",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked();
// Check that execution completed with correct return value.
- CHECK(v8::Script::Compile(source)->Run()->Equals(v8_str("completed")));
+ CHECK(v8::Script::Compile(isolate->GetCurrentContext(), source)
+ .ToLocalChecked()
+ ->Run(isolate->GetCurrentContext())
+ .ToLocalChecked()
+ ->Equals(isolate->GetCurrentContext(), v8_str("completed"))
+ .FromJust());
}
@@ -375,9 +476,11 @@ void MicrotaskLoopForever(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::HandleScope scope(isolate);
// Enqueue another should-not-run task to ensure we clean out the queue
// when we terminate.
- isolate->EnqueueMicrotask(v8::Function::New(isolate, MicrotaskShouldNotRun));
+ isolate->EnqueueMicrotask(
+ v8::Function::New(isolate->GetCurrentContext(), MicrotaskShouldNotRun)
+ .ToLocalChecked());
CompileRun("terminate(); while (true) { }");
- CHECK(v8::V8::IsExecutionTerminating());
+ CHECK(v8::Isolate::GetCurrent()->IsExecutionTerminating());
}
@@ -389,18 +492,22 @@ TEST(TerminateFromOtherThreadWhileMicrotaskRunning) {
v8::Isolate* isolate = CcTest::isolate();
isolate->SetAutorunMicrotasks(false);
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> global =
+ v8::Local<v8::ObjectTemplate> global =
CreateGlobalTemplate(CcTest::isolate(), Signal, DoLoop);
- v8::Handle<v8::Context> context =
+ v8::Local<v8::Context> context =
v8::Context::New(CcTest::isolate(), NULL, global);
v8::Context::Scope context_scope(context);
- isolate->EnqueueMicrotask(v8::Function::New(isolate, MicrotaskLoopForever));
+ isolate->EnqueueMicrotask(
+ v8::Function::New(isolate->GetCurrentContext(), MicrotaskLoopForever)
+ .ToLocalChecked());
// The second task should never be run because we bail out if we're
// terminating.
- isolate->EnqueueMicrotask(v8::Function::New(isolate, MicrotaskShouldNotRun));
+ isolate->EnqueueMicrotask(
+ v8::Function::New(isolate->GetCurrentContext(), MicrotaskShouldNotRun)
+ .ToLocalChecked());
isolate->RunMicrotasks();
- v8::V8::CancelTerminateExecution(isolate);
+ isolate->CancelTerminateExecution();
isolate->RunMicrotasks(); // should not run MicrotaskShouldNotRun
thread.Join();
@@ -420,9 +527,9 @@ static void CounterCallback(v8::Isolate* isolate, void* data) {
TEST(PostponeTerminateException) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> global =
+ v8::Local<v8::ObjectTemplate> global =
CreateGlobalTemplate(CcTest::isolate(), TerminateCurrentThread, DoLoop);
- v8::Handle<v8::Context> context =
+ v8::Local<v8::Context> context =
v8::Context::New(CcTest::isolate(), NULL, global);
v8::Context::Scope context_scope(context);
@@ -468,9 +575,9 @@ TEST(PostponeTerminateException) {
TEST(ErrorObjectAfterTermination) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
+ v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
- v8::V8::TerminateExecution(isolate);
+ isolate->TerminateExecution();
v8::Local<v8::Value> error = v8::Exception::Error(v8_str("error"));
// TODO(yangguo): crbug/403509. Check for empty handle instead.
CHECK(error->IsUndefined());
@@ -478,16 +585,17 @@ TEST(ErrorObjectAfterTermination) {
void InnerTryCallTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
- CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
- v8::Handle<v8::Object> global = CcTest::global();
- v8::Handle<v8::Function> loop =
- v8::Handle<v8::Function>::Cast(global->Get(v8_str("loop")));
+ CHECK(!args.GetIsolate()->IsExecutionTerminating());
+ v8::Local<v8::Object> global = CcTest::global();
+ v8::Local<v8::Function> loop = v8::Local<v8::Function>::Cast(
+ global->Get(CcTest::isolate()->GetCurrentContext(), v8_str("loop"))
+ .ToLocalChecked());
i::MaybeHandle<i::Object> result =
i::Execution::TryCall(v8::Utils::OpenHandle((*loop)),
v8::Utils::OpenHandle((*global)), 0, NULL, NULL);
CHECK(result.is_null());
// TryCall ignores terminate execution, but rerequests the interrupt.
- CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
+ CHECK(!args.GetIsolate()->IsExecutionTerminating());
CHECK(CompileRun("1 + 1;").IsEmpty());
}
@@ -495,12 +603,12 @@ void InnerTryCallTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(TerminationInInnerTryCall) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> global_template = CreateGlobalTemplate(
+ v8::Local<v8::ObjectTemplate> global_template = CreateGlobalTemplate(
CcTest::isolate(), TerminateCurrentThread, DoLoopNoCall);
global_template->Set(
v8_str("inner_try_call_terminate"),
v8::FunctionTemplate::New(isolate, InnerTryCallTerminate));
- v8::Handle<v8::Context> context =
+ v8::Local<v8::Context> context =
v8::Context::New(CcTest::isolate(), NULL, global_template);
v8::Context::Scope context_scope(context);
{
@@ -508,8 +616,12 @@ TEST(TerminationInInnerTryCall) {
CompileRun("inner_try_call_terminate()");
CHECK(try_catch.HasTerminated());
}
- CHECK_EQ(4, CompileRun("2 + 2")->ToInt32()->Int32Value());
- CHECK(!v8::V8::IsExecutionTerminating());
+ CHECK_EQ(4, CompileRun("2 + 2")
+ ->ToInt32(v8::Isolate::GetCurrent()->GetCurrentContext())
+ .ToLocalChecked()
+ ->Int32Value(v8::Isolate::GetCurrent()->GetCurrentContext())
+ .FromJust());
+ CHECK(!v8::Isolate::GetCurrent()->IsExecutionTerminating());
}
@@ -517,23 +629,30 @@ TEST(TerminateAndTryCall) {
i::FLAG_allow_natives_syntax = true;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(
+ v8::Local<v8::ObjectTemplate> global = CreateGlobalTemplate(
isolate, TerminateCurrentThread, DoLoopCancelTerminate);
- v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, global);
+ v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
v8::Context::Scope context_scope(context);
- CHECK(!v8::V8::IsExecutionTerminating(isolate));
+ CHECK(!isolate->IsExecutionTerminating());
v8::TryCatch try_catch(isolate);
- CHECK(!v8::V8::IsExecutionTerminating(isolate));
+ CHECK(!isolate->IsExecutionTerminating());
// Terminate execution has been triggered inside TryCall, but re-requested
// to trigger later.
CHECK(CompileRun("terminate(); reference_error();").IsEmpty());
CHECK(try_catch.HasCaught());
- CHECK(!v8::V8::IsExecutionTerminating(isolate));
- CHECK(CcTest::global()->Get(v8_str("terminate"))->IsFunction());
+ CHECK(!isolate->IsExecutionTerminating());
+ CHECK(CcTest::global()
+ ->Get(isolate->GetCurrentContext(), v8_str("terminate"))
+ .ToLocalChecked()
+ ->IsFunction());
// The first stack check after terminate has been re-requested fails.
CHECK(CompileRun("1 + 1").IsEmpty());
- CHECK(!v8::V8::IsExecutionTerminating(isolate));
+ CHECK(!isolate->IsExecutionTerminating());
// V8 then recovers.
- CHECK_EQ(4, CompileRun("2 + 2")->ToInt32()->Int32Value());
- CHECK(!v8::V8::IsExecutionTerminating(isolate));
+ CHECK_EQ(4, CompileRun("2 + 2")
+ ->ToInt32(v8::Isolate::GetCurrent()->GetCurrentContext())
+ .ToLocalChecked()
+ ->Int32Value(v8::Isolate::GetCurrent()->GetCurrentContext())
+ .FromJust());
+ CHECK(!isolate->IsExecutionTerminating());
}

Powered by Google App Engine
This is Rietveld 408576698