Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: src/mips/simulator-mips.cc

Issue 1314623002: Make Simulator respect C stack limits as well. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Architecture ports.wq Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits.h> 5 #include <limits.h>
6 #include <stdarg.h> 6 #include <stdarg.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <cmath> 8 #include <cmath>
9 9
10 #if V8_TARGET_ARCH_MIPS 10 #if V8_TARGET_ARCH_MIPS
(...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 1800
1801 1801
1802 void Simulator::WriteB(int32_t addr, int8_t value) { 1802 void Simulator::WriteB(int32_t addr, int8_t value) {
1803 int8_t* ptr = reinterpret_cast<int8_t*>(addr); 1803 int8_t* ptr = reinterpret_cast<int8_t*>(addr);
1804 TraceMemWr(addr, value, BYTE); 1804 TraceMemWr(addr, value, BYTE);
1805 *ptr = value; 1805 *ptr = value;
1806 } 1806 }
1807 1807
1808 1808
1809 // Returns the limit of the stack area to enable checking for stack overflows. 1809 // Returns the limit of the stack area to enable checking for stack overflows.
1810 uintptr_t Simulator::StackLimit() const { 1810 uintptr_t Simulator::StackLimit(uintptr_t c_limit) const {
1811 // Leave a safety margin of 1024 bytes to prevent overrunning the stack when 1811 // The simulator uses a separate JS stack. If we have exhausted the C stack,
1812 // pushing values. 1812 // we also drop down the JS limit to reflect the exhaustion on the JS stack.
1813 if (GetCurrentStackPosition() < c_limit) {
1814 return reinterpret_cast<uintptr_t>(get_sp());
1815 }
1816
1817 // Otherwise the limit is the JS stack. Leave a safety margin of 1024 bytes
1818 // to prevent overrunning the stack when pushing values.
1813 return reinterpret_cast<uintptr_t>(stack_) + 1024; 1819 return reinterpret_cast<uintptr_t>(stack_) + 1024;
1814 } 1820 }
1815 1821
1816 1822
1817 // Unsupported instructions use Format to print an error and stop execution. 1823 // Unsupported instructions use Format to print an error and stop execution.
1818 void Simulator::Format(Instruction* instr, const char* format) { 1824 void Simulator::Format(Instruction* instr, const char* format) {
1819 PrintF("Simulator found unsupported instruction:\n 0x%08x: %s\n", 1825 PrintF("Simulator found unsupported instruction:\n 0x%08x: %s\n",
1820 reinterpret_cast<intptr_t>(instr), format); 1826 reinterpret_cast<intptr_t>(instr), format);
1821 UNIMPLEMENTED_MIPS(); 1827 UNIMPLEMENTED_MIPS();
1822 } 1828 }
(...skipping 2634 matching lines...) Expand 10 before | Expand all | Expand 10 after
4457 } else { 4463 } else {
4458 InstructionDecode(instr); 4464 InstructionDecode(instr);
4459 } 4465 }
4460 program_counter = get_pc(); 4466 program_counter = get_pc();
4461 } 4467 }
4462 } 4468 }
4463 } 4469 }
4464 4470
4465 4471
4466 void Simulator::CallInternal(byte* entry) { 4472 void Simulator::CallInternal(byte* entry) {
4473 // Adjust JS-based stack limit to C-based stack limit.
4474 isolate_->stack_guard()->AdjustStackLimitForSimulator();
4475
4467 // Prepare to execute the code at entry. 4476 // Prepare to execute the code at entry.
4468 set_register(pc, reinterpret_cast<int32_t>(entry)); 4477 set_register(pc, reinterpret_cast<int32_t>(entry));
4469 // Put down marker for end of simulation. The simulator will stop simulation 4478 // Put down marker for end of simulation. The simulator will stop simulation
4470 // when the PC reaches this value. By saving the "end simulation" value into 4479 // when the PC reaches this value. By saving the "end simulation" value into
4471 // the LR the simulation stops when returning to this call point. 4480 // the LR the simulation stops when returning to this call point.
4472 set_register(ra, end_sim_pc); 4481 set_register(ra, end_sim_pc);
4473 4482
4474 // Remember the values of callee-saved registers. 4483 // Remember the values of callee-saved registers.
4475 // The code below assumes that r9 is not used as sb (static base) in 4484 // The code below assumes that r9 is not used as sb (static base) in
4476 // simulator code and therefore is regarded as a callee-saved register. 4485 // simulator code and therefore is regarded as a callee-saved register.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
4609 4618
4610 4619
4611 #undef UNSUPPORTED 4620 #undef UNSUPPORTED
4612 4621
4613 } // namespace internal 4622 } // namespace internal
4614 } // namespace v8 4623 } // namespace v8
4615 4624
4616 #endif // USE_SIMULATOR 4625 #endif // USE_SIMULATOR
4617 4626
4618 #endif // V8_TARGET_ARCH_MIPS 4627 #endif // V8_TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698