OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_DBC) | 9 #if defined(TARGET_ARCH_DBC) |
10 | 10 |
(...skipping 3673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3684 { | 3684 { |
3685 DispatchAfterException: | 3685 DispatchAfterException: |
3686 DISPATCH(); | 3686 DISPATCH(); |
3687 } | 3687 } |
3688 | 3688 |
3689 UNREACHABLE(); | 3689 UNREACHABLE(); |
3690 return 0; | 3690 return 0; |
3691 } | 3691 } |
3692 | 3692 |
3693 | 3693 |
3694 void Simulator::JumpToFrame(uword pc, uword sp, uword fp, Thread* thread) { | 3694 void Simulator::Longjmp(uword pc, |
| 3695 uword sp, |
| 3696 uword fp, |
| 3697 RawObject* raw_exception, |
| 3698 RawObject* raw_stacktrace, |
| 3699 Thread* thread) { |
3695 // Walk over all setjmp buffers (simulated --> C++ transitions) | 3700 // Walk over all setjmp buffers (simulated --> C++ transitions) |
3696 // and try to find the setjmp associated with the simulated stack pointer. | 3701 // and try to find the setjmp associated with the simulated stack pointer. |
3697 SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); | 3702 SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); |
3698 while ((buf->link() != NULL) && (buf->link()->fp() > fp)) { | 3703 while ((buf->link() != NULL) && (buf->link()->fp() > fp)) { |
3699 buf = buf->link(); | 3704 buf = buf->link(); |
3700 } | 3705 } |
3701 ASSERT(buf != NULL); | 3706 ASSERT(buf != NULL); |
3702 ASSERT(last_setjmp_buffer() == buf); | 3707 ASSERT(last_setjmp_buffer() == buf); |
3703 | 3708 |
3704 // The C++ caller has not cleaned up the stack memory of C++ frames. | 3709 // The C++ caller has not cleaned up the stack memory of C++ frames. |
3705 // Prepare for unwinding frames by destroying all the stack resources | 3710 // Prepare for unwinding frames by destroying all the stack resources |
3706 // in the previous C++ frames. | 3711 // in the previous C++ frames. |
3707 StackResource::Unwind(thread); | 3712 StackResource::Unwind(thread); |
3708 | 3713 |
3709 // Set the tag. | 3714 // Set the tag. |
3710 thread->set_vm_tag(VMTag::kDartTagId); | 3715 thread->set_vm_tag(VMTag::kDartTagId); |
3711 // Clear top exit frame. | 3716 // Clear top exit frame. |
3712 thread->set_top_exit_frame_info(0); | 3717 thread->set_top_exit_frame_info(0); |
3713 | 3718 |
| 3719 ASSERT(raw_exception != Object::null()); |
3714 sp_ = reinterpret_cast<RawObject**>(sp); | 3720 sp_ = reinterpret_cast<RawObject**>(sp); |
3715 fp_ = reinterpret_cast<RawObject**>(fp); | 3721 fp_ = reinterpret_cast<RawObject**>(fp); |
3716 | 3722 pc_ = pc; |
3717 if (pc == StubCode::RunExceptionHandler_entry()->EntryPoint()) { | 3723 special_[kExceptionSpecialIndex] = raw_exception; |
3718 // Instead of executing the RunException stub, we implement its | 3724 special_[kStacktraceSpecialIndex] = raw_stacktrace; |
3719 // behavior here. | |
3720 RawObject* raw_exception = thread->active_exception(); | |
3721 RawObject* raw_stacktrace = thread->active_stacktrace(); | |
3722 ASSERT(raw_exception != Object::null()); | |
3723 special_[kExceptionSpecialIndex] = raw_exception; | |
3724 special_[kStacktraceSpecialIndex] = raw_stacktrace; | |
3725 pc_ = thread->resume_pc(); | |
3726 } else { | |
3727 pc_ = pc; | |
3728 } | |
3729 | |
3730 buf->Longjmp(); | 3725 buf->Longjmp(); |
3731 UNREACHABLE(); | 3726 UNREACHABLE(); |
3732 } | 3727 } |
3733 | 3728 |
3734 } // namespace dart | 3729 } // namespace dart |
3735 | 3730 |
3736 #endif // defined TARGET_ARCH_DBC | 3731 #endif // defined TARGET_ARCH_DBC |
OLD | NEW |