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
8
#include "
src/execution/isolate.h
"
9
#include "
src/execution/stack-guard.h
"
10
11
namespace
v8
{
12
namespace
internal
{
13
14
class
Isolate;
15
16
// Scope intercepts only interrupt which is part of its interrupt_mask and does
17
// not affect other interrupts.
18
class
V8_NODISCARD
InterruptsScope
{
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
34
~InterruptsScope
() {
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
:
47
StackGuard
*
stack_guard_
;
48
InterruptsScope
*
prev_
;
49
const
uint32_t
intercept_mask_
;
50
uint32_t
intercepted_flags_
;
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.
60
class
V8_NODISCARD
PostponeInterruptsScope
:
public
InterruptsScope
{
61
public
:
62
explicit
PostponeInterruptsScope
(
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.
71
class
V8_NODISCARD
SafeForInterruptsScope
:
public
InterruptsScope
{
72
public
:
73
explicit
SafeForInterruptsScope
(
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::internal::InterruptsScope
Definition
interrupts-scope.h:18
v8::internal::InterruptsScope::~InterruptsScope
~InterruptsScope()
Definition
interrupts-scope.h:34
v8::internal::InterruptsScope::intercept_mask_
const uint32_t intercept_mask_
Definition
interrupts-scope.h:49
v8::internal::InterruptsScope::Mode
Mode
Definition
interrupts-scope.h:20
v8::internal::InterruptsScope::InterruptsScope
V8_EXPORT_PRIVATE InterruptsScope(Isolate *isolate, uint32_t intercept_mask, Mode mode)
Definition
interrupts-scope.h:22
v8::internal::InterruptsScope::prev_
InterruptsScope * prev_
Definition
interrupts-scope.h:48
v8::internal::InterruptsScope::stack_guard_
StackGuard * stack_guard_
Definition
interrupts-scope.h:47
v8::internal::InterruptsScope::mode_
const Mode mode_
Definition
interrupts-scope.h:51
v8::internal::InterruptsScope::intercepted_flags_
uint32_t intercepted_flags_
Definition
interrupts-scope.h:50
v8::internal::Isolate
Definition
isolate.h:586
v8::internal::PostponeInterruptsScope
Definition
interrupts-scope.h:60
v8::internal::PostponeInterruptsScope::PostponeInterruptsScope
PostponeInterruptsScope(Isolate *isolate, uint32_t intercept_mask=StackGuard::ALL_INTERRUPTS)
Definition
interrupts-scope.h:62
v8::internal::SafeForInterruptsScope
Definition
interrupts-scope.h:71
v8::internal::SafeForInterruptsScope::SafeForInterruptsScope
SafeForInterruptsScope(Isolate *isolate, uint32_t intercept_mask=StackGuard::ALL_INTERRUPTS)
Definition
interrupts-scope.h:73
v8::internal::StackGuard
Definition
stack-guard.h:24
v8::internal::StackGuard::InterruptFlag
InterruptFlag
Definition
stack-guard.h:92
mode_
RecordWriteMode const mode_
Definition
code-generator-arm.cc:224
isolate.h
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
V8_EXPORT_PRIVATE
#define V8_EXPORT_PRIVATE
Definition
macros.h:460
stack-guard.h
V8_NODISCARD
#define V8_NODISCARD
Definition
v8config.h:693
src
execution
interrupts-scope.h
Generated on Sun Apr 6 2025 21:08:53 for v8 by
1.12.0