msan.h 1.2 KB
Newer Older
1
// Copyright 2013 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4 5 6 7 8 9

// MemorySanitizer support.

#ifndef V8_MSAN_H_
#define V8_MSAN_H_

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 19
#define MSAN_ALLOCATED_UNINITIALIZED_MEMORY(p, s) \
  __msan_allocated_memory(reinterpret_cast<const void*>(p), (s))
20
// Marks a memory range as initialized.
21 22
#define MSAN_MEMORY_IS_INITIALIZED(p, s) \
  __msan_unpoison(reinterpret_cast<const void*>(p), (s))
23 24 25 26 27 28 29 30 31 32 33 34

#else  // !V8_USE_MEMORY_SANITIZER

#define MSAN_ALLOCATED_UNINITIALIZED_MEMORY(p, s)                            \
  static_assert((std::is_pointer<decltype(p)>::value ||                      \
                 std::is_same<v8::internal::Address, decltype(p)>::value) && \
                    std::is_convertible<decltype(s), size_t>::value,         \
                "static type violation")
#define MSAN_MEMORY_IS_INITIALIZED(p, s) \
  MSAN_ALLOCATED_UNINITIALIZED_MEMORY(p, s)

#endif  // V8_USE_MEMORY_SANITIZER
35

36
#endif  // V8_MSAN_H_