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_MIPS) | 9 #if defined(TARGET_ARCH_MIPS) |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 #define SScanF sscanf // NOLINT | 36 #define SScanF sscanf // NOLINT |
37 | 37 |
38 | 38 |
39 // SimulatorSetjmpBuffer are linked together, and the last created one | 39 // SimulatorSetjmpBuffer are linked together, and the last created one |
40 // is referenced by the Simulator. When an exception is thrown, the exception | 40 // is referenced by the Simulator. When an exception is thrown, the exception |
41 // runtime looks at where to jump and finds the corresponding | 41 // runtime looks at where to jump and finds the corresponding |
42 // SimulatorSetjmpBuffer based on the stack pointer of the exception handler. | 42 // SimulatorSetjmpBuffer based on the stack pointer of the exception handler. |
43 // The runtime then does a Longjmp on that buffer to return to the simulator. | 43 // The runtime then does a Longjmp on that buffer to return to the simulator. |
44 class SimulatorSetjmpBuffer { | 44 class SimulatorSetjmpBuffer { |
45 public: | 45 public: |
46 int Setjmp() { return setjmp(buffer_); } | |
47 void Longjmp() { | 46 void Longjmp() { |
48 // "This" is now the last setjmp buffer. | 47 // "This" is now the last setjmp buffer. |
49 simulator_->set_last_setjmp_buffer(this); | 48 simulator_->set_last_setjmp_buffer(this); |
50 longjmp(buffer_, 1); | 49 longjmp(buffer_, 1); |
51 } | 50 } |
52 | 51 |
53 explicit SimulatorSetjmpBuffer(Simulator* sim) { | 52 explicit SimulatorSetjmpBuffer(Simulator* sim) { |
54 simulator_ = sim; | 53 simulator_ = sim; |
55 link_ = sim->last_setjmp_buffer(); | 54 link_ = sim->last_setjmp_buffer(); |
56 sim->set_last_setjmp_buffer(this); | 55 sim->set_last_setjmp_buffer(this); |
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 (redirection->call_kind() == kBootstrapNativeCall) || | 1249 (redirection->call_kind() == kBootstrapNativeCall) || |
1251 (redirection->call_kind() == kNativeCall)) { | 1250 (redirection->call_kind() == kNativeCall)) { |
1252 // Set the top_exit_frame_info of this simulator to the native stack. | 1251 // Set the top_exit_frame_info of this simulator to the native stack. |
1253 set_top_exit_frame_info(Thread::GetCurrentStackPointer()); | 1252 set_top_exit_frame_info(Thread::GetCurrentStackPointer()); |
1254 } | 1253 } |
1255 if (redirection->call_kind() == kRuntimeCall) { | 1254 if (redirection->call_kind() == kRuntimeCall) { |
1256 NativeArguments arguments; | 1255 NativeArguments arguments; |
1257 ASSERT(sizeof(NativeArguments) == 4*kWordSize); | 1256 ASSERT(sizeof(NativeArguments) == 4*kWordSize); |
1258 arguments.thread_ = reinterpret_cast<Thread*>(get_register(A0)); | 1257 arguments.thread_ = reinterpret_cast<Thread*>(get_register(A0)); |
1259 arguments.argc_tag_ = get_register(A1); | 1258 arguments.argc_tag_ = get_register(A1); |
1260 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(A2)); | 1259 arguments.argv_ = reinterpret_cast<RawObject**>(get_register(A2)); |
1261 arguments.retval_ = reinterpret_cast<RawObject**>(get_register(A3)); | 1260 arguments.retval_ = reinterpret_cast<RawObject**>(get_register(A3)); |
1262 SimulatorRuntimeCall target = | 1261 SimulatorRuntimeCall target = |
1263 reinterpret_cast<SimulatorRuntimeCall>(external); | 1262 reinterpret_cast<SimulatorRuntimeCall>(external); |
1264 target(arguments); | 1263 target(arguments); |
1265 set_register(V0, icount_); // Zap result registers from void function. | 1264 set_register(V0, icount_); // Zap result registers from void function. |
1266 set_register(V1, icount_); | 1265 set_register(V1, icount_); |
1267 } else if (redirection->call_kind() == kLeafRuntimeCall) { | 1266 } else if (redirection->call_kind() == kLeafRuntimeCall) { |
1268 int32_t a0 = get_register(A0); | 1267 int32_t a0 = get_register(A0); |
1269 int32_t a1 = get_register(A1); | 1268 int32_t a1 = get_register(A1); |
1270 int32_t a2 = get_register(A2); | 1269 int32_t a2 = get_register(A2); |
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2532 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 2531 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |
2533 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 2532 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
2534 buf->Longjmp(); | 2533 buf->Longjmp(); |
2535 } | 2534 } |
2536 | 2535 |
2537 } // namespace dart | 2536 } // namespace dart |
2538 | 2537 |
2539 #endif // defined(USING_SIMULATOR) | 2538 #endif // defined(USING_SIMULATOR) |
2540 | 2539 |
2541 #endif // defined TARGET_ARCH_MIPS | 2540 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |