1// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
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.
4
5#ifndef RUNTIME_VM_LONGJUMP_H_
6#define RUNTIME_VM_LONGJUMP_H_
7
8#include <setjmp.h>
9
10#include "vm/allocation.h"
11#include "vm/thread_state.h"
12
13namespace dart {
14
15class Error;
16
17class LongJumpScope : public StackResource {
18 public:
19 LongJumpScope()
20 : StackResource(ThreadState::Current()),
21 top_(nullptr),
22 base_(thread()->long_jump_base()) {
23 thread()->set_long_jump_base(this);
24 }
25
26 ~LongJumpScope() {
27 ASSERT(thread() == ThreadState::Current());
28 thread()->set_long_jump_base(base_);
29 }
30
31 jmp_buf* Set();
32 DART_NORETURN void Jump(int value, const Error& error);
33
34 private:
35 jmp_buf environment_;
36 StackResource* top_;
37 LongJumpScope* base_;
38
39 DISALLOW_COPY_AND_ASSIGN(LongJumpScope);
40};
41
42} // namespace dart
43
44#endif // RUNTIME_VM_LONGJUMP_H_
45