v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
msan.h
Go to the documentation of this file.
1// Copyright 2013 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_BASE_SANITIZER_MSAN_H_
6#define V8_BASE_SANITIZER_MSAN_H_
7
8// MemorySanitizer support.
9
10#include "src/base/macros.h"
11#include "src/base/memory.h"
12
13#ifdef V8_USE_MEMORY_SANITIZER
14
15#include <sanitizer/msan_interface.h>
16
17// Marks a memory range as uninitialized, as if it was allocated here.
18#define MSAN_ALLOCATED_UNINITIALIZED_MEMORY(start, size) \
19 __msan_allocated_memory(reinterpret_cast<const void*>(start), (size))
20
21// Marks a memory range as initialized.
22#define MSAN_MEMORY_IS_INITIALIZED(start, size) \
23 __msan_unpoison(reinterpret_cast<const void*>(start), (size))
24
25#define DISABLE_MSAN __attribute__((no_sanitize("memory")))
26
27#else // !V8_USE_MEMORY_SANITIZER
28
29#define MSAN_ALLOCATED_UNINITIALIZED_MEMORY(start, size) \
30 static_assert((std::is_pointer_v<decltype(start)> || \
31 std::is_same_v<v8::base::Address, decltype(start)>), \
32 "static type violation"); \
33 static_assert(std::is_convertible_v<decltype(size), size_t>, \
34 "static type violation"); \
35 USE(start, size)
36
37#define MSAN_MEMORY_IS_INITIALIZED(start, size) \
38 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(start, size)
39
40#define DISABLE_MSAN
41
42#endif // V8_USE_MEMORY_SANITIZER
43
44#endif // V8_BASE_SANITIZER_MSAN_H_