Merge "Fix 32-bit device tests"
diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc
index e534369..247cb96 100644
--- a/runtime/gc/collector/concurrent_copying.cc
+++ b/runtime/gc/collector/concurrent_copying.cc
@@ -2043,13 +2043,23 @@
   }
   DCHECK(to_ref != nullptr);
 
+  // Copy the object excluding the lock word since that is handled in the loop.
+  to_ref->SetClass(from_ref->GetClass<kVerifyNone, kWithoutReadBarrier>());
+  const size_t kObjectHeaderSize = sizeof(mirror::Object);
+  DCHECK_GE(obj_size, kObjectHeaderSize);
+  static_assert(kObjectHeaderSize == sizeof(mirror::HeapReference<mirror::Class>) +
+                    sizeof(LockWord),
+                "Object header size does not match");
+  // Memcpy can tear for words since it may do byte copy. It is only safe to do this since the
+  // object in the from space is immutable other than the lock word. b/31423258
+  memcpy(reinterpret_cast<uint8_t*>(to_ref) + kObjectHeaderSize,
+         reinterpret_cast<const uint8_t*>(from_ref) + kObjectHeaderSize,
+         obj_size - kObjectHeaderSize);
+
   // Attempt to install the forward pointer. This is in a loop as the
   // lock word atomic write can fail.
   while (true) {
-    // Copy the object. TODO: copy only the lockword in the second iteration and on?
-    memcpy(to_ref, from_ref, obj_size);
-
-    LockWord old_lock_word = to_ref->GetLockWord(false);
+    LockWord old_lock_word = from_ref->GetLockWord(false);
 
     if (old_lock_word.GetState() == LockWord::kForwardingAddress) {
       // Lost the race. Another thread (either GC or mutator) stored
@@ -2093,6 +2103,8 @@
       return to_ref;
     }
 
+    // Copy the old lock word over since we did not copy it yet.
+    to_ref->SetLockWord(old_lock_word, false);
     // Set the gray ptr.
     if (kUseBakerReadBarrier) {
       to_ref->SetReadBarrierPointer(ReadBarrier::GrayPtr());
diff --git a/test/Android.bp b/test/Android.bp
index 5803b84..54c85eb 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -69,6 +69,9 @@
                 "-Wno-missing-noreturn",
             ],
         },
+        darwin: {
+            enabled: false,
+        },
         android: {
             ldflags: [
                 // Allow jni_compiler_test to find Java_MyClassNatives_bar
@@ -148,6 +151,9 @@
                 "-Wno-missing-noreturn",
             ],
         },
+        darwin: {
+            enabled: false,
+        },
     },
 }
 
@@ -175,5 +181,8 @@
                 "-lpthread",
             ],
         },
+        darwin: {
+            enabled: false,
+        },
     },
 }
diff --git a/tools/javafuzz/README.md b/tools/javafuzz/README.md
index 68fc171..b08075a 100644
--- a/tools/javafuzz/README.md
+++ b/tools/javafuzz/README.md
@@ -39,9 +39,10 @@
 How to start the JavaFuzz tests
 ===============================
 
-    run_java_fuzz_test.py [--num_tests]
-                          [--device]
-                          [--mode1=mode] [--mode2=mode]
+    run_java_fuzz_test.py
+                          [--num_tests=#TESTS]
+                          [--device=DEVICE]
+                          [--mode1=MODE] [--mode2=MODE]
 
 where
 
diff --git a/tools/javafuzz/run_java_fuzz_test.py b/tools/javafuzz/run_java_fuzz_test.py
index 085471f..51d00be 100755
--- a/tools/javafuzz/run_java_fuzz_test.py
+++ b/tools/javafuzz/run_java_fuzz_test.py
@@ -28,8 +28,8 @@
 
 from tempfile import mkdtemp
 
-
-sys.path.append(os.path.dirname(os.path.dirname(__file__)))
+sys.path.append(os.path.dirname(os.path.dirname(
+    os.path.realpath(__file__))))
 
 from bisection_search.common import RetCode
 from bisection_search.common import CommandListToCommandString
@@ -396,7 +396,7 @@
     print('Directory :', self._results_dir)
     print('Exec-mode1:', self._runner1.description)
     print('Exec-mode2:', self._runner2.description)
-    print
+    print()
     self.ShowStats()
     for self._test in range(1, self._num_tests + 1):
       self.RunJavaFuzzTest()