Make it possible to enable heap poisoning via make variable.

If ART_HEAP_POISONING=true, build with heap poisoning enabled.

Bug: 8367515
Change-Id: I818e86047e6dd99b5bc9920713ef943a65b677e6
diff --git a/build/Android.common_build.mk b/build/Android.common_build.mk
index 6346970..7620e76 100644
--- a/build/Android.common_build.mk
+++ b/build/Android.common_build.mk
@@ -237,6 +237,10 @@
   art_cflags += -DART_USE_OPTIMIZING_COMPILER=1
 endif
 
+ifeq ($(ART_HEAP_POISONING),true)
+  art_cflags += -DART_HEAP_POISONING=1
+endif
+
 # Cflags for non-debug ART and ART tools.
 art_non_debug_cflags := \
   -O3
diff --git a/runtime/globals.h b/runtime/globals.h
index 3104229..beabf55 100644
--- a/runtime/globals.h
+++ b/runtime/globals.h
@@ -101,7 +101,11 @@
 static constexpr bool kUseBakerOrBrooksReadBarrier = kUseBakerReadBarrier || kUseBrooksReadBarrier;
 
 // If true, references within the heap are poisoned (negated).
+#ifdef ART_HEAP_POISONING
+static constexpr bool kPoisonHeapReferences = true;
+#else
 static constexpr bool kPoisonHeapReferences = false;
+#endif
 
 // Kinds of tracing clocks.
 enum TraceClockSource {