OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/longjump.h" | 5 #include "vm/longjump.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 | 8 |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 return &environment_; | 21 return &environment_; |
22 } | 22 } |
23 | 23 |
24 | 24 |
25 bool LongJumpScope::IsSafeToJump() { | 25 bool LongJumpScope::IsSafeToJump() { |
26 // We do not want to jump past Dart frames. Note that this code | 26 // We do not want to jump past Dart frames. Note that this code |
27 // assumes the stack grows from high to low. | 27 // assumes the stack grows from high to low. |
28 Thread* thread = Thread::Current(); | 28 Thread* thread = Thread::Current(); |
29 uword jumpbuf_addr = Isolate::GetCurrentStackPointer(); | 29 uword jumpbuf_addr = Isolate::GetCurrentStackPointer(); |
30 #if defined(USING_SIMULATOR) | 30 #if defined(USING_SIMULATOR) |
31 { | 31 Isolate* isolate = thread->isolate(); |
32 Isolate* isolate = thread->isolate(); | 32 ASSERT(isolate->MutatorThreadIsCurrentThread()); |
33 ASSERT(isolate->MutatorThreadIsCurrentThread()); | 33 uword top_exit_frame_info = isolate->simulator()->top_exit_frame_info(); |
34 uword top_exit_frame_info = isolate->simulator()->top_exit_frame_info(); | |
35 } | |
36 #else | 34 #else |
37 uword top_exit_frame_info = thread->top_exit_frame_info(); | 35 uword top_exit_frame_info = thread->top_exit_frame_info(); |
38 #endif | 36 #endif |
39 return ((top_exit_frame_info == 0) || (jumpbuf_addr < top_exit_frame_info)); | 37 return ((top_exit_frame_info == 0) || (jumpbuf_addr < top_exit_frame_info)); |
40 } | 38 } |
41 | 39 |
42 | 40 |
43 void LongJumpScope::Jump(int value, const Error& error) { | 41 void LongJumpScope::Jump(int value, const Error& error) { |
44 // A zero is the default return value from setting up a LongJumpScope | 42 // A zero is the default return value from setting up a LongJumpScope |
45 // using Set. | 43 // using Set. |
(...skipping 13 matching lines...) Expand all Loading... |
59 // Remember the error in the sticky error of this isolate. | 57 // Remember the error in the sticky error of this isolate. |
60 isolate->object_store()->set_sticky_error(error); | 58 isolate->object_store()->set_sticky_error(error); |
61 | 59 |
62 // Destruct all the active StackResource objects. | 60 // Destruct all the active StackResource objects. |
63 StackResource::UnwindAbove(thread, top_); | 61 StackResource::UnwindAbove(thread, top_); |
64 longjmp(environment_, value); | 62 longjmp(environment_, value); |
65 UNREACHABLE(); | 63 UNREACHABLE(); |
66 } | 64 } |
67 | 65 |
68 } // namespace dart | 66 } // namespace dart |
OLD | NEW |