OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <cmath> | 6 #include <cmath> |
7 #include <cstdarg> | 7 #include <cstdarg> |
8 | 8 |
9 #if V8_TARGET_ARCH_ARM64 | 9 #if V8_TARGET_ARCH_ARM64 |
10 | 10 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 CallArgument(direct_call), | 215 CallArgument(direct_call), |
216 CallArgument(return_address), | 216 CallArgument(return_address), |
217 CallArgument(isolate), | 217 CallArgument(isolate), |
218 CallArgument::End() | 218 CallArgument::End() |
219 }; | 219 }; |
220 return CallInt64(entry, args); | 220 return CallInt64(entry, args); |
221 } | 221 } |
222 | 222 |
223 | 223 |
224 void Simulator::CheckPCSComplianceAndRun() { | 224 void Simulator::CheckPCSComplianceAndRun() { |
| 225 // Adjust JS-based stack limit to C-based stack limit. |
| 226 isolate_->stack_guard()->AdjustStackLimitForSimulator(); |
| 227 |
225 #ifdef DEBUG | 228 #ifdef DEBUG |
226 CHECK_EQ(kNumberOfCalleeSavedRegisters, kCalleeSaved.Count()); | 229 CHECK_EQ(kNumberOfCalleeSavedRegisters, kCalleeSaved.Count()); |
227 CHECK_EQ(kNumberOfCalleeSavedFPRegisters, kCalleeSavedFP.Count()); | 230 CHECK_EQ(kNumberOfCalleeSavedFPRegisters, kCalleeSavedFP.Count()); |
228 | 231 |
229 int64_t saved_registers[kNumberOfCalleeSavedRegisters]; | 232 int64_t saved_registers[kNumberOfCalleeSavedRegisters]; |
230 uint64_t saved_fpregisters[kNumberOfCalleeSavedFPRegisters]; | 233 uint64_t saved_fpregisters[kNumberOfCalleeSavedFPRegisters]; |
231 | 234 |
232 CPURegList register_list = kCalleeSaved; | 235 CPURegList register_list = kCalleeSaved; |
233 CPURegList fpregister_list = kCalleeSavedFP; | 236 CPURegList fpregister_list = kCalleeSavedFP; |
234 | 237 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 intptr_t current_sp = sp(); | 328 intptr_t current_sp = sp(); |
326 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); | 329 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); |
327 uintptr_t address = *stack_slot; | 330 uintptr_t address = *stack_slot; |
328 DCHECK(sizeof(uintptr_t) < 2 * kXRegSize); | 331 DCHECK(sizeof(uintptr_t) < 2 * kXRegSize); |
329 set_sp(current_sp + 2 * kXRegSize); | 332 set_sp(current_sp + 2 * kXRegSize); |
330 return address; | 333 return address; |
331 } | 334 } |
332 | 335 |
333 | 336 |
334 // Returns the limit of the stack area to enable checking for stack overflows. | 337 // Returns the limit of the stack area to enable checking for stack overflows. |
335 uintptr_t Simulator::StackLimit() const { | 338 uintptr_t Simulator::StackLimit(uintptr_t c_limit) const { |
336 // Leave a safety margin of 1024 bytes to prevent overrunning the stack when | 339 // The simulator uses a separate JS stack. If we have exhausted the C stack, |
337 // pushing values. | 340 // we also drop down the JS limit to reflect the exhaustion on the JS stack. |
| 341 if (GetCurrentStackPosition() < c_limit) { |
| 342 return reinterpret_cast<uintptr_t>(get_sp()); |
| 343 } |
| 344 |
| 345 // Otherwise the limit is the JS stack. Leave a safety margin of 1024 bytes |
| 346 // to prevent overrunning the stack when pushing values. |
338 return stack_limit_ + 1024; | 347 return stack_limit_ + 1024; |
339 } | 348 } |
340 | 349 |
341 | 350 |
342 Simulator::Simulator(Decoder<DispatchingDecoderVisitor>* decoder, | 351 Simulator::Simulator(Decoder<DispatchingDecoderVisitor>* decoder, |
343 Isolate* isolate, FILE* stream) | 352 Isolate* isolate, FILE* stream) |
344 : decoder_(decoder), | 353 : decoder_(decoder), |
345 last_debugger_input_(NULL), | 354 last_debugger_input_(NULL), |
346 log_parameters_(NO_PARAM), | 355 log_parameters_(NO_PARAM), |
347 isolate_(isolate) { | 356 isolate_(isolate) { |
(...skipping 3480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3828 delete[] format; | 3837 delete[] format; |
3829 } | 3838 } |
3830 | 3839 |
3831 | 3840 |
3832 #endif // USE_SIMULATOR | 3841 #endif // USE_SIMULATOR |
3833 | 3842 |
3834 } // namespace internal | 3843 } // namespace internal |
3835 } // namespace v8 | 3844 } // namespace v8 |
3836 | 3845 |
3837 #endif // V8_TARGET_ARCH_ARM64 | 3846 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |