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

Side by Side Diff: src/arm/simulator-arm.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 <stdarg.h> 5 #include <stdarg.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <cmath> 7 #include <cmath>
8 8
9 #if V8_TARGET_ARCH_ARM 9 #if V8_TARGET_ARCH_ARM
10 10
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 *ptr++ = value1; 1220 *ptr++ = value1;
1221 *ptr = value2; 1221 *ptr = value2;
1222 } else { 1222 } else {
1223 PrintF("Unaligned write at 0x%08x\n", addr); 1223 PrintF("Unaligned write at 0x%08x\n", addr);
1224 UNIMPLEMENTED(); 1224 UNIMPLEMENTED();
1225 } 1225 }
1226 } 1226 }
1227 1227
1228 1228
1229 // Returns the limit of the stack area to enable checking for stack overflows. 1229 // Returns the limit of the stack area to enable checking for stack overflows.
1230 uintptr_t Simulator::StackLimit() const { 1230 uintptr_t Simulator::StackLimit(uintptr_t c_limit) const {
1231 // Leave a safety margin of 1024 bytes to prevent overrunning the stack when 1231 // The simulator uses a separate JS stack. If we have exhausted the C stack,
1232 // pushing values. 1232 // we also drop down the JS limit to reflect the exhaustion on the JS stack.
1233 if (GetCurrentStackPosition() < c_limit) {
1234 return reinterpret_cast<uintptr_t>(get_sp());
1235 }
1236
1237 // Otherwise the limit is the JS stack. Leave a safety margin of 1024 bytes
1238 // to prevent overrunning the stack when pushing values.
1233 return reinterpret_cast<uintptr_t>(stack_) + 1024; 1239 return reinterpret_cast<uintptr_t>(stack_) + 1024;
1234 } 1240 }
1235 1241
1236 1242
1237 // Unsupported instructions use Format to print an error and stop execution. 1243 // Unsupported instructions use Format to print an error and stop execution.
1238 void Simulator::Format(Instruction* instr, const char* format) { 1244 void Simulator::Format(Instruction* instr, const char* format) {
1239 PrintF("Simulator found unsupported instruction:\n 0x%08x: %s\n", 1245 PrintF("Simulator found unsupported instruction:\n 0x%08x: %s\n",
1240 reinterpret_cast<intptr_t>(instr), format); 1246 reinterpret_cast<intptr_t>(instr), format);
1241 UNIMPLEMENTED(); 1247 UNIMPLEMENTED();
1242 } 1248 }
(...skipping 2759 matching lines...) Expand 10 before | Expand all | Expand 10 after
4002 } else { 4008 } else {
4003 InstructionDecode(instr); 4009 InstructionDecode(instr);
4004 } 4010 }
4005 program_counter = get_pc(); 4011 program_counter = get_pc();
4006 } 4012 }
4007 } 4013 }
4008 } 4014 }
4009 4015
4010 4016
4011 void Simulator::CallInternal(byte* entry) { 4017 void Simulator::CallInternal(byte* entry) {
4018 // Adjust JS-based stack limit to C-based stack limit.
4019 isolate_->stack_guard()->AdjustStackLimitForSimulator();
4020
4012 // Prepare to execute the code at entry 4021 // Prepare to execute the code at entry
4013 set_register(pc, reinterpret_cast<int32_t>(entry)); 4022 set_register(pc, reinterpret_cast<int32_t>(entry));
4014 // Put down marker for end of simulation. The simulator will stop simulation 4023 // Put down marker for end of simulation. The simulator will stop simulation
4015 // when the PC reaches this value. By saving the "end simulation" value into 4024 // when the PC reaches this value. By saving the "end simulation" value into
4016 // the LR the simulation stops when returning to this call point. 4025 // the LR the simulation stops when returning to this call point.
4017 set_register(lr, end_sim_pc); 4026 set_register(lr, end_sim_pc);
4018 4027
4019 // Remember the values of callee-saved registers. 4028 // Remember the values of callee-saved registers.
4020 // The code below assumes that r9 is not used as sb (static base) in 4029 // The code below assumes that r9 is not used as sb (static base) in
4021 // simulator code and therefore is regarded as a callee-saved register. 4030 // simulator code and therefore is regarded as a callee-saved register.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
4148 set_register(sp, current_sp + sizeof(uintptr_t)); 4157 set_register(sp, current_sp + sizeof(uintptr_t));
4149 return address; 4158 return address;
4150 } 4159 }
4151 4160
4152 } // namespace internal 4161 } // namespace internal
4153 } // namespace v8 4162 } // namespace v8
4154 4163
4155 #endif // USE_SIMULATOR 4164 #endif // USE_SIMULATOR
4156 4165
4157 #endif // V8_TARGET_ARCH_ARM 4166 #endif // V8_TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698