| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 5005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5016 v8::V8::AddMessageListener(receive_message); | 5016 v8::V8::AddMessageListener(receive_message); |
| 5017 v8::TryCatch try_catch; | 5017 v8::TryCatch try_catch; |
| 5018 try_catch.SetVerbose(true); | 5018 try_catch.SetVerbose(true); |
| 5019 Local<Value> result = CompileRun("function foo() { foo(); } foo();"); | 5019 Local<Value> result = CompileRun("function foo() { foo(); } foo();"); |
| 5020 CHECK(try_catch.HasCaught()); | 5020 CHECK(try_catch.HasCaught()); |
| 5021 CHECK(result.IsEmpty()); | 5021 CHECK(result.IsEmpty()); |
| 5022 CHECK(message_received); | 5022 CHECK(message_received); |
| 5023 v8::V8::RemoveMessageListeners(receive_message); | 5023 v8::V8::RemoveMessageListeners(receive_message); |
| 5024 } | 5024 } |
| 5025 | 5025 |
| 5026 void APIStackOverflowNestedContextsHelper(bool is_bottom_call); | |
| 5027 | |
| 5028 void APIStackOverflowNestedContextsCallback( | |
| 5029 const v8::FunctionCallbackInfo<Value>& args) { | |
| 5030 APIStackOverflowNestedContextsHelper(false); | |
| 5031 } | |
| 5032 | |
| 5033 | |
| 5034 void APIStackOverflowNestedContextsHelper(bool is_bottom_call) { | |
| 5035 v8::Isolate* isolate = CcTest::isolate(); | |
| 5036 TryCatch try_catch; | |
| 5037 | |
| 5038 Local<ObjectTemplate> global = ObjectTemplate::New(); | |
| 5039 global->Set(String::NewFromUtf8(isolate, "recur"), | |
| 5040 FunctionTemplate::New(isolate, APIStackOverflowNestedContextsCallback)); | |
| 5041 | |
| 5042 Local<Context> innerContext = Context::New(isolate, NULL, global); | |
| 5043 if (try_catch.HasCaught()) { | |
| 5044 try_catch.ReThrow(); | |
| 5045 return; | |
| 5046 } | |
| 5047 if (innerContext.IsEmpty()) return; | |
| 5048 | |
| 5049 Context::Scope context_scope(innerContext); | |
| 5050 Local<Script> script = v8::Script::Compile(v8::String::NewFromUtf8( | |
| 5051 isolate, | |
| 5052 "function f() { " | |
| 5053 " try { recur(); } catch(e) { throw e; } " | |
| 5054 " return 'bad'; " | |
| 5055 "} f(); ")); | |
| 5056 | |
| 5057 Local<Value> result = script->Run(); | |
| 5058 CHECK(result.IsEmpty()); | |
| 5059 if (try_catch.HasCaught()) { | |
| 5060 if (is_bottom_call) { | |
| 5061 String::Utf8Value ex_value(try_catch.Exception()); | |
| 5062 CHECK_EQ("RangeError: Maximum call stack size exceeded", *ex_value); | |
| 5063 } | |
| 5064 try_catch.ReThrow(); | |
| 5065 } | |
| 5066 } | |
| 5067 | |
| 5068 | |
| 5069 void APIStackOverflowNestedContexts(int extra_stack_bytes) { | |
| 5070 if (extra_stack_bytes) alloca(extra_stack_bytes); | |
| 5071 LocalContext context; | |
| 5072 v8::HandleScope scope(context->GetIsolate()); | |
| 5073 v8::TryCatch try_catch; | |
| 5074 APIStackOverflowNestedContextsHelper(true); | |
| 5075 CHECK(try_catch.HasCaught()); | |
| 5076 } | |
| 5077 | |
| 5078 | |
| 5079 TEST(APIStackOverflowNestedContexts) { | |
| 5080 // The place where a stack overflow can occur is not completely deterministic | |
| 5081 // so probe a few different depths | |
| 5082 APIStackOverflowNestedContexts(2500); | |
| 5083 APIStackOverflowNestedContexts(2800); | |
| 5084 APIStackOverflowNestedContexts(30000); | |
| 5085 } | |
| 5086 | |
| 5087 | 5026 |
| 5088 THREADED_TEST(ExternalScriptException) { | 5027 THREADED_TEST(ExternalScriptException) { |
| 5089 v8::Isolate* isolate = CcTest::isolate(); | 5028 v8::Isolate* isolate = CcTest::isolate(); |
| 5090 v8::HandleScope scope(isolate); | 5029 v8::HandleScope scope(isolate); |
| 5091 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 5030 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
| 5092 templ->Set(v8_str("ThrowFromC"), | 5031 templ->Set(v8_str("ThrowFromC"), |
| 5093 v8::FunctionTemplate::New(isolate, ThrowFromC)); | 5032 v8::FunctionTemplate::New(isolate, ThrowFromC)); |
| 5094 LocalContext context(0, templ); | 5033 LocalContext context(0, templ); |
| 5095 | 5034 |
| 5096 v8::TryCatch try_catch; | 5035 v8::TryCatch try_catch; |
| (...skipping 17334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22431 "f.call(friend);"); | 22370 "f.call(friend);"); |
| 22432 CHECK_EQ(2, named_access_count); | 22371 CHECK_EQ(2, named_access_count); |
| 22433 | 22372 |
| 22434 // Test access using Object.setPrototypeOf reflective method. | 22373 // Test access using Object.setPrototypeOf reflective method. |
| 22435 named_access_count = 0; | 22374 named_access_count = 0; |
| 22436 CompileRun("Object.setPrototypeOf(friend, {});"); | 22375 CompileRun("Object.setPrototypeOf(friend, {});"); |
| 22437 CHECK_EQ(1, named_access_count); | 22376 CHECK_EQ(1, named_access_count); |
| 22438 CompileRun("Object.getPrototypeOf(friend);"); | 22377 CompileRun("Object.getPrototypeOf(friend);"); |
| 22439 CHECK_EQ(2, named_access_count); | 22378 CHECK_EQ(2, named_access_count); |
| 22440 } | 22379 } |
| OLD | NEW |