v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
interrupts-scope.h
Go to the documentation of this file.
1// Copyright 2019 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_EXECUTION_INTERRUPTS_SCOPE_H_
6#define V8_EXECUTION_INTERRUPTS_SCOPE_H_
7
10
11namespace v8 {
12namespace internal {
13
14class Isolate;
15
16// Scope intercepts only interrupt which is part of its interrupt_mask and does
17// not affect other interrupts.
19 public:
20 enum Mode : uint8_t { kPostponeInterrupts, kRunInterrupts, kNoop };
21
22 V8_EXPORT_PRIVATE InterruptsScope(Isolate* isolate, uint32_t intercept_mask,
23 Mode mode)
24 : stack_guard_(nullptr),
25 intercept_mask_(intercept_mask),
26 intercepted_flags_(0),
27 mode_(mode) {
28 if (mode_ != kNoop) {
29 stack_guard_ = isolate->stack_guard();
30 stack_guard_->PushInterruptsScope(this);
31 }
32 }
33
35 if (mode_ != kNoop) {
36 stack_guard_->PopInterruptsScope();
37 }
38 }
39
40 // Find the scope that intercepts this interrupt.
41 // It may be outermost PostponeInterruptsScope or innermost
42 // SafeForInterruptsScope if any.
43 // Return whether the interrupt has been intercepted.
44 bool Intercept(StackGuard::InterruptFlag flag);
45
46 private:
49 const uint32_t intercept_mask_;
51 const Mode mode_;
52
53 friend class StackGuard;
54};
55
56// Support for temporarily postponing interrupts. When the outermost
57// postpone scope is left the interrupts will be re-enabled and any
58// interrupts that occurred while in the scope will be taken into
59// account.
61 public:
63 Isolate* isolate, uint32_t intercept_mask = StackGuard::ALL_INTERRUPTS)
64 : InterruptsScope(isolate, intercept_mask,
65 InterruptsScope::kPostponeInterrupts) {}
66};
67
68// Support for overriding PostponeInterruptsScope. Interrupt is not ignored if
69// innermost scope is SafeForInterruptsScope ignoring any outer
70// PostponeInterruptsScopes.
72 public:
74 Isolate* isolate, uint32_t intercept_mask = StackGuard::ALL_INTERRUPTS)
75 : InterruptsScope(isolate, intercept_mask,
76 InterruptsScope::kRunInterrupts) {}
77};
78
79} // namespace internal
80} // namespace v8
81
82#endif // V8_EXECUTION_INTERRUPTS_SCOPE_H_
V8_EXPORT_PRIVATE InterruptsScope(Isolate *isolate, uint32_t intercept_mask, Mode mode)
PostponeInterruptsScope(Isolate *isolate, uint32_t intercept_mask=StackGuard::ALL_INTERRUPTS)
SafeForInterruptsScope(Isolate *isolate, uint32_t intercept_mask=StackGuard::ALL_INTERRUPTS)
RecordWriteMode const mode_
#define V8_EXPORT_PRIVATE
Definition macros.h:460
#define V8_NODISCARD
Definition v8config.h:693