Commit 8ae6bc60 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[asan] Move asan macros to asan.h

Similar to msan.h, asan should get its own header file such that the
functionality can be reused.

R=ahaas@chromium.org

Bug: v8:7570
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: Ib81e4ff4b1d08158df7730c32345d4facf9453b0
Reviewed-on: https://chromium-review.googlesource.com/1046656Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53073}
parent 8aee0141
......@@ -1452,6 +1452,7 @@ v8_source_set("v8_base") {
"src/api.h",
"src/arguments.cc",
"src/arguments.h",
"src/asan.h",
"src/asmjs/asm-js.cc",
"src/asmjs/asm-js.h",
"src/asmjs/asm-names.h",
......
......@@ -5,10 +5,7 @@
#include "src/api.h"
#include <string.h> // For memcpy, strlen.
#ifdef V8_USE_ADDRESS_SANITIZER
#include <sanitizer/asan_interface.h>
#endif // V8_USE_ADDRESS_SANITIZER
#include <cmath> // For isnan.
#include <cmath> // For isnan.
#include <limits>
#include <vector>
#include "include/v8-profiler.h"
......
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// AddressSanitizer support.
#ifndef V8_ASAN_H_
#define V8_ASAN_H_
#include "src/base/macros.h"
#include "src/globals.h"
#ifdef V8_USE_ADDRESS_SANITIZER
#include <sanitizer/asan_interface.h>
#else // !V8_USE_ADDRESS_SANITIZER
#define ASAN_POISON_MEMORY_REGION(start, size) \
static_assert( \
(std::is_pointer<decltype(start)>::value || \
std::is_same<v8::internal::Address, decltype(start)>::value) && \
std::is_convertible<decltype(size), size_t>::value, \
"static type violation")
#define ASAN_UNPOISON_MEMORY_REGION(start, size) \
ASAN_POISON_MEMORY_REGION(start, size)
#endif // V8_USE_ADDRESS_SANITIZER
#endif // V8_ASAN_H_
......@@ -6,37 +6,22 @@
#include <cstring>
#include "src/asan.h"
#include "src/utils.h"
#include "src/v8.h"
#ifdef V8_USE_ADDRESS_SANITIZER
#include <sanitizer/asan_interface.h>
#endif // V8_USE_ADDRESS_SANITIZER
namespace v8 {
namespace internal {
namespace {
#if V8_USE_ADDRESS_SANITIZER
const size_t kASanRedzoneBytes = 24; // Must be a multiple of 8.
#else
#ifdef V8_USE_ADDRESS_SANITIZER
#define ASAN_POISON_MEMORY_REGION(start, size) \
do { \
USE(start); \
USE(size); \
} while (false)
constexpr size_t kASanRedzoneBytes = 24; // Must be a multiple of 8.
#define ASAN_UNPOISON_MEMORY_REGION(start, size) \
do { \
USE(start); \
USE(size); \
} while (false)
#else // !V8_USE_ADDRESS_SANITIZER
const size_t kASanRedzoneBytes = 0;
constexpr size_t kASanRedzoneBytes = 0;
#endif // V8_USE_ADDRESS_SANITIZER
......@@ -82,7 +67,7 @@ void* Zone::New(size_t size) {
}
Address redzone_position = result + size;
DCHECK(redzone_position + kASanRedzoneBytes == position_);
DCHECK_EQ(redzone_position + kASanRedzoneBytes, position_);
ASAN_POISON_MEMORY_REGION(reinterpret_cast<void*>(redzone_position),
kASanRedzoneBytes);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment