OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include <math.h> // for isnan. | 5 #include <math.h> // for isnan. |
6 #include <setjmp.h> | 6 #include <setjmp.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 #if defined(TARGET_ARCH_ARM64) | 10 #if defined(TARGET_ARCH_ARM64) |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 // the size specified by the user and the buffer space needed for | 398 // the size specified by the user and the buffer space needed for |
399 // handling stack overflow exceptions. To be safe in potential | 399 // handling stack overflow exceptions. To be safe in potential |
400 // stack underflows we also add some underflow buffer space. | 400 // stack underflows we also add some underflow buffer space. |
401 stack_ = new char[(Isolate::GetSpecifiedStackSize() + | 401 stack_ = new char[(Isolate::GetSpecifiedStackSize() + |
402 Isolate::kStackSizeBuffer + | 402 Isolate::kStackSizeBuffer + |
403 kSimulatorStackUnderflowSize)]; | 403 kSimulatorStackUnderflowSize)]; |
404 pc_modified_ = false; | 404 pc_modified_ = false; |
405 icount_ = 0; | 405 icount_ = 0; |
406 break_pc_ = NULL; | 406 break_pc_ = NULL; |
407 break_instr_ = 0; | 407 break_instr_ = 0; |
| 408 last_setjmp_buffer_ = NULL; |
408 top_exit_frame_info_ = 0; | 409 top_exit_frame_info_ = 0; |
409 | 410 |
410 // Setup architecture state. | 411 // Setup architecture state. |
411 // All registers are initialized to zero to start with. | 412 // All registers are initialized to zero to start with. |
412 for (int i = 0; i < kNumberOfCpuRegisters; i++) { | 413 for (int i = 0; i < kNumberOfCpuRegisters; i++) { |
413 registers_[i] = 0; | 414 registers_[i] = 0; |
414 } | 415 } |
415 n_flag_ = false; | 416 n_flag_ = false; |
416 z_flag_ = false; | 417 z_flag_ = false; |
417 c_flag_ = false; | 418 c_flag_ = false; |
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2058 set_register(R28, r28_val); | 2059 set_register(R28, r28_val); |
2059 set_register(R29, r29_val); | 2060 set_register(R29, r29_val); |
2060 | 2061 |
2061 // Restore the SP register and return R0. | 2062 // Restore the SP register and return R0. |
2062 set_register(R31, sp_before_call, R31IsSP); | 2063 set_register(R31, sp_before_call, R31IsSP); |
2063 int64_t return_value; | 2064 int64_t return_value; |
2064 return_value = get_register(R0); | 2065 return_value = get_register(R0); |
2065 return return_value; | 2066 return return_value; |
2066 } | 2067 } |
2067 | 2068 |
| 2069 |
| 2070 void Simulator::Longjmp(uword pc, |
| 2071 uword sp, |
| 2072 uword fp, |
| 2073 RawObject* raw_exception, |
| 2074 RawObject* raw_stacktrace) { |
| 2075 // Walk over all setjmp buffers (simulated --> C++ transitions) |
| 2076 // and try to find the setjmp associated with the simulated stack pointer. |
| 2077 SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); |
| 2078 while (buf->link() != NULL && buf->link()->sp() <= sp) { |
| 2079 buf = buf->link(); |
| 2080 } |
| 2081 ASSERT(buf != NULL); |
| 2082 |
| 2083 // The C++ caller has not cleaned up the stack memory of C++ frames. |
| 2084 // Prepare for unwinding frames by destroying all the stack resources |
| 2085 // in the previous C++ frames. |
| 2086 uword native_sp = buf->native_sp(); |
| 2087 Isolate* isolate = Isolate::Current(); |
| 2088 while (isolate->top_resource() != NULL && |
| 2089 (reinterpret_cast<uword>(isolate->top_resource()) < native_sp)) { |
| 2090 isolate->top_resource()->~StackResource(); |
| 2091 } |
| 2092 |
| 2093 // Unwind the C++ stack and continue simulation in the target frame. |
| 2094 set_pc(static_cast<int64_t>(pc)); |
| 2095 set_register(R31, static_cast<int64_t>(sp), R31IsSP); |
| 2096 set_register(FP, static_cast<int64_t>(fp)); |
| 2097 |
| 2098 ASSERT(raw_exception != Object::null()); |
| 2099 set_register(kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); |
| 2100 set_register(kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); |
| 2101 buf->Longjmp(); |
| 2102 } |
| 2103 |
2068 } // namespace dart | 2104 } // namespace dart |
2069 | 2105 |
2070 #endif // !defined(HOST_ARCH_ARM64) | 2106 #endif // !defined(HOST_ARCH_ARM64) |
2071 | 2107 |
2072 #endif // defined TARGET_ARCH_ARM64 | 2108 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |