OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 <setjmp.h> // NOLINT | 5 #include <setjmp.h> // NOLINT |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 #if defined(TARGET_ARCH_ARM) | 9 #if defined(TARGET_ARCH_ARM) |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 #define SScanF sscanf // NOLINT | 37 #define SScanF sscanf // NOLINT |
38 | 38 |
39 | 39 |
40 // SimulatorSetjmpBuffer are linked together, and the last created one | 40 // SimulatorSetjmpBuffer are linked together, and the last created one |
41 // is referenced by the Simulator. When an exception is thrown, the exception | 41 // is referenced by the Simulator. When an exception is thrown, the exception |
42 // runtime looks at where to jump and finds the corresponding | 42 // runtime looks at where to jump and finds the corresponding |
43 // SimulatorSetjmpBuffer based on the stack pointer of the exception handler. | 43 // SimulatorSetjmpBuffer based on the stack pointer of the exception handler. |
44 // The runtime then does a Longjmp on that buffer to return to the simulator. | 44 // The runtime then does a Longjmp on that buffer to return to the simulator. |
45 class SimulatorSetjmpBuffer { | 45 class SimulatorSetjmpBuffer { |
46 public: | 46 public: |
47 int Setjmp() { return setjmp(buffer_); } | |
48 void Longjmp() { | 47 void Longjmp() { |
49 // "This" is now the last setjmp buffer. | 48 // "This" is now the last setjmp buffer. |
50 simulator_->set_last_setjmp_buffer(this); | 49 simulator_->set_last_setjmp_buffer(this); |
51 longjmp(buffer_, 1); | 50 longjmp(buffer_, 1); |
52 } | 51 } |
53 | 52 |
54 explicit SimulatorSetjmpBuffer(Simulator* sim) { | 53 explicit SimulatorSetjmpBuffer(Simulator* sim) { |
55 simulator_ = sim; | 54 simulator_ = sim; |
56 link_ = sim->last_setjmp_buffer(); | 55 link_ = sim->last_setjmp_buffer(); |
57 sim->set_last_setjmp_buffer(this); | 56 sim->set_last_setjmp_buffer(this); |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 (redirection->call_kind() == kBootstrapNativeCall) || | 1538 (redirection->call_kind() == kBootstrapNativeCall) || |
1540 (redirection->call_kind() == kNativeCall)) { | 1539 (redirection->call_kind() == kNativeCall)) { |
1541 // Set the top_exit_frame_info of this simulator to the native stack. | 1540 // Set the top_exit_frame_info of this simulator to the native stack. |
1542 set_top_exit_frame_info(Thread::GetCurrentStackPointer()); | 1541 set_top_exit_frame_info(Thread::GetCurrentStackPointer()); |
1543 } | 1542 } |
1544 if (redirection->call_kind() == kRuntimeCall) { | 1543 if (redirection->call_kind() == kRuntimeCall) { |
1545 NativeArguments arguments; | 1544 NativeArguments arguments; |
1546 ASSERT(sizeof(NativeArguments) == 4*kWordSize); | 1545 ASSERT(sizeof(NativeArguments) == 4*kWordSize); |
1547 arguments.thread_ = reinterpret_cast<Thread*>(get_register(R0)); | 1546 arguments.thread_ = reinterpret_cast<Thread*>(get_register(R0)); |
1548 arguments.argc_tag_ = get_register(R1); | 1547 arguments.argc_tag_ = get_register(R1); |
1549 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(R2)); | 1548 arguments.argv_ = reinterpret_cast<RawObject**>(get_register(R2)); |
1550 arguments.retval_ = reinterpret_cast<RawObject**>(get_register(R3)); | 1549 arguments.retval_ = reinterpret_cast<RawObject**>(get_register(R3)); |
1551 SimulatorRuntimeCall target = | 1550 SimulatorRuntimeCall target = |
1552 reinterpret_cast<SimulatorRuntimeCall>(external); | 1551 reinterpret_cast<SimulatorRuntimeCall>(external); |
1553 target(arguments); | 1552 target(arguments); |
1554 set_register(R0, icount_); // Zap result register from void function. | 1553 set_register(R0, icount_); // Zap result register from void function. |
1555 set_register(R1, icount_); | 1554 set_register(R1, icount_); |
1556 } else if (redirection->call_kind() == kLeafRuntimeCall) { | 1555 } else if (redirection->call_kind() == kLeafRuntimeCall) { |
1557 ASSERT((0 <= redirection->argument_count()) && | 1556 ASSERT((0 <= redirection->argument_count()) && |
1558 (redirection->argument_count() <= 4)); | 1557 (redirection->argument_count() <= 4)); |
1559 int32_t r0 = get_register(R0); | 1558 int32_t r0 = get_register(R0); |
(...skipping 2348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3908 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 3907 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |
3909 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 3908 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
3910 buf->Longjmp(); | 3909 buf->Longjmp(); |
3911 } | 3910 } |
3912 | 3911 |
3913 } // namespace dart | 3912 } // namespace dart |
3914 | 3913 |
3915 #endif // defined(USING_SIMULATOR) | 3914 #endif // defined(USING_SIMULATOR) |
3916 | 3915 |
3917 #endif // defined TARGET_ARCH_ARM | 3916 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |