v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
trap-handler-internal.h
Go to the documentation of this file.
1
// Copyright 2016 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_TRAP_HANDLER_TRAP_HANDLER_INTERNAL_H_
6
#define V8_TRAP_HANDLER_TRAP_HANDLER_INTERNAL_H_
7
8
// This file should not be included (even transitively) by files outside of
9
// src/trap-handler.
10
11
#include "
src/trap-handler/trap-handler.h
"
12
13
#include <atomic>
14
15
namespace
v8
{
16
namespace
internal
{
17
namespace
trap_handler {
18
19
// This describes a chunk of code that the trap handler will be able to handle
20
// faults in. {base} points to the beginning of the chunk, and {size} is the
21
// number of bytes in the code chunk. The remainder of the struct is a list of
22
// protected memory access instructions and an offset to a landing pad to handle
23
// faults on that instruction.
24
struct
CodeProtectionInfo
{
25
uintptr_t
base
;
26
size_t
size
;
27
size_t
num_protected_instructions
;
28
ProtectedInstructionData
instructions[1];
29
};
30
31
class
MetadataLock
{
32
static
std::atomic_flag
spinlock_
;
33
34
public
:
35
MetadataLock
();
36
~MetadataLock
();
37
38
MetadataLock
(
const
MetadataLock
&) =
delete
;
39
void
operator=
(
const
MetadataLock
&) =
delete
;
40
};
41
42
// To enable constant time registration of handler data, we keep a free list of
43
// entries in the gCodeObjects table. Each entry contains a {next_free} field,
44
// which can be used to figure out where the next entry should be inserted.
45
// In order to avoid having to initialize all the links to start with, we use
46
// 0 to indicate that this is a fresh, never-used list entry and that therefore
47
// the next entry is known to be free. If {next_entry} is greater than zero,
48
// then {next_entry - 1} is the index that we should insert into next.
49
struct
CodeProtectionInfoListEntry
{
50
CodeProtectionInfo
*
code_info
;
51
size_t
next_free
;
52
};
53
54
extern
size_t
gNumCodeObjects
;
55
extern
CodeProtectionInfoListEntry
*
gCodeObjects
;
56
57
// This list describes sandboxes as bases and sizes.
58
struct
SandboxRecord
{
59
uintptr_t
base
;
60
size_t
size
;
61
SandboxRecord
*
next
;
62
};
63
64
class
SandboxRecordsLock
{
65
static
std::atomic_flag
spinlock_
;
66
67
public
:
68
SandboxRecordsLock
();
69
~SandboxRecordsLock
();
70
71
SandboxRecordsLock
(
const
SandboxRecordsLock
&) =
delete
;
72
void
operator=
(
const
SandboxRecordsLock
&) =
delete
;
73
};
74
75
extern
SandboxRecord
*
gSandboxRecordsHead
;
76
77
extern
std::atomic_size_t
gRecoveredTrapCount
;
78
79
extern
std::atomic<uintptr_t>
gLandingPad
;
80
81
// Searches the fault location table for an entry matching fault_addr. If found,
82
// returns true, otherwise, returns false.
83
bool
IsFaultAddressCovered
(uintptr_t fault_addr);
84
85
// Checks whether the accessed memory is covered by the trap handler. In
86
// particular, when the V8 sandbox is enabled, only faulting accesses to memory
87
// inside the sandbox are handled by the trap handler since all Wasm memory
88
// objects are inside the sandbox.
89
bool
IsAccessedMemoryCovered
(uintptr_t accessed_addr);
90
91
}
// namespace trap_handler
92
}
// namespace internal
93
}
// namespace v8
94
95
#endif
// V8_TRAP_HANDLER_TRAP_HANDLER_INTERNAL_H_
v8::internal::trap_handler::MetadataLock
Definition
trap-handler-internal.h:31
v8::internal::trap_handler::MetadataLock::MetadataLock
MetadataLock()
Definition
handler-shared.cc:50
v8::internal::trap_handler::MetadataLock::spinlock_
static std::atomic_flag spinlock_
Definition
trap-handler-internal.h:32
v8::internal::trap_handler::MetadataLock::MetadataLock
MetadataLock(const MetadataLock &)=delete
v8::internal::trap_handler::MetadataLock::operator=
void operator=(const MetadataLock &)=delete
v8::internal::trap_handler::MetadataLock::~MetadataLock
~MetadataLock()
Definition
handler-shared.cc:59
v8::internal::trap_handler::SandboxRecordsLock
Definition
trap-handler-internal.h:64
v8::internal::trap_handler::SandboxRecordsLock::operator=
void operator=(const SandboxRecordsLock &)=delete
v8::internal::trap_handler::SandboxRecordsLock::~SandboxRecordsLock
~SandboxRecordsLock()
Definition
handler-shared.cc:72
v8::internal::trap_handler::SandboxRecordsLock::SandboxRecordsLock
SandboxRecordsLock(const SandboxRecordsLock &)=delete
v8::internal::trap_handler::SandboxRecordsLock::spinlock_
static std::atomic_flag spinlock_
Definition
trap-handler-internal.h:65
v8::internal::trap_handler::SandboxRecordsLock::SandboxRecordsLock
SandboxRecordsLock()
Definition
handler-shared.cc:67
v8::internal::trap_handler::gSandboxRecordsHead
SandboxRecord * gSandboxRecordsHead
Definition
handler-shared.cc:37
v8::internal::trap_handler::IsFaultAddressCovered
bool IsFaultAddressCovered(uintptr_t fault_addr)
v8::internal::trap_handler::gCodeObjects
CodeProtectionInfoListEntry * gCodeObjects
Definition
handler-shared.cc:36
v8::internal::trap_handler::gLandingPad
std::atomic< uintptr_t > gLandingPad
Definition
handler-shared.cc:39
v8::internal::trap_handler::gRecoveredTrapCount
std::atomic_size_t gRecoveredTrapCount
Definition
handler-shared.cc:38
v8::internal::trap_handler::gNumCodeObjects
size_t gNumCodeObjects
Definition
handler-shared.cc:35
v8::internal::trap_handler::IsAccessedMemoryCovered
bool IsAccessedMemoryCovered(uintptr_t accessed_addr)
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
v8::internal::trap_handler::CodeProtectionInfoListEntry
Definition
trap-handler-internal.h:49
v8::internal::trap_handler::CodeProtectionInfoListEntry::code_info
CodeProtectionInfo * code_info
Definition
trap-handler-internal.h:50
v8::internal::trap_handler::CodeProtectionInfoListEntry::next_free
size_t next_free
Definition
trap-handler-internal.h:51
v8::internal::trap_handler::CodeProtectionInfo
Definition
trap-handler-internal.h:24
v8::internal::trap_handler::CodeProtectionInfo::size
size_t size
Definition
trap-handler-internal.h:26
v8::internal::trap_handler::CodeProtectionInfo::num_protected_instructions
size_t num_protected_instructions
Definition
trap-handler-internal.h:27
v8::internal::trap_handler::CodeProtectionInfo::base
uintptr_t base
Definition
trap-handler-internal.h:25
v8::internal::trap_handler::ProtectedInstructionData
Definition
trap-handler.h:105
v8::internal::trap_handler::SandboxRecord
Definition
trap-handler-internal.h:58
v8::internal::trap_handler::SandboxRecord::next
SandboxRecord * next
Definition
trap-handler-internal.h:61
v8::internal::trap_handler::SandboxRecord::base
uintptr_t base
Definition
trap-handler-internal.h:59
v8::internal::trap_handler::SandboxRecord::size
size_t size
Definition
trap-handler-internal.h:60
trap-handler.h
src
trap-handler
trap-handler-internal.h
Generated on Sun Apr 6 2025 21:08:57 for v8 by
1.12.0