Reviewers: Yang,

Message:
PTAL

Description:
Ensure there is some space on JS stack available for bootstrapping.

Please review this at https://codereview.chromium.org/1203873005/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+5, -5 lines):
  M src/bootstrapper.cc
  M src/isolate.h
  M src/isolate.cc


Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index f59830ed4ce08eec1663eb0267ee863bc604e06a..a43d5aaf57f80b833c9ccdf44a25c3ecba06964e 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -3091,7 +3091,7 @@ Genesis::Genesis(Isolate* isolate,
   // environment has been at least partially initialized. Add a stack check
   // before entering JS code to catch overflow early.
   StackLimitCheck check(isolate);
-  if (check.HasOverflowed()) {
+  if (check.JsHasOverflowed(1 * KB)) {
     isolate->StackOverflow();
     return;
   }
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index 17f480c1d5a4c249da957814e7937e0b3941b2e6..f3d047f0a484dc9f1eb09f74d2d56f1755885d9e 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -2772,15 +2772,15 @@ void Isolate::CheckDetachedContextsAfterGC() {
 }


-bool StackLimitCheck::JsHasOverflowed() const {
+bool StackLimitCheck::JsHasOverflowed(uintptr_t gap) const {
   StackGuard* stack_guard = isolate_->stack_guard();
 #ifdef USE_SIMULATOR
   // The simulator uses a separate JS stack.
   Address jssp_address = Simulator::current(isolate_)->get_sp();
   uintptr_t jssp = reinterpret_cast<uintptr_t>(jssp_address);
-  if (jssp < stack_guard->real_jslimit()) return true;
+  if (jssp - gap < stack_guard->real_jslimit()) return true;
 #endif  // USE_SIMULATOR
-  return GetCurrentStackPosition() < stack_guard->real_climit();
+  return GetCurrentStackPosition() - gap < stack_guard->real_climit();
 }


Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index ffef934a0179700c2f1ac5e00ab9fe2200daf758..a67f0c7fb55c72cae7ea20aa52c68bc2ca1ffcd5 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -1481,7 +1481,7 @@ class StackLimitCheck BASE_EMBEDDED {
   }

// Use this to check for stack-overflow when entering runtime from JS code.
-  bool JsHasOverflowed() const;
+  bool JsHasOverflowed(uintptr_t gap = 0) const;

  private:
   Isolate* isolate_;


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to