| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 CHECK(v8::Isolate::GetCurrent()->IsExecutionTerminating()); | 396 CHECK(v8::Isolate::GetCurrent()->IsExecutionTerminating()); |
| 397 } | 397 } |
| 398 | 398 |
| 399 | 399 |
| 400 TEST(TerminateFromOtherThreadWhileMicrotaskRunning) { | 400 TEST(TerminateFromOtherThreadWhileMicrotaskRunning) { |
| 401 semaphore = new v8::base::Semaphore(0); | 401 semaphore = new v8::base::Semaphore(0); |
| 402 TerminatorThread thread(CcTest::i_isolate()); | 402 TerminatorThread thread(CcTest::i_isolate()); |
| 403 thread.Start(); | 403 thread.Start(); |
| 404 | 404 |
| 405 v8::Isolate* isolate = CcTest::isolate(); | 405 v8::Isolate* isolate = CcTest::isolate(); |
| 406 isolate->SetMicrotasksPolicy(v8::MicrotasksPolicy::kExplicit); | 406 isolate->SetAutorunMicrotasks(false); |
| 407 v8::HandleScope scope(isolate); | 407 v8::HandleScope scope(isolate); |
| 408 v8::Local<v8::ObjectTemplate> global = | 408 v8::Local<v8::ObjectTemplate> global = |
| 409 CreateGlobalTemplate(CcTest::isolate(), Signal, DoLoop); | 409 CreateGlobalTemplate(CcTest::isolate(), Signal, DoLoop); |
| 410 v8::Local<v8::Context> context = | 410 v8::Local<v8::Context> context = |
| 411 v8::Context::New(CcTest::isolate(), NULL, global); | 411 v8::Context::New(CcTest::isolate(), NULL, global); |
| 412 v8::Context::Scope context_scope(context); | 412 v8::Context::Scope context_scope(context); |
| 413 isolate->EnqueueMicrotask( | 413 isolate->EnqueueMicrotask( |
| 414 v8::Function::New(isolate->GetCurrentContext(), MicrotaskLoopForever) | 414 v8::Function::New(isolate->GetCurrentContext(), MicrotaskLoopForever) |
| 415 .ToLocalChecked()); | 415 .ToLocalChecked()); |
| 416 // The second task should never be run because we bail out if we're | 416 // The second task should never be run because we bail out if we're |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 CHECK(value->IsFunction()); | 559 CHECK(value->IsFunction()); |
| 560 // The first stack check after terminate has been re-requested fails. | 560 // The first stack check after terminate has been re-requested fails. |
| 561 CHECK(CompileRun("1 + 1").IsEmpty()); | 561 CHECK(CompileRun("1 + 1").IsEmpty()); |
| 562 CHECK(!isolate->IsExecutionTerminating()); | 562 CHECK(!isolate->IsExecutionTerminating()); |
| 563 // V8 then recovers. | 563 // V8 then recovers. |
| 564 v8::Maybe<int32_t> result = CompileRun("2 + 2")->Int32Value( | 564 v8::Maybe<int32_t> result = CompileRun("2 + 2")->Int32Value( |
| 565 v8::Isolate::GetCurrent()->GetCurrentContext()); | 565 v8::Isolate::GetCurrent()->GetCurrentContext()); |
| 566 CHECK_EQ(4, result.FromJust()); | 566 CHECK_EQ(4, result.FromJust()); |
| 567 CHECK(!isolate->IsExecutionTerminating()); | 567 CHECK(!isolate->IsExecutionTerminating()); |
| 568 } | 568 } |
| OLD | NEW |