| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 v8::HandleScope scope(CcTest::isolate()); | 185 v8::HandleScope scope(CcTest::isolate()); |
| 186 v8::Handle<v8::ObjectTemplate> global = | 186 v8::Handle<v8::ObjectTemplate> global = |
| 187 CreateGlobalTemplate(CcTest::isolate(), Signal, DoLoop); | 187 CreateGlobalTemplate(CcTest::isolate(), Signal, DoLoop); |
| 188 v8::Handle<v8::Context> context = | 188 v8::Handle<v8::Context> context = |
| 189 v8::Context::New(CcTest::isolate(), NULL, global); | 189 v8::Context::New(CcTest::isolate(), NULL, global); |
| 190 v8::Context::Scope context_scope(context); | 190 v8::Context::Scope context_scope(context); |
| 191 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate())); | 191 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate())); |
| 192 // Run a loop that will be infinite if thread termination does not work. | 192 // Run a loop that will be infinite if thread termination does not work. |
| 193 v8::Handle<v8::String> source = v8::String::NewFromUtf8( | 193 v8::Handle<v8::String> source = v8::String::NewFromUtf8( |
| 194 CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }"); | 194 CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }"); |
| 195 i::FLAG_turbo_osr = false; // TODO(titzer): interrupts in TF loops. |
| 195 v8::Script::Compile(source)->Run(); | 196 v8::Script::Compile(source)->Run(); |
| 196 | 197 |
| 197 thread.Join(); | 198 thread.Join(); |
| 198 delete semaphore; | 199 delete semaphore; |
| 199 semaphore = NULL; | 200 semaphore = NULL; |
| 200 } | 201 } |
| 201 | 202 |
| 202 | 203 |
| 203 int call_count = 0; | 204 int call_count = 0; |
| 204 | 205 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 CHECK(false); | 370 CHECK(false); |
| 370 } | 371 } |
| 371 | 372 |
| 372 | 373 |
| 373 void MicrotaskLoopForever(const v8::FunctionCallbackInfo<v8::Value>& info) { | 374 void MicrotaskLoopForever(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 374 v8::Isolate* isolate = info.GetIsolate(); | 375 v8::Isolate* isolate = info.GetIsolate(); |
| 375 v8::HandleScope scope(isolate); | 376 v8::HandleScope scope(isolate); |
| 376 // Enqueue another should-not-run task to ensure we clean out the queue | 377 // Enqueue another should-not-run task to ensure we clean out the queue |
| 377 // when we terminate. | 378 // when we terminate. |
| 378 isolate->EnqueueMicrotask(v8::Function::New(isolate, MicrotaskShouldNotRun)); | 379 isolate->EnqueueMicrotask(v8::Function::New(isolate, MicrotaskShouldNotRun)); |
| 380 i::FLAG_turbo_osr = false; // TODO(titzer): interrupts in TF loops. |
| 379 CompileRun("terminate(); while (true) { }"); | 381 CompileRun("terminate(); while (true) { }"); |
| 380 CHECK(v8::V8::IsExecutionTerminating()); | 382 CHECK(v8::V8::IsExecutionTerminating()); |
| 381 } | 383 } |
| 382 | 384 |
| 383 | 385 |
| 384 TEST(TerminateFromOtherThreadWhileMicrotaskRunning) { | 386 TEST(TerminateFromOtherThreadWhileMicrotaskRunning) { |
| 385 semaphore = new v8::base::Semaphore(0); | 387 semaphore = new v8::base::Semaphore(0); |
| 386 TerminatorThread thread(CcTest::i_isolate()); | 388 TerminatorThread thread(CcTest::i_isolate()); |
| 387 thread.Start(); | 389 thread.Start(); |
| 388 | 390 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 CHECK(try_catch.HasCaught()); | 532 CHECK(try_catch.HasCaught()); |
| 531 CHECK(!v8::V8::IsExecutionTerminating(isolate)); | 533 CHECK(!v8::V8::IsExecutionTerminating(isolate)); |
| 532 CHECK(CcTest::global()->Get(v8_str("terminate"))->IsFunction()); | 534 CHECK(CcTest::global()->Get(v8_str("terminate"))->IsFunction()); |
| 533 // The first stack check after terminate has been re-requested fails. | 535 // The first stack check after terminate has been re-requested fails. |
| 534 CHECK(CompileRun("1 + 1").IsEmpty()); | 536 CHECK(CompileRun("1 + 1").IsEmpty()); |
| 535 CHECK(!v8::V8::IsExecutionTerminating(isolate)); | 537 CHECK(!v8::V8::IsExecutionTerminating(isolate)); |
| 536 // V8 then recovers. | 538 // V8 then recovers. |
| 537 CHECK_EQ(4, CompileRun("2 + 2")->ToInt32()->Int32Value()); | 539 CHECK_EQ(4, CompileRun("2 + 2")->ToInt32()->Int32Value()); |
| 538 CHECK(!v8::V8::IsExecutionTerminating(isolate)); | 540 CHECK(!v8::V8::IsExecutionTerminating(isolate)); |
| 539 } | 541 } |
| OLD | NEW |