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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 v8::HandleScope scope(CcTest::isolate()); | 145 v8::HandleScope scope(CcTest::isolate()); |
146 v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate( | 146 v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate( |
147 CcTest::isolate(), TerminateCurrentThread, DoLoopNoCall); | 147 CcTest::isolate(), TerminateCurrentThread, DoLoopNoCall); |
148 v8::Handle<v8::Context> context = | 148 v8::Handle<v8::Context> context = |
149 v8::Context::New(CcTest::isolate(), NULL, global); | 149 v8::Context::New(CcTest::isolate(), NULL, global); |
150 v8::Context::Scope context_scope(context); | 150 v8::Context::Scope context_scope(context); |
151 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate())); | 151 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate())); |
152 // Run a loop that will be infinite if thread termination does not work. | 152 // Run a loop that will be infinite if thread termination does not work. |
153 v8::Handle<v8::String> source = v8::String::NewFromUtf8( | 153 v8::Handle<v8::String> source = v8::String::NewFromUtf8( |
154 CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }"); | 154 CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }"); |
| 155 i::FLAG_turbo_osr = false; // TODO(titzer): interrupts in TF loops. |
155 v8::Script::Compile(source)->Run(); | 156 v8::Script::Compile(source)->Run(); |
156 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate())); | 157 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate())); |
157 // Test that we can run the code again after thread termination. | 158 // Test that we can run the code again after thread termination. |
158 v8::Script::Compile(source)->Run(); | 159 v8::Script::Compile(source)->Run(); |
159 } | 160 } |
160 | 161 |
161 | 162 |
162 class TerminatorThread : public v8::base::Thread { | 163 class TerminatorThread : public v8::base::Thread { |
163 public: | 164 public: |
164 explicit TerminatorThread(i::Isolate* isolate) | 165 explicit TerminatorThread(i::Isolate* isolate) |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 TEST(TerminateCancelTerminateFromThreadItself) { | 355 TEST(TerminateCancelTerminateFromThreadItself) { |
355 v8::Isolate* isolate = CcTest::isolate(); | 356 v8::Isolate* isolate = CcTest::isolate(); |
356 v8::HandleScope scope(isolate); | 357 v8::HandleScope scope(isolate); |
357 v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate( | 358 v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate( |
358 isolate, TerminateCurrentThread, DoLoopCancelTerminate); | 359 isolate, TerminateCurrentThread, DoLoopCancelTerminate); |
359 v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, global); | 360 v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, global); |
360 v8::Context::Scope context_scope(context); | 361 v8::Context::Scope context_scope(context); |
361 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate())); | 362 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate())); |
362 v8::Handle<v8::String> source = v8::String::NewFromUtf8( | 363 v8::Handle<v8::String> source = v8::String::NewFromUtf8( |
363 isolate, "try { doloop(); } catch(e) { fail(); } 'completed';"); | 364 isolate, "try { doloop(); } catch(e) { fail(); } 'completed';"); |
| 365 i::FLAG_turbo_osr = false; // TODO(titzer): interrupts in TF loops. |
364 // Check that execution completed with correct return value. | 366 // Check that execution completed with correct return value. |
365 CHECK(v8::Script::Compile(source)->Run()->Equals(v8_str("completed"))); | 367 CHECK(v8::Script::Compile(source)->Run()->Equals(v8_str("completed"))); |
366 } | 368 } |
367 | 369 |
368 | 370 |
369 void MicrotaskShouldNotRun(const v8::FunctionCallbackInfo<v8::Value>& info) { | 371 void MicrotaskShouldNotRun(const v8::FunctionCallbackInfo<v8::Value>& info) { |
370 CHECK(false); | 372 CHECK(false); |
371 } | 373 } |
372 | 374 |
373 | 375 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 v8::Handle<v8::ObjectTemplate> global_template = CreateGlobalTemplate( | 502 v8::Handle<v8::ObjectTemplate> global_template = CreateGlobalTemplate( |
501 CcTest::isolate(), TerminateCurrentThread, DoLoopNoCall); | 503 CcTest::isolate(), TerminateCurrentThread, DoLoopNoCall); |
502 global_template->Set( | 504 global_template->Set( |
503 v8_str("inner_try_call_terminate"), | 505 v8_str("inner_try_call_terminate"), |
504 v8::FunctionTemplate::New(isolate, InnerTryCallTerminate)); | 506 v8::FunctionTemplate::New(isolate, InnerTryCallTerminate)); |
505 v8::Handle<v8::Context> context = | 507 v8::Handle<v8::Context> context = |
506 v8::Context::New(CcTest::isolate(), NULL, global_template); | 508 v8::Context::New(CcTest::isolate(), NULL, global_template); |
507 v8::Context::Scope context_scope(context); | 509 v8::Context::Scope context_scope(context); |
508 { | 510 { |
509 v8::TryCatch try_catch; | 511 v8::TryCatch try_catch; |
| 512 i::FLAG_turbo_osr = false; // TODO(titzer): interrupts in TF loops. |
510 CompileRun("inner_try_call_terminate()"); | 513 CompileRun("inner_try_call_terminate()"); |
511 CHECK(try_catch.HasTerminated()); | 514 CHECK(try_catch.HasTerminated()); |
512 } | 515 } |
513 CHECK_EQ(4, CompileRun("2 + 2")->ToInt32()->Int32Value()); | 516 CHECK_EQ(4, CompileRun("2 + 2")->ToInt32()->Int32Value()); |
514 CHECK(!v8::V8::IsExecutionTerminating()); | 517 CHECK(!v8::V8::IsExecutionTerminating()); |
515 } | 518 } |
516 | 519 |
517 | 520 |
518 TEST(TerminateAndTryCall) { | 521 TEST(TerminateAndTryCall) { |
519 i::FLAG_allow_natives_syntax = true; | 522 i::FLAG_allow_natives_syntax = true; |
(...skipping 12 matching lines...) Expand all Loading... |
532 CHECK(try_catch.HasCaught()); | 535 CHECK(try_catch.HasCaught()); |
533 CHECK(!v8::V8::IsExecutionTerminating(isolate)); | 536 CHECK(!v8::V8::IsExecutionTerminating(isolate)); |
534 CHECK(CcTest::global()->Get(v8_str("terminate"))->IsFunction()); | 537 CHECK(CcTest::global()->Get(v8_str("terminate"))->IsFunction()); |
535 // The first stack check after terminate has been re-requested fails. | 538 // The first stack check after terminate has been re-requested fails. |
536 CHECK(CompileRun("1 + 1").IsEmpty()); | 539 CHECK(CompileRun("1 + 1").IsEmpty()); |
537 CHECK(!v8::V8::IsExecutionTerminating(isolate)); | 540 CHECK(!v8::V8::IsExecutionTerminating(isolate)); |
538 // V8 then recovers. | 541 // V8 then recovers. |
539 CHECK_EQ(4, CompileRun("2 + 2")->ToInt32()->Int32Value()); | 542 CHECK_EQ(4, CompileRun("2 + 2")->ToInt32()->Int32Value()); |
540 CHECK(!v8::V8::IsExecutionTerminating(isolate)); | 543 CHECK(!v8::V8::IsExecutionTerminating(isolate)); |
541 } | 544 } |
OLD | NEW |