Use the alternate 32-bit base address for asan build only.
Following up
https://android-review.googlesource.com/#/c/331545/.
Bug: 34606909
Test: marlin-userdebug asan coverage build boots
Test: test-art-host
Change-Id: I3fbf64a822520992670e91cc857f7279bd288546
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 0a45fce..6d0ab75 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -29,6 +29,7 @@
#include "base/arena_allocator.h"
#include "base/dumpable.h"
#include "base/histogram-inl.h"
+#include "base/memory_tool.h"
#include "base/stl_util.h"
#include "base/systrace.h"
#include "base/time_utils.h"
@@ -286,7 +287,7 @@
if (foreground_collector_type_ == kCollectorTypeCC) {
// Need to use a low address so that we can allocate a contiguous
// 2 * Xmx space when there's no image (dex2oat for target).
-#if defined(__LP64__)
+#if defined(__LP64__) || !defined(ADDRESS_SANITIZER)
CHECK_GE(300 * MB, non_moving_space_capacity);
requested_alloc_space_begin = reinterpret_cast<uint8_t*>(300 * MB) - non_moving_space_capacity;
#else
@@ -367,7 +368,7 @@
&error_str));
CHECK(non_moving_space_mem_map != nullptr) << error_str;
// Try to reserve virtual memory at a lower address if we have a separate non moving space.
-#if defined(__LP64__)
+#if defined(__LP64__) || !defined(ADDRESS_SANITIZER)
request_begin = reinterpret_cast<uint8_t*>(300 * MB);
#else
// For 32-bit, use 0x20000000 because asan reserves 0x04000000 - 0x20000000.