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

Side by Side Diff: test/cctest/test-api.cc

Issue 178073002: Raise StackOverflow during bootstrapping (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Raise StackOverflow during bootstrapping Created 6 years, 9 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/isolate.h ('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 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 4968 matching lines...) Expand 10 before | Expand all | Expand 10 after
4979 v8::V8::AddMessageListener(receive_message); 4979 v8::V8::AddMessageListener(receive_message);
4980 v8::TryCatch try_catch; 4980 v8::TryCatch try_catch;
4981 try_catch.SetVerbose(true); 4981 try_catch.SetVerbose(true);
4982 Local<Value> result = CompileRun("function foo() { foo(); } foo();"); 4982 Local<Value> result = CompileRun("function foo() { foo(); } foo();");
4983 CHECK(try_catch.HasCaught()); 4983 CHECK(try_catch.HasCaught());
4984 CHECK(result.IsEmpty()); 4984 CHECK(result.IsEmpty());
4985 CHECK(message_received); 4985 CHECK(message_received);
4986 v8::V8::RemoveMessageListeners(receive_message); 4986 v8::V8::RemoveMessageListeners(receive_message);
4987 } 4987 }
4988 4988
4989 void APIStackOverflowNestedContextsHelper(bool is_bottom_call);
Jarin 2014/03/25 15:28:33 In v8, bools as arguments are normally frowned upo
4990
4991 void APIStackOverflowNestedContextsCallback(
4992 const v8::FunctionCallbackInfo<Value>& args) {
4993 APIStackOverflowNestedContextsHelper(false);
4994 }
4995
4996
4997 void APIStackOverflowNestedContextsHelper(bool is_bottom_call) {
4998 v8::Isolate* isolate = CcTest::isolate();
4999 TryCatch try_catch;
5000
5001 Local<ObjectTemplate> global = ObjectTemplate::New();
5002 global->Set(String::NewFromUtf8(isolate, "recur"),
5003 FunctionTemplate::New(isolate, APIStackOverflowNestedContextsCallback));
5004
5005 Local<Context> innerContext = Context::New(isolate, NULL, global);
5006 if (try_catch.HasCaught()) {
5007 try_catch.ReThrow();
5008 return;
5009 }
5010 if (innerContext.IsEmpty()) return;
5011
5012 Context::Scope context_scope(innerContext);
5013 Local<Script> script = v8::Script::Compile(v8::String::NewFromUtf8(
5014 isolate,
5015 "function f() { "
5016 " try { recur(); } catch(e) { throw e; } "
5017 " return 'bad'; "
5018 "} f(); "));
5019
5020 Local<Value> result = script->Run();
5021 CHECK(result.IsEmpty());
5022 if (try_catch.HasCaught()) {
5023 if (is_bottom_call) {
5024 String::Utf8Value ex_value(try_catch.Exception());
5025 CHECK_EQ("RangeError: Maximum call stack size exceeded", *ex_value);
5026 }
5027 try_catch.ReThrow();
5028 }
5029 }
5030
5031
5032 void APIStackOverflowNestedContexts(int extra_stack_bytes) {
5033 if (extra_stack_bytes) alloca(extra_stack_bytes);
5034 LocalContext context;
5035 v8::HandleScope scope(context->GetIsolate());
5036 v8::TryCatch try_catch;
5037 APIStackOverflowNestedContextsHelper(true);
5038 CHECK(try_catch.HasCaught());
5039 }
5040
5041
5042 TEST(APIStackOverflowNestedContexts) {
5043 // The place where a stack overflow can occur is not completely deterministic
5044 // so probe a few different depths
5045 APIStackOverflowNestedContexts(2500);
5046 APIStackOverflowNestedContexts(2800);
5047 APIStackOverflowNestedContexts(30000);
5048 }
5049
4989 5050
4990 THREADED_TEST(ExternalScriptException) { 5051 THREADED_TEST(ExternalScriptException) {
4991 v8::Isolate* isolate = CcTest::isolate(); 5052 v8::Isolate* isolate = CcTest::isolate();
4992 v8::HandleScope scope(isolate); 5053 v8::HandleScope scope(isolate);
4993 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); 5054 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
4994 templ->Set(v8_str("ThrowFromC"), 5055 templ->Set(v8_str("ThrowFromC"),
4995 v8::FunctionTemplate::New(isolate, ThrowFromC)); 5056 v8::FunctionTemplate::New(isolate, ThrowFromC));
4996 LocalContext context(0, templ); 5057 LocalContext context(0, templ);
4997 5058
4998 v8::TryCatch try_catch; 5059 v8::TryCatch try_catch;
(...skipping 17110 matching lines...) Expand 10 before | Expand all | Expand 10 after
22109 Local<Object> ApiCallOptimizationChecker::holder; 22170 Local<Object> ApiCallOptimizationChecker::holder;
22110 Local<Object> ApiCallOptimizationChecker::callee; 22171 Local<Object> ApiCallOptimizationChecker::callee;
22111 int ApiCallOptimizationChecker::count = 0; 22172 int ApiCallOptimizationChecker::count = 0;
22112 22173
22113 22174
22114 TEST(TestFunctionCallOptimization) { 22175 TEST(TestFunctionCallOptimization) {
22115 i::FLAG_allow_natives_syntax = true; 22176 i::FLAG_allow_natives_syntax = true;
22116 ApiCallOptimizationChecker checker; 22177 ApiCallOptimizationChecker checker;
22117 checker.RunAll(); 22178 checker.RunAll();
22118 } 22179 }
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698