Commit 440a1c7a authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC64: Adjust simulator stack safety margin.

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

R=dstence@us.ibm.com, michael_dawson@ca.ibm.com, svenpanne@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1174693002

Cr-Commit-Position: refs/heads/master@{#28924}
parent 1c5d4d7e
...@@ -728,7 +728,7 @@ DEFINE_INT(sim_stack_alignment, 8, ...@@ -728,7 +728,7 @@ DEFINE_INT(sim_stack_alignment, 8,
"Stack alingment in bytes in simulator (4 or 8, 8 is default)") "Stack alingment in bytes in simulator (4 or 8, 8 is default)")
#endif #endif
DEFINE_INT(sim_stack_size, 2 * MB / KB, DEFINE_INT(sim_stack_size, 2 * MB / KB,
"Stack size of the ARM64 and MIPS64 simulator " "Stack size of the ARM64, MIPS64 and PPC64 simulator "
"in kBytes (default is 2 MB)") "in kBytes (default is 2 MB)")
DEFINE_BOOL(log_regs_modified, true, DEFINE_BOOL(log_regs_modified, true,
"When logging register values, only print modified registers.") "When logging register values, only print modified registers.")
......
...@@ -794,10 +794,11 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { ...@@ -794,10 +794,11 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
// Set up simulator support first. Some of this information is needed to // Set up simulator support first. Some of this information is needed to
// setup the architecture state. // setup the architecture state.
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
size_t stack_size = 2 * 1024 * 1024; // allocate 2MB for stack size_t stack_size = FLAG_sim_stack_size * KB;
#else #else
size_t stack_size = 1 * 1024 * 1024; // allocate 1MB for stack size_t stack_size = MB; // allocate 1MB for stack
#endif #endif
stack_size += 2 * stack_protection_size_;
stack_ = reinterpret_cast<char*>(malloc(stack_size)); stack_ = reinterpret_cast<char*>(malloc(stack_size));
pc_modified_ = false; pc_modified_ = false;
icount_ = 0; icount_ = 0;
...@@ -823,7 +824,8 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { ...@@ -823,7 +824,8 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
// The sp is initialized to point to the bottom (high address) of the // 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 // allocated stack area. To be safe in potential stack underflows we leave
// some buffer below. // 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(); InitializeCoverage();
last_debugger_input_ = NULL; last_debugger_input_ = NULL;
...@@ -1107,9 +1109,8 @@ void Simulator::WriteDW(intptr_t addr, int64_t value) { ...@@ -1107,9 +1109,8 @@ void Simulator::WriteDW(intptr_t addr, int64_t value) {
// Returns the limit of the stack area to enable checking for stack overflows. // Returns the limit of the stack area to enable checking for stack overflows.
uintptr_t Simulator::StackLimit() const { uintptr_t Simulator::StackLimit() const {
// Leave a safety margin of 1024 bytes to prevent overrunning the stack when // Leave a safety margin to prevent overrunning the stack when pushing values.
// pushing values. return reinterpret_cast<uintptr_t>(stack_) + stack_protection_size_;
return reinterpret_cast<uintptr_t>(stack_) + 1024;
} }
......
...@@ -351,6 +351,7 @@ class Simulator { ...@@ -351,6 +351,7 @@ class Simulator {
// Simulator support. // Simulator support.
char* stack_; char* stack_;
static const size_t stack_protection_size_ = 256 * kPointerSize;
bool pc_modified_; bool pc_modified_;
int icount_; int icount_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment