Use art::Atomic for CopyObject

Just to be sure it doesn't get turned into memcpy.

Also avoid casting ObjectArray to IntArray. This is a strict aliasing
violation.

Bug: 32012820

Test: test-art-host

Change-Id: Icc5d4a758cb4f4e1686389bb0cb74ac08e554f04
diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc
index 8e49743..9d3c26e 100644
--- a/runtime/mirror/object.cc
+++ b/runtime/mirror/object.cc
@@ -86,14 +86,16 @@
     DCHECK_ALIGNED(dst_bytes, sizeof(uintptr_t));
     // Use word sized copies to begin.
     while (num_bytes >= sizeof(uintptr_t)) {
-      *reinterpret_cast<uintptr_t*>(dst_bytes) = *reinterpret_cast<uintptr_t*>(src_bytes);
+      reinterpret_cast<Atomic<uintptr_t>*>(dst_bytes)->StoreRelaxed(
+          reinterpret_cast<Atomic<uintptr_t>*>(src_bytes)->LoadRelaxed());
       src_bytes += sizeof(uintptr_t);
       dst_bytes += sizeof(uintptr_t);
       num_bytes -= sizeof(uintptr_t);
     }
     // Copy possible 32 bit word.
     if (sizeof(uintptr_t) != sizeof(uint32_t) && num_bytes >= sizeof(uint32_t)) {
-      *reinterpret_cast<uint32_t*>(dst_bytes) = *reinterpret_cast<uint32_t*>(src_bytes);
+      reinterpret_cast<Atomic<uint32_t>*>(dst_bytes)->StoreRelaxed(
+          reinterpret_cast<Atomic<uint32_t>*>(src_bytes)->LoadRelaxed());
       src_bytes += sizeof(uint32_t);
       dst_bytes += sizeof(uint32_t);
       num_bytes -= sizeof(uint32_t);
@@ -101,7 +103,8 @@
     // Copy remaining bytes, avoid going past the end of num_bytes since there may be a redzone
     // there.
     while (num_bytes > 0) {
-      *reinterpret_cast<uint8_t*>(dst_bytes) = *reinterpret_cast<uint8_t*>(src_bytes);
+      reinterpret_cast<Atomic<uint8_t>*>(dst_bytes)->StoreRelaxed(
+          reinterpret_cast<Atomic<uint8_t>*>(src_bytes)->LoadRelaxed());
       src_bytes += sizeof(uint8_t);
       dst_bytes += sizeof(uint8_t);
       num_bytes -= sizeof(uint8_t);