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 <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_ARM64) | 9 #if defined(TARGET_ARCH_ARM64) |
10 | 10 |
(...skipping 3557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3568 } else { | 3568 } else { |
3569 return_value = get_register(R0); | 3569 return_value = get_register(R0); |
3570 } | 3570 } |
3571 return return_value; | 3571 return return_value; |
3572 } | 3572 } |
3573 | 3573 |
3574 | 3574 |
3575 void Simulator::Longjmp(uword pc, | 3575 void Simulator::Longjmp(uword pc, |
3576 uword sp, | 3576 uword sp, |
3577 uword fp, | 3577 uword fp, |
| 3578 uword pp, |
3578 RawObject* raw_exception, | 3579 RawObject* raw_exception, |
3579 RawObject* raw_stacktrace, | 3580 RawObject* raw_stacktrace, |
3580 Thread* thread) { | 3581 Thread* thread) { |
3581 // Walk over all setjmp buffers (simulated --> C++ transitions) | 3582 // Walk over all setjmp buffers (simulated --> C++ transitions) |
3582 // and try to find the setjmp associated with the simulated stack pointer. | 3583 // and try to find the setjmp associated with the simulated stack pointer. |
3583 SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); | 3584 SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); |
3584 while (buf->link() != NULL && buf->link()->sp() <= sp) { | 3585 while (buf->link() != NULL && buf->link()->sp() <= sp) { |
3585 buf = buf->link(); | 3586 buf = buf->link(); |
3586 } | 3587 } |
3587 ASSERT(buf != NULL); | 3588 ASSERT(buf != NULL); |
3588 | 3589 |
3589 // The C++ caller has not cleaned up the stack memory of C++ frames. | 3590 // The C++ caller has not cleaned up the stack memory of C++ frames. |
3590 // Prepare for unwinding frames by destroying all the stack resources | 3591 // Prepare for unwinding frames by destroying all the stack resources |
3591 // in the previous C++ frames. | 3592 // in the previous C++ frames. |
3592 StackResource::Unwind(thread); | 3593 StackResource::Unwind(thread); |
3593 | 3594 |
3594 // Unwind the C++ stack and continue simulation in the target frame. | 3595 // Unwind the C++ stack and continue simulation in the target frame. |
3595 set_pc(static_cast<int64_t>(pc)); | 3596 set_pc(static_cast<int64_t>(pc)); |
3596 set_register(NULL, SP, static_cast<int64_t>(sp)); | 3597 set_register(NULL, SP, static_cast<int64_t>(sp)); |
3597 set_register(NULL, FP, static_cast<int64_t>(fp)); | 3598 set_register(NULL, FP, static_cast<int64_t>(fp)); |
| 3599 // In the PP register, the pool pointer is untagged. |
| 3600 set_register(NULL, PP, static_cast<int64_t>(pp) - kHeapObjectTag); |
3598 set_register(NULL, THR, reinterpret_cast<int64_t>(thread)); | 3601 set_register(NULL, THR, reinterpret_cast<int64_t>(thread)); |
3599 // Set the tag. | 3602 // Set the tag. |
3600 thread->set_vm_tag(VMTag::kDartTagId); | 3603 thread->set_vm_tag(VMTag::kDartTagId); |
3601 // Clear top exit frame. | 3604 // Clear top exit frame. |
3602 thread->set_top_exit_frame_info(0); | 3605 thread->set_top_exit_frame_info(0); |
3603 | 3606 |
3604 ASSERT(raw_exception != Object::null()); | 3607 ASSERT(raw_exception != Object::null()); |
3605 set_register(NULL, kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); | 3608 set_register(NULL, kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); |
3606 set_register(NULL, kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); | 3609 set_register(NULL, kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); |
3607 // Restore pool pointer. | |
3608 int64_t code = *reinterpret_cast<int64_t*>( | |
3609 fp + kPcMarkerSlotFromFp * kWordSize); | |
3610 int64_t pp = *reinterpret_cast<int64_t*>( | |
3611 code + Code::object_pool_offset() - kHeapObjectTag); | |
3612 pp -= kHeapObjectTag; // In the PP register, the pool pointer is untagged. | |
3613 set_register(NULL, CODE_REG, code); | |
3614 set_register(NULL, PP, pp); | |
3615 buf->Longjmp(); | 3610 buf->Longjmp(); |
3616 } | 3611 } |
3617 | 3612 |
3618 } // namespace dart | 3613 } // namespace dart |
3619 | 3614 |
3620 #endif // !defined(USING_SIMULATOR) | 3615 #endif // !defined(USING_SIMULATOR) |
3621 | 3616 |
3622 #endif // defined TARGET_ARCH_ARM64 | 3617 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |