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 2483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2494 } else { | 2494 } else { |
2495 return_value = Utils::LowHighTo64Bits(get_register(V0), get_register(V1)); | 2495 return_value = Utils::LowHighTo64Bits(get_register(V0), get_register(V1)); |
2496 } | 2496 } |
2497 return return_value; | 2497 return return_value; |
2498 } | 2498 } |
2499 | 2499 |
2500 | 2500 |
2501 void Simulator::Longjmp(uword pc, | 2501 void Simulator::Longjmp(uword pc, |
2502 uword sp, | 2502 uword sp, |
2503 uword fp, | 2503 uword fp, |
2504 uword pp, | |
2505 RawObject* raw_exception, | 2504 RawObject* raw_exception, |
2506 RawObject* raw_stacktrace, | 2505 RawObject* raw_stacktrace, |
2507 Thread* thread) { | 2506 Thread* thread) { |
2508 // Walk over all setjmp buffers (simulated --> C++ transitions) | 2507 // Walk over all setjmp buffers (simulated --> C++ transitions) |
2509 // and try to find the setjmp associated with the simulated stack pointer. | 2508 // and try to find the setjmp associated with the simulated stack pointer. |
2510 SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); | 2509 SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); |
2511 while (buf->link() != NULL && buf->link()->sp() <= sp) { | 2510 while (buf->link() != NULL && buf->link()->sp() <= sp) { |
2512 buf = buf->link(); | 2511 buf = buf->link(); |
2513 } | 2512 } |
2514 ASSERT(buf != NULL); | 2513 ASSERT(buf != NULL); |
2515 | 2514 |
2516 // The C++ caller has not cleaned up the stack memory of C++ frames. | 2515 // The C++ caller has not cleaned up the stack memory of C++ frames. |
2517 // Prepare for unwinding frames by destroying all the stack resources | 2516 // Prepare for unwinding frames by destroying all the stack resources |
2518 // in the previous C++ frames. | 2517 // in the previous C++ frames. |
2519 StackResource::Unwind(thread); | 2518 StackResource::Unwind(thread); |
2520 | 2519 |
2521 // Unwind the C++ stack and continue simulation in the target frame. | 2520 // Unwind the C++ stack and continue simulation in the target frame. |
2522 set_pc(static_cast<int32_t>(pc)); | 2521 set_pc(static_cast<int32_t>(pc)); |
2523 set_register(SP, static_cast<int32_t>(sp)); | 2522 set_register(SP, static_cast<int32_t>(sp)); |
2524 set_register(FP, static_cast<int32_t>(fp)); | 2523 set_register(FP, static_cast<int32_t>(fp)); |
2525 set_register(PP, static_cast<int32_t>(pp)); | |
2526 set_register(THR, reinterpret_cast<int32_t>(thread)); | 2524 set_register(THR, reinterpret_cast<int32_t>(thread)); |
2527 // Set the tag. | 2525 // Set the tag. |
2528 thread->set_vm_tag(VMTag::kDartTagId); | 2526 thread->set_vm_tag(VMTag::kDartTagId); |
2529 // Clear top exit frame. | 2527 // Clear top exit frame. |
2530 thread->set_top_exit_frame_info(0); | 2528 thread->set_top_exit_frame_info(0); |
2531 | 2529 |
2532 ASSERT(raw_exception != Object::null()); | 2530 ASSERT(raw_exception != Object::null()); |
2533 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 2531 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |
2534 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 2532 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
| 2533 // Restore pool pointer. |
| 2534 int32_t code = *reinterpret_cast<int32_t*>( |
| 2535 fp + kPcMarkerSlotFromFp * kWordSize); |
| 2536 int32_t pp = *reinterpret_cast<int32_t*>( |
| 2537 code + Code::object_pool_offset() - kHeapObjectTag); |
| 2538 set_register(CODE_REG, code); |
| 2539 set_register(PP, pp); |
2535 buf->Longjmp(); | 2540 buf->Longjmp(); |
2536 } | 2541 } |
2537 | 2542 |
2538 } // namespace dart | 2543 } // namespace dart |
2539 | 2544 |
2540 #endif // defined(USING_SIMULATOR) | 2545 #endif // defined(USING_SIMULATOR) |
2541 | 2546 |
2542 #endif // defined TARGET_ARCH_MIPS | 2547 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |