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

Side by Side Diff: src/mips64/simulator-mips64.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, 4 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_MIPS64 10 #if V8_TARGET_ARCH_MIPS64
(...skipping 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 1793
1794 1794
1795 void Simulator::WriteB(int64_t addr, int8_t value) { 1795 void Simulator::WriteB(int64_t addr, int8_t value) {
1796 TraceMemWr(addr, value, BYTE); 1796 TraceMemWr(addr, value, BYTE);
1797 int8_t* ptr = reinterpret_cast<int8_t*>(addr); 1797 int8_t* ptr = reinterpret_cast<int8_t*>(addr);
1798 *ptr = value; 1798 *ptr = value;
1799 } 1799 }
1800 1800
1801 1801
1802 // Returns the limit of the stack area to enable checking for stack overflows. 1802 // Returns the limit of the stack area to enable checking for stack overflows.
1803 uintptr_t Simulator::StackLimit() const { 1803 uintptr_t Simulator::StackLimit(uintptr_t c_limit) const {
1804 // Leave a safety margin of 1024 bytes to prevent overrunning the stack when 1804 // The simulator uses a separate JS stack. If we have exhausted the C stack,
1805 // pushing values. 1805 // we also drop down the JS limit to reflect the exhaustion on the JS stack.
1806 if (GetCurrentStackPosition() < c_limit) {
1807 return reinterpret_cast<uintptr_t>(get_sp());
1808 }
1809
1810 // Otherwise the limit is the JS stack. Leave a safety margin of 1024 bytes
1811 // to prevent overrunning the stack when pushing values.
1806 return reinterpret_cast<uintptr_t>(stack_) + 1024; 1812 return reinterpret_cast<uintptr_t>(stack_) + 1024;
1807 } 1813 }
1808 1814
1809 1815
1810 // Unsupported instructions use Format to print an error and stop execution. 1816 // Unsupported instructions use Format to print an error and stop execution.
1811 void Simulator::Format(Instruction* instr, const char* format) { 1817 void Simulator::Format(Instruction* instr, const char* format) {
1812 PrintF("Simulator found unsupported instruction:\n 0x%08lx: %s\n", 1818 PrintF("Simulator found unsupported instruction:\n 0x%08lx: %s\n",
1813 reinterpret_cast<intptr_t>(instr), format); 1819 reinterpret_cast<intptr_t>(instr), format);
1814 UNIMPLEMENTED_MIPS(); 1820 UNIMPLEMENTED_MIPS();
1815 } 1821 }
(...skipping 2797 matching lines...) Expand 10 before | Expand all | Expand 10 after
4613 } else { 4619 } else {
4614 InstructionDecode(instr); 4620 InstructionDecode(instr);
4615 } 4621 }
4616 program_counter = get_pc(); 4622 program_counter = get_pc();
4617 } 4623 }
4618 } 4624 }
4619 } 4625 }
4620 4626
4621 4627
4622 void Simulator::CallInternal(byte* entry) { 4628 void Simulator::CallInternal(byte* entry) {
4629 // Adjust JS-based stack limit to C-based stack limit.
4630 isolate_->stack_guard()->AdjustStackLimitForSimulator();
4631
4623 // Prepare to execute the code at entry. 4632 // Prepare to execute the code at entry.
4624 set_register(pc, reinterpret_cast<int64_t>(entry)); 4633 set_register(pc, reinterpret_cast<int64_t>(entry));
4625 // Put down marker for end of simulation. The simulator will stop simulation 4634 // Put down marker for end of simulation. The simulator will stop simulation
4626 // when the PC reaches this value. By saving the "end simulation" value into 4635 // when the PC reaches this value. By saving the "end simulation" value into
4627 // the LR the simulation stops when returning to this call point. 4636 // the LR the simulation stops when returning to this call point.
4628 set_register(ra, end_sim_pc); 4637 set_register(ra, end_sim_pc);
4629 4638
4630 // Remember the values of callee-saved registers. 4639 // Remember the values of callee-saved registers.
4631 // The code below assumes that r9 is not used as sb (static base) in 4640 // The code below assumes that r9 is not used as sb (static base) in
4632 // simulator code and therefore is regarded as a callee-saved register. 4641 // simulator code and therefore is regarded as a callee-saved register.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
4779 } 4788 }
4780 4789
4781 4790
4782 #undef UNSUPPORTED 4791 #undef UNSUPPORTED
4783 } // namespace internal 4792 } // namespace internal
4784 } // namespace v8 4793 } // namespace v8
4785 4794
4786 #endif // USE_SIMULATOR 4795 #endif // USE_SIMULATOR
4787 4796
4788 #endif // V8_TARGET_ARCH_MIPS64 4797 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698