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 #ifndef RUNTIME_VM_LONGJUMP_H_ | 5 #ifndef RUNTIME_VM_LONGJUMP_H_ |
6 #define RUNTIME_VM_LONGJUMP_H_ | 6 #define RUNTIME_VM_LONGJUMP_H_ |
7 | 7 |
8 #include <setjmp.h> | 8 #include <setjmp.h> |
9 | 9 |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
11 #include "vm/isolate.h" | 11 #include "vm/isolate.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 class Error; | 15 class Error; |
16 | 16 |
17 class LongJumpScope : public StackResource { | 17 class LongJumpScope : public StackResource { |
18 public: | 18 public: |
19 LongJumpScope() | 19 LongJumpScope() |
20 : StackResource(Thread::Current()), | 20 : StackResource(Thread::Current()), |
21 top_(NULL), | 21 top_(NULL), |
22 base_(Thread::Current()->long_jump_base()) { | 22 base_(Thread::Current()->long_jump_base()) { |
23 Thread::Current()->set_long_jump_base(this); | 23 Thread::Current()->set_long_jump_base(this); |
24 } | 24 } |
25 | 25 |
26 ~LongJumpScope() { | 26 ~LongJumpScope() { Thread::Current()->set_long_jump_base(base_); } |
27 Thread::Current()->set_long_jump_base(base_); | |
28 } | |
29 | 27 |
30 jmp_buf* Set(); | 28 jmp_buf* Set(); |
31 void Jump(int value, const Error& error); | 29 void Jump(int value, const Error& error); |
32 | 30 |
33 // Would it be safe to use this longjump? | 31 // Would it be safe to use this longjump? |
34 // | 32 // |
35 // Checks to make sure that the jump would not cross Dart frames. | 33 // Checks to make sure that the jump would not cross Dart frames. |
36 bool IsSafeToJump(); | 34 bool IsSafeToJump(); |
37 | 35 |
38 private: | 36 private: |
39 jmp_buf environment_; | 37 jmp_buf environment_; |
40 StackResource* top_; | 38 StackResource* top_; |
41 LongJumpScope* base_; | 39 LongJumpScope* base_; |
42 | 40 |
43 DISALLOW_COPY_AND_ASSIGN(LongJumpScope); | 41 DISALLOW_COPY_AND_ASSIGN(LongJumpScope); |
44 }; | 42 }; |
45 | 43 |
46 } // namespace dart | 44 } // namespace dart |
47 | 45 |
48 #endif // RUNTIME_VM_LONGJUMP_H_ | 46 #endif // RUNTIME_VM_LONGJUMP_H_ |
OLD | NEW |