| OLD | NEW |
| 1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-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 8656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8667 static v8::Handle<Value> SpaghettiIncident(const v8::Arguments& args) { | 8667 static v8::Handle<Value> SpaghettiIncident(const v8::Arguments& args) { |
| 8668 v8::HandleScope scope; | 8668 v8::HandleScope scope; |
| 8669 v8::TryCatch tc; | 8669 v8::TryCatch tc; |
| 8670 v8::Handle<v8::String> str = args[0]->ToString(); | 8670 v8::Handle<v8::String> str = args[0]->ToString(); |
| 8671 if (tc.HasCaught()) | 8671 if (tc.HasCaught()) |
| 8672 return tc.ReThrow(); | 8672 return tc.ReThrow(); |
| 8673 return v8::Undefined(); | 8673 return v8::Undefined(); |
| 8674 } | 8674 } |
| 8675 | 8675 |
| 8676 | 8676 |
| 8677 // Test that a stack overflow can be propagated down through a spaghetti | 8677 // Test that an exception can be propagated down through a spaghetti |
| 8678 // stack using ReThrow. | 8678 // stack using ReThrow. |
| 8679 THREADED_TEST(SpaghettiStackOverflow) { | 8679 THREADED_TEST(SpaghettiStackReThrow) { |
| 8680 v8::HandleScope scope; | 8680 v8::HandleScope scope; |
| 8681 LocalContext context; | 8681 LocalContext context; |
| 8682 context->Global()->Set( | 8682 context->Global()->Set( |
| 8683 v8::String::New("s"), | 8683 v8::String::New("s"), |
| 8684 v8::FunctionTemplate::New(SpaghettiIncident)->GetFunction()); | 8684 v8::FunctionTemplate::New(SpaghettiIncident)->GetFunction()); |
| 8685 v8::TryCatch try_catch; | 8685 v8::TryCatch try_catch; |
| 8686 CompileRun("var o = {toString: function () {return s(o);}}; s(o);"); | 8686 CompileRun( |
| 8687 "var i = 0;" |
| 8688 "var o = {" |
| 8689 " toString: function () {" |
| 8690 " if (i == 10) {" |
| 8691 " throw 'Hey!';" |
| 8692 " } else {" |
| 8693 " i++;" |
| 8694 " return s(o);" |
| 8695 " }" |
| 8696 " }" |
| 8697 "};" |
| 8698 "s(o);"); |
| 8687 CHECK(try_catch.HasCaught()); | 8699 CHECK(try_catch.HasCaught()); |
| 8688 v8::String::Utf8Value value(try_catch.Exception()); | 8700 v8::String::Utf8Value value(try_catch.Exception()); |
| 8689 CHECK_NE(0, strstr(*value, "RangeError")); | 8701 CHECK_EQ(0, strcmp(*value, "Hey!")); |
| 8690 } | 8702 } |
| OLD | NEW |