| Index: src/mips64/simulator-mips64.cc | 
| diff --git a/src/mips64/simulator-mips64.cc b/src/mips64/simulator-mips64.cc | 
| index 577af17dc6e7ca74014e1c73291527811a144cb0..9a0d8fdce8bd359b8701ac56c45396e100eecdc0 100644 | 
| --- a/src/mips64/simulator-mips64.cc | 
| +++ b/src/mips64/simulator-mips64.cc | 
| @@ -1800,9 +1800,15 @@ void Simulator::WriteB(int64_t addr, int8_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. | 
| +uintptr_t Simulator::StackLimit(uintptr_t c_limit) const { | 
| +  // The simulator uses a separate JS stack. If we have exhausted the C stack, | 
| +  // we also drop down the JS limit to reflect the exhaustion on the JS stack. | 
| +  if (GetCurrentStackPosition() < c_limit) { | 
| +    return reinterpret_cast<uintptr_t>(get_sp()); | 
| +  } | 
| + | 
| +  // Otherwise the limit is the JS stack. Leave a safety margin of 1024 bytes | 
| +  // to prevent overrunning the stack when pushing values. | 
| return reinterpret_cast<uintptr_t>(stack_) + 1024; | 
| } | 
|  | 
| @@ -4620,6 +4626,9 @@ void Simulator::Execute() { | 
|  | 
|  | 
| void Simulator::CallInternal(byte* entry) { | 
| +  // Adjust JS-based stack limit to C-based stack limit. | 
| +  isolate_->stack_guard()->AdjustStackLimitForSimulator(); | 
| + | 
| // Prepare to execute the code at entry. | 
| set_register(pc, reinterpret_cast<int64_t>(entry)); | 
| // Put down marker for end of simulation. The simulator will stop simulation | 
|  |