Skip to content

Commit 69aa868

Browse files
isheludkoCommit Bot
authored andcommitted
[runtime] Reserve more stack space for compilation.
... to properly handle stack overflows near the hard stack limit. Bug: chromium:716522 Change-Id: I6acdb29f039b9835bdf45b087d6561a05ed837bb Reviewed-on: https://chromium-review.googlesource.com/517799 Commit-Queue: Jakob Kummerow <[email protected]> Reviewed-by: Jakob Kummerow <[email protected]> Cr-Commit-Position: refs/heads/master@{#45619}
1 parent e0dcd1e commit 69aa868

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/bootstrapper.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3341,7 +3341,7 @@ bool Bootstrapper::CompileNative(Isolate* isolate, Vector<const char> name,
33413341
// environment has been at least partially initialized. Add a stack check
33423342
// before entering JS code to catch overflow early.
33433343
StackLimitCheck check(isolate);
3344-
if (check.JsHasOverflowed(4 * KB)) {
3344+
if (check.JsHasOverflowed(kStackSpaceRequiredForCompilation * KB)) {
33453345
isolate->StackOverflow();
33463346
return false;
33473347
}

src/globals.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ namespace internal {
110110
#define V8_DEFAULT_STACK_SIZE_KB 984
111111
#endif
112112

113+
// Minimum stack size in KB required by compilers.
114+
const int kStackSpaceRequiredForCompilation = 40;
113115

114116
// Determine whether double field unboxing feature is enabled.
115117
#if V8_TARGET_ARCH_64_BIT

src/runtime/runtime-compiler.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ RUNTIME_FUNCTION(Runtime_CompileLazy) {
3333
#endif
3434

3535
StackLimitCheck check(isolate);
36-
if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow();
36+
if (check.JsHasOverflowed(kStackSpaceRequiredForCompilation * KB)) {
37+
return isolate->StackOverflow();
38+
}
3739
if (!Compiler::Compile(function, Compiler::KEEP_EXCEPTION)) {
3840
return isolate->heap()->exception();
3941
}
@@ -46,7 +48,9 @@ RUNTIME_FUNCTION(Runtime_CompileOptimized_Concurrent) {
4648
DCHECK_EQ(1, args.length());
4749
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
4850
StackLimitCheck check(isolate);
49-
if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow();
51+
if (check.JsHasOverflowed(kStackSpaceRequiredForCompilation * KB)) {
52+
return isolate->StackOverflow();
53+
}
5054
if (!Compiler::CompileOptimized(function, Compiler::CONCURRENT)) {
5155
return isolate->heap()->exception();
5256
}
@@ -60,7 +64,9 @@ RUNTIME_FUNCTION(Runtime_CompileOptimized_NotConcurrent) {
6064
DCHECK_EQ(1, args.length());
6165
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
6266
StackLimitCheck check(isolate);
63-
if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow();
67+
if (check.JsHasOverflowed(kStackSpaceRequiredForCompilation * KB)) {
68+
return isolate->StackOverflow();
69+
}
6470
if (!Compiler::CompileOptimized(function, Compiler::NOT_CONCURRENT)) {
6571
return isolate->heap()->exception();
6672
}

0 commit comments

Comments
 (0)