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 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 | 1230 |
1231 if ((redirection->call_kind() == kRuntimeCall) || | 1231 if ((redirection->call_kind() == kRuntimeCall) || |
1232 (redirection->call_kind() == kBootstrapNativeCall) || | 1232 (redirection->call_kind() == kBootstrapNativeCall) || |
1233 (redirection->call_kind() == kNativeCall)) { | 1233 (redirection->call_kind() == kNativeCall)) { |
1234 // Set the top_exit_frame_info of this simulator to the native stack. | 1234 // Set the top_exit_frame_info of this simulator to the native stack. |
1235 set_top_exit_frame_info(Isolate::GetCurrentStackPointer()); | 1235 set_top_exit_frame_info(Isolate::GetCurrentStackPointer()); |
1236 } | 1236 } |
1237 if (redirection->call_kind() == kRuntimeCall) { | 1237 if (redirection->call_kind() == kRuntimeCall) { |
1238 NativeArguments arguments; | 1238 NativeArguments arguments; |
1239 ASSERT(sizeof(NativeArguments) == 4*kWordSize); | 1239 ASSERT(sizeof(NativeArguments) == 4*kWordSize); |
1240 arguments.isolate_ = reinterpret_cast<Isolate*>(get_register(A0)); | 1240 arguments.thread_ = reinterpret_cast<Thread*>(get_register(A0)); |
1241 arguments.argc_tag_ = get_register(A1); | 1241 arguments.argc_tag_ = get_register(A1); |
1242 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(A2)); | 1242 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(A2)); |
1243 arguments.retval_ = reinterpret_cast<RawObject**>(get_register(A3)); | 1243 arguments.retval_ = reinterpret_cast<RawObject**>(get_register(A3)); |
1244 SimulatorRuntimeCall target = | 1244 SimulatorRuntimeCall target = |
1245 reinterpret_cast<SimulatorRuntimeCall>(external); | 1245 reinterpret_cast<SimulatorRuntimeCall>(external); |
1246 target(arguments); | 1246 target(arguments); |
1247 set_register(V0, icount_); // Zap result registers from void function. | 1247 set_register(V0, icount_); // Zap result registers from void function. |
1248 set_register(V1, icount_); | 1248 set_register(V1, icount_); |
1249 } else if (redirection->call_kind() == kLeafRuntimeCall) { | 1249 } else if (redirection->call_kind() == kLeafRuntimeCall) { |
1250 int32_t a0 = get_register(A0); | 1250 int32_t a0 = get_register(A0); |
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2447 } | 2447 } |
2448 return return_value; | 2448 return return_value; |
2449 } | 2449 } |
2450 | 2450 |
2451 | 2451 |
2452 void Simulator::Longjmp(uword pc, | 2452 void Simulator::Longjmp(uword pc, |
2453 uword sp, | 2453 uword sp, |
2454 uword fp, | 2454 uword fp, |
2455 RawObject* raw_exception, | 2455 RawObject* raw_exception, |
2456 RawObject* raw_stacktrace, | 2456 RawObject* raw_stacktrace, |
2457 Isolate* isolate) { | 2457 Thread* thread) { |
2458 // Walk over all setjmp buffers (simulated --> C++ transitions) | 2458 // Walk over all setjmp buffers (simulated --> C++ transitions) |
2459 // and try to find the setjmp associated with the simulated stack pointer. | 2459 // and try to find the setjmp associated with the simulated stack pointer. |
2460 SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); | 2460 SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); |
2461 while (buf->link() != NULL && buf->link()->sp() <= sp) { | 2461 while (buf->link() != NULL && buf->link()->sp() <= sp) { |
2462 buf = buf->link(); | 2462 buf = buf->link(); |
2463 } | 2463 } |
2464 ASSERT(buf != NULL); | 2464 ASSERT(buf != NULL); |
2465 | 2465 |
2466 // The C++ caller has not cleaned up the stack memory of C++ frames. | 2466 // The C++ caller has not cleaned up the stack memory of C++ frames. |
2467 // Prepare for unwinding frames by destroying all the stack resources | 2467 // Prepare for unwinding frames by destroying all the stack resources |
2468 // in the previous C++ frames. | 2468 // in the previous C++ frames. |
| 2469 Isolate* isolate = thread->isolate(); |
2469 StackResource::Unwind(isolate); | 2470 StackResource::Unwind(isolate); |
2470 | 2471 |
2471 // Unwind the C++ stack and continue simulation in the target frame. | 2472 // Unwind the C++ stack and continue simulation in the target frame. |
2472 set_pc(static_cast<int32_t>(pc)); | 2473 set_pc(static_cast<int32_t>(pc)); |
2473 set_register(SP, static_cast<int32_t>(sp)); | 2474 set_register(SP, static_cast<int32_t>(sp)); |
2474 set_register(FP, static_cast<int32_t>(fp)); | 2475 set_register(FP, static_cast<int32_t>(fp)); |
| 2476 set_register(THR, reinterpret_cast<int32_t>(thread)); |
2475 // Set the tag. | 2477 // Set the tag. |
2476 isolate->set_vm_tag(VMTag::kDartTagId); | 2478 isolate->set_vm_tag(VMTag::kDartTagId); |
2477 // Clear top exit frame. | 2479 // Clear top exit frame. |
2478 isolate->set_top_exit_frame_info(0); | 2480 isolate->set_top_exit_frame_info(0); |
2479 | 2481 |
2480 ASSERT(raw_exception != Object::null()); | 2482 ASSERT(raw_exception != Object::null()); |
2481 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 2483 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |
2482 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 2484 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
2483 buf->Longjmp(); | 2485 buf->Longjmp(); |
2484 } | 2486 } |
2485 | 2487 |
2486 } // namespace dart | 2488 } // namespace dart |
2487 | 2489 |
2488 #endif // !defined(HOST_ARCH_MIPS) | 2490 #endif // !defined(HOST_ARCH_MIPS) |
2489 | 2491 |
2490 #endif // defined TARGET_ARCH_MIPS | 2492 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |