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

Side by Side Diff: test/cctest/test-thread-termination.cc

Issue 2123005: Add termination of the script to the bailout check. (Closed)
Patch Set: Same patch, moved to writable enlistment. Created 10 years, 7 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 unified diff | Download patch
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 v8::Handle<v8::String> source = 301 v8::Handle<v8::String> source =
302 v8::String::New("try { loop(); fail(); } catch(e) { fail(); }"); 302 v8::String::New("try { loop(); fail(); } catch(e) { fail(); }");
303 call_count = 0; 303 call_count = 0;
304 v8::Script::Compile(source)->Run(); 304 v8::Script::Compile(source)->Run();
305 // Test that we can run the code again after thread termination. 305 // Test that we can run the code again after thread termination.
306 CHECK(!v8::V8::IsExecutionTerminating()); 306 CHECK(!v8::V8::IsExecutionTerminating());
307 call_count = 0; 307 call_count = 0;
308 v8::Script::Compile(source)->Run(); 308 v8::Script::Compile(source)->Run();
309 context.Dispose(); 309 context.Dispose();
310 } 310 }
311
312 v8::Handle<v8::Value> ReenterAfterTermination(const v8::Arguments& args) {
313 v8::TryCatch try_catch;
314 CHECK(!v8::V8::IsExecutionTerminating());
315 v8::Script::Compile(v8::String::New("function f() {"
316 " var term = true;"
317 " try {"
318 " while(true) {"
319 " if (term) terminate();"
320 " term = false;"
321 " }"
322 " fail();"
323 " } catch(e) {"
324 " fail();"
325 " }"
326 "}"
327 "f()"))->Run();
328 CHECK(try_catch.HasCaught());
329 CHECK(try_catch.Exception()->IsNull());
330 CHECK(try_catch.Message().IsEmpty());
331 CHECK(!try_catch.CanContinue());
332 CHECK(v8::V8::IsExecutionTerminating());
333 v8::Script::Compile(v8::String::New("function f() { fail(); } f()"))->Run();
334 return v8::Undefined();
335 }
336
337 // Test that reentry into V8 while the termination exception is still pending
338 // (has not yet unwound the 0-level JS frame) does not crash.
339 TEST(TerminateAndReenterFromThreadItself) {
340 v8::HandleScope scope;
341 v8::Handle<v8::ObjectTemplate> global =
342 CreateGlobalTemplate(TerminateCurrentThread, ReenterAfterTermination);
343 v8::Persistent<v8::Context> context = v8::Context::New(NULL, global);
344 v8::Context::Scope context_scope(context);
345 CHECK(!v8::V8::IsExecutionTerminating());
346 v8::Handle<v8::String> source =
347 v8::String::New("try { loop(); fail(); } catch(e) { fail(); }");
348 v8::Script::Compile(source)->Run();
349 CHECK(!v8::V8::IsExecutionTerminating());
350 // Check we can run JS again after termination.
351 CHECK(v8::Script::Compile(v8::String::New("function f() { return true; }"
352 "f()"))->Run()->IsTrue());
353 context.Dispose();
354 }
355
OLDNEW
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698