Index: src/execution.cc |
diff --git a/src/execution.cc b/src/execution.cc |
index 243bb8a9117ae5998384b1146c21e8a0ec4f923e..85a73cd6676c5711bcaacdc81933efb90cbbf959 100644 |
--- a/src/execution.cc |
+++ b/src/execution.cc |
@@ -59,6 +59,19 @@ MUST_USE_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, bool is_construct, |
Handle<Object> new_target) { |
DCHECK(!receiver->IsJSGlobalObject()); |
+#ifdef USE_SIMULATOR |
+ // Simulators use separate stacks for C++ and JS. JS stack overflow checks |
+ // are performed whenever a JS function is called. However, it can be the case |
+ // that the C++ stack grows faster than the JS stack, resulting in an overflow |
+ // there. Add a check here to make that less likely. |
+ StackLimitCheck check(isolate); |
+ if (check.HasOverflowed()) { |
+ isolate->StackOverflow(); |
+ isolate->ReportPendingMessages(); |
+ return MaybeHandle<Object>(); |
+ } |
+#endif |
+ |
// Entering JavaScript. |
VMState<JS> state(isolate); |
CHECK(AllowJavascriptExecution::IsAllowed(isolate)); |