v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
memory-tagging.cc
Go to the documentation of this file.
1
// Copyright 2023 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
#include "
src/heap/base/memory-tagging.h
"
6
7
#include "
src/base/cpu.h
"
8
#include "
src/base/logging.h
"
9
#include "
v8config.h
"
10
11
#define SUPPORTS_MTE V8_OS_LINUX&& V8_HOST_ARCH_ARM64
12
13
namespace
heap::base
{
14
15
SuspendTagCheckingScope::SuspendTagCheckingScope
() noexcept {
16
#if SUPPORTS_MTE
17
v8::base::CPU
cpu;
18
if
(
V8_UNLIKELY
(cpu.has_mte())) {
19
uint64_t val;
20
// Do a test to see if anything else has interfered with TCO.
21
// We expect TCO to be unset here.
22
asm
volatile
(
".arch_extension memtag \n mrs %0, tco"
:
"=r"
(val));
23
CHECK_EQ
(val, 0);
24
25
// Suspend tag checks via PSTATE.TCO.
26
asm
volatile
(
".arch_extension memtag \n msr tco, #1"
:::
"memory"
);
27
}
28
#endif
29
}
30
31
SuspendTagCheckingScope::~SuspendTagCheckingScope
() {
32
#if SUPPORTS_MTE
33
v8::base::CPU
cpu;
34
if
(
V8_UNLIKELY
(cpu.has_mte())) {
35
uint64_t val;
36
// Do a test to see if anything else has interfered with TCO.
37
// We expect TCO to be set here.
38
asm
volatile
(
".arch_extension memtag \n mrs %0, tco"
:
"=r"
(val));
39
CHECK_EQ
(val, 1u << 25);
40
41
asm
volatile
(
".arch_extension memtag \n msr tco, #0"
:::
"memory"
);
42
}
43
#endif
44
}
45
46
}
// namespace heap::base
heap::base::SuspendTagCheckingScope::~SuspendTagCheckingScope
~SuspendTagCheckingScope()
Definition
memory-tagging.cc:31
heap::base::SuspendTagCheckingScope::SuspendTagCheckingScope
SuspendTagCheckingScope() noexcept
Definition
memory-tagging.cc:15
v8::base::CPU
Definition
cpu.h:32
cpu.h
memory-tagging.h
heap::base
Definition
platform.h:72
logging.h
CHECK_EQ
#define CHECK_EQ(lhs, rhs)
v8config.h
V8_UNLIKELY
#define V8_UNLIKELY(condition)
Definition
v8config.h:660
src
heap
base
memory-tagging.cc
Generated on Sun Apr 6 2025 21:08:54 for v8 by
1.12.0