Reviewers: dstence, michael_dawson,

Description:
PPC: Adjust simulator stack safety margin.

This fixes a PPC64 failure in test/mjsunit/regress/regress-crbug-491062.js.

[email protected], [email protected]
BUG=

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

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

Affected files (+7, -10 lines):
  M src/flag-definitions.h
  M src/ppc/simulator-ppc.h
  M src/ppc/simulator-ppc.cc


Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index b2f2b9963f9cd73b52ff7a21988cbea7ff1f61e7..96f4dd26ed90d6091fb8260fb109b1f49b05fa35 100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -728,7 +728,7 @@ DEFINE_INT(sim_stack_alignment, 8,
            "Stack alingment in bytes in simulator (4 or 8, 8 is default)")
 #endif
 DEFINE_INT(sim_stack_size, 2 * MB / KB,
-           "Stack size of the ARM64 and MIPS64 simulator "
+           "Stack size of the ARM64, MIPS64 and PPC simulator "
            "in kBytes (default is 2 MB)")
 DEFINE_BOOL(log_regs_modified, true,
             "When logging register values, only print modified registers.")
Index: src/ppc/simulator-ppc.cc
diff --git a/src/ppc/simulator-ppc.cc b/src/ppc/simulator-ppc.cc
index 1932631215745152f63a05de52d9d1fe092334aa..ba743bb73ea6c7b4d5de988c3e250c61046616c6 100644
--- a/src/ppc/simulator-ppc.cc
+++ b/src/ppc/simulator-ppc.cc
@@ -793,11 +793,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
   Initialize(isolate);
 // Set up simulator support first. Some of this information is needed to
 // setup the architecture state.
-#if V8_TARGET_ARCH_PPC64
-  size_t stack_size = 2 * 1024 * 1024;  // allocate 2MB for stack
-#else
-  size_t stack_size = 1 * 1024 * 1024;  // allocate 1MB for stack
-#endif
+ size_t stack_size = (FLAG_sim_stack_size * KB) + (2 * stack_protection_size_);
   stack_ = reinterpret_cast<char*>(malloc(stack_size));
   pc_modified_ = false;
   icount_ = 0;
@@ -823,7 +819,8 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
   // The sp is initialized to point to the bottom (high address) of the
// allocated stack area. To be safe in potential stack underflows we leave
   // some buffer below.
-  registers_[sp] = reinterpret_cast<intptr_t>(stack_) + stack_size - 64;
+  registers_[sp] =
+ reinterpret_cast<intptr_t>(stack_) + stack_size - stack_protection_size_;
   InitializeCoverage();

   last_debugger_input_ = NULL;
@@ -1107,9 +1104,8 @@ void Simulator::WriteDW(intptr_t addr, int64_t value) {

// Returns the limit of the stack area to enable checking for stack overflows.
 uintptr_t Simulator::StackLimit() const {
- // Leave a safety margin of 1024 bytes to prevent overrunning the stack when
-  // pushing values.
-  return reinterpret_cast<uintptr_t>(stack_) + 1024;
+ // Leave a safety margin to prevent overrunning the stack when pushing values.
+  return reinterpret_cast<uintptr_t>(stack_) + stack_protection_size_;
 }


Index: src/ppc/simulator-ppc.h
diff --git a/src/ppc/simulator-ppc.h b/src/ppc/simulator-ppc.h
index b74548fcf5b6286fabbc6fd57d42150becb2722f..a99382511bca4dfeb3e6bcd5332675c2e384a9bf 100644
--- a/src/ppc/simulator-ppc.h
+++ b/src/ppc/simulator-ppc.h
@@ -351,6 +351,7 @@ class Simulator {

   // Simulator support.
   char* stack_;
+  static const size_t stack_protection_size_ = 2 * KB;
   bool pc_modified_;
   int icount_;



--
--
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