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

Side by Side Diff: src/bootstrapper.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 | « no previous file | src/isolate.h » ('j') | test/cctest/test-api.cc » ('J')
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 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 } 1466 }
1467 1467
1468 1468
1469 bool Genesis::CompileNative(Isolate* isolate, 1469 bool Genesis::CompileNative(Isolate* isolate,
1470 Vector<const char> name, 1470 Vector<const char> name,
1471 Handle<String> source) { 1471 Handle<String> source) {
1472 HandleScope scope(isolate); 1472 HandleScope scope(isolate);
1473 #ifdef ENABLE_DEBUGGER_SUPPORT 1473 #ifdef ENABLE_DEBUGGER_SUPPORT
1474 isolate->debugger()->set_compiling_natives(true); 1474 isolate->debugger()->set_compiling_natives(true);
1475 #endif 1475 #endif
1476 // During genesis, the boilerplate for stack overflow won't work until the
1477 // environment has been at least partially initialized. Add a stack check
1478 // before entering JS code to catch overflow early.
1479 StackLimitCheck check(isolate);
1480 if (check.HasOverflowed()) return false;
1481 1476
1482 bool result = CompileScriptCached(isolate, 1477 bool result = CompileScriptCached(isolate,
1483 name, 1478 name,
1484 source, 1479 source,
1485 NULL, 1480 NULL,
1486 NULL, 1481 NULL,
1487 Handle<Context>(isolate->context()), 1482 Handle<Context>(isolate->context()),
1488 true); 1483 true);
1489 ASSERT(isolate->has_pending_exception() != result); 1484 ASSERT(isolate->has_pending_exception() != result);
1490 if (!result) isolate->clear_pending_exception(); 1485 if (!result) isolate->clear_pending_exception();
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2600 // If V8 cannot be initialized, just return. 2595 // If V8 cannot be initialized, just return.
2601 if (!V8::Initialize(NULL)) return; 2596 if (!V8::Initialize(NULL)) return;
2602 2597
2603 // Before creating the roots we must save the context and restore it 2598 // Before creating the roots we must save the context and restore it
2604 // on all function exits. 2599 // on all function exits.
2605 SaveContext saved_context(isolate); 2600 SaveContext saved_context(isolate);
2606 2601
2607 // During genesis, the boilerplate for stack overflow won't work until the 2602 // During genesis, the boilerplate for stack overflow won't work until the
2608 // environment has been at least partially initialized. Add a stack check 2603 // environment has been at least partially initialized. Add a stack check
2609 // before entering JS code to catch overflow early. 2604 // before entering JS code to catch overflow early.
2605 const uint32_t stack_to_get_through_genesis = 3500 * sizeof(intptr_t);
2610 StackLimitCheck check(isolate); 2606 StackLimitCheck check(isolate);
2611 if (check.HasOverflowed()) return; 2607 if (check.WillOverflow(stack_to_get_through_genesis)) {
2608 // Only raise a StackOverflow if there is a valid current context
2609 if (isolate->context() != NULL) {
2610 isolate->StackOverflow();
2611 isolate->OptionalRescheduleException(true);
2612 }
2613 return;
2614 }
2612 2615
2613 // We can only de-serialize a context if the isolate was initialized from 2616 // We can only de-serialize a context if the isolate was initialized from
2614 // a snapshot. Otherwise we have to build the context from scratch. 2617 // a snapshot. Otherwise we have to build the context from scratch.
2615 if (isolate->initialized_from_snapshot()) { 2618 if (isolate->initialized_from_snapshot()) {
2616 native_context_ = Snapshot::NewContextFromSnapshot(isolate); 2619 native_context_ = Snapshot::NewContextFromSnapshot(isolate);
2617 } else { 2620 } else {
2618 native_context_ = Handle<Context>(); 2621 native_context_ = Handle<Context>();
2619 } 2622 }
2620 2623
2621 if (!native_context().is_null()) { 2624 if (!native_context().is_null()) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2746 return from + sizeof(NestingCounterType); 2749 return from + sizeof(NestingCounterType);
2747 } 2750 }
2748 2751
2749 2752
2750 // Called when the top-level V8 mutex is destroyed. 2753 // Called when the top-level V8 mutex is destroyed.
2751 void Bootstrapper::FreeThreadResources() { 2754 void Bootstrapper::FreeThreadResources() {
2752 ASSERT(!IsActive()); 2755 ASSERT(!IsActive());
2753 } 2756 }
2754 2757
2755 } } // namespace v8::internal 2758 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/isolate.h » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698