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 | // MemorySanitizer support. |
6 | |
7 | #ifndef V8_MSAN_H_ |
8 | #define V8_MSAN_H_ |
9 | |
10 | #include "src/base/macros.h" |
11 | #include "src/globals.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(p, s) \ |
19 | __msan_allocated_memory(reinterpret_cast<const void*>(p), (s)) |
20 | // Marks a memory range as initialized. |
21 | #define MSAN_MEMORY_IS_INITIALIZED(p, s) \ |
22 | __msan_unpoison(reinterpret_cast<const void*>(p), (s)) |
23 | |
24 | #else // !V8_USE_MEMORY_SANITIZER |
25 | |
26 | #define MSAN_ALLOCATED_UNINITIALIZED_MEMORY(p, s) \ |
27 | static_assert((std::is_pointer<decltype(p)>::value || \ |
28 | std::is_same<v8::internal::Address, decltype(p)>::value) && \ |
29 | std::is_convertible<decltype(s), size_t>::value, \ |
30 | "static type violation") |
31 | #define MSAN_MEMORY_IS_INITIALIZED(p, s) \ |
32 | MSAN_ALLOCATED_UNINITIALIZED_MEMORY(p, s) |
33 | |
34 | #endif // V8_USE_MEMORY_SANITIZER |
35 | |
36 | #endif // V8_MSAN_H_ |
37 | |