Merge "MIPS: Add asub_s/u.df"
diff --git a/compiler/optimizing/code_generator_vector_mips.cc b/compiler/optimizing/code_generator_vector_mips.cc
index 7a8c0ad..384b642 100644
--- a/compiler/optimizing/code_generator_vector_mips.cc
+++ b/compiler/optimizing/code_generator_vector_mips.cc
@@ -68,8 +68,12 @@
       break;
     case DataType::Type::kInt64:
       DCHECK_EQ(2u, instruction->GetVectorLength());
-      __ Mtc1(locations->InAt(0).AsRegisterPairLow<Register>(), FTMP);
-      __ MoveToFpuHigh(locations->InAt(0).AsRegisterPairHigh<Register>(), FTMP);
+      __ InsertW(static_cast<VectorRegister>(FTMP),
+                 locations->InAt(0).AsRegisterPairLow<Register>(),
+                 0);
+      __ InsertW(static_cast<VectorRegister>(FTMP),
+                 locations->InAt(0).AsRegisterPairHigh<Register>(),
+                 1);
       __ ReplicateFPToVectorRegister(dst, FTMP, /* is_double */ true);
       break;
     case DataType::Type::kFloat32:
@@ -124,10 +128,8 @@
       break;
     case DataType::Type::kInt64:
       DCHECK_EQ(2u, instruction->GetVectorLength());
-      __ Mfc1(locations->Out().AsRegisterPairLow<Register>(),
-              locations->InAt(0).AsFpuRegister<FRegister>());
-      __ MoveFromFpuHigh(locations->Out().AsRegisterPairHigh<Register>(),
-                         locations->InAt(0).AsFpuRegister<FRegister>());
+      __ Copy_sW(locations->Out().AsRegisterPairLow<Register>(), src, 0);
+      __ Copy_sW(locations->Out().AsRegisterPairHigh<Register>(), src, 1);
       break;
     case DataType::Type::kFloat32:
     case DataType::Type::kFloat64:
@@ -987,10 +989,8 @@
       break;
     case DataType::Type::kInt64:
       DCHECK_EQ(2u, instruction->GetVectorLength());
-      __ Mtc1(locations->InAt(0).AsRegisterPairLow<Register>(),
-              locations->Out().AsFpuRegister<FRegister>());
-      __ MoveToFpuHigh(locations->InAt(0).AsRegisterPairHigh<Register>(),
-                         locations->Out().AsFpuRegister<FRegister>());
+      __ InsertW(dst, locations->InAt(0).AsRegisterPairLow<Register>(), 0);
+      __ InsertW(dst, locations->InAt(0).AsRegisterPairHigh<Register>(), 1);
       break;
     default:
       LOG(FATAL) << "Unsupported SIMD type";
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index 32201d9..cdc55bd 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -177,6 +177,42 @@
     // Do not abort on dex pc errors. This can easily happen when we want to dump a stack trace on
     // abort.
     locking_method_ = owner_->GetCurrentMethod(&locking_dex_pc_, false);
+    if (locking_method_ != nullptr && UNLIKELY(locking_method_->IsProxyMethod())) {
+      // Grab another frame. Proxy methods are not helpful for lock profiling. This should be rare
+      // enough that it's OK to walk the stack twice.
+      struct NextMethodVisitor FINAL : public StackVisitor {
+        explicit NextMethodVisitor(Thread* thread) REQUIRES_SHARED(Locks::mutator_lock_)
+            : StackVisitor(thread,
+                           nullptr,
+                           StackVisitor::StackWalkKind::kIncludeInlinedFrames,
+                           false),
+              count_(0),
+              method_(nullptr),
+              dex_pc_(0) {}
+        bool VisitFrame() OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_) {
+          ArtMethod* m = GetMethod();
+          if (m->IsRuntimeMethod()) {
+            // Continue if this is a runtime method.
+            return true;
+          }
+          count_++;
+          if (count_ == 2u) {
+            method_ = m;
+            dex_pc_ = GetDexPc(false);
+            return false;
+          }
+          return true;
+        }
+        size_t count_;
+        ArtMethod* method_;
+        uint32_t dex_pc_;
+      };
+      NextMethodVisitor nmv(owner_);
+      nmv.WalkStack();
+      locking_method_ = nmv.method_;
+      locking_dex_pc_ = nmv.dex_pc_;
+    }
+    DCHECK(locking_method_ == nullptr || !locking_method_->IsProxyMethod());
   }
   return success;
 }
@@ -337,6 +373,8 @@
     // acquisition failures to use in sampled logging.
     if (lock_profiling_threshold_ != 0) {
       locking_method_ = self->GetCurrentMethod(&locking_dex_pc_);
+      // We don't expect a proxy method here.
+      DCHECK(locking_method_ == nullptr || !locking_method_->IsProxyMethod());
     }
   } else if (owner_ == self) {  // Recursive.
     lock_count_++;
diff --git a/test/147-stripped-dex-fallback/run b/test/147-stripped-dex-fallback/run
index e594010..37c3e1f 100755
--- a/test/147-stripped-dex-fallback/run
+++ b/test/147-stripped-dex-fallback/run
@@ -21,4 +21,4 @@
   exit 1
 fi
 
-${RUN} ${flags} --strip-dex --no-dex2oat
+${RUN} ${flags} --strip-dex --runtime-option -Xnodex2oat
diff --git a/test/165-lock-owner-proxy/expected.txt b/test/165-lock-owner-proxy/expected.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/165-lock-owner-proxy/expected.txt
diff --git a/test/165-lock-owner-proxy/info.txt b/test/165-lock-owner-proxy/info.txt
new file mode 100644
index 0000000..0964d33
--- /dev/null
+++ b/test/165-lock-owner-proxy/info.txt
@@ -0,0 +1 @@
+Regression test for b/68871592
diff --git a/test/646-checker-hadd-alt-char/build b/test/165-lock-owner-proxy/run
old mode 100755
new mode 100644
similarity index 71%
rename from test/646-checker-hadd-alt-char/build
rename to test/165-lock-owner-proxy/run
index 10ffcc5..9365411
--- a/test/646-checker-hadd-alt-char/build
+++ b/test/165-lock-owner-proxy/run
@@ -1,12 +1,12 @@
 #!/bin/bash
 #
-# Copyright 2017 The Android Open Source Project
+# Copyright (C) 2017 The Android Open Source Project
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
 #
-#      http://www.apache.org/licenses/LICENSE-2.0
+#     http://www.apache.org/licenses/LICENSE-2.0
 #
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,7 +14,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
+# Use a smaller heap so it's easier to potentially fill up.
+exec ${RUN} $@ --runtime-option -Xmx2m
diff --git a/test/165-lock-owner-proxy/src/Main.java b/test/165-lock-owner-proxy/src/Main.java
new file mode 100644
index 0000000..1b1694d
--- /dev/null
+++ b/test/165-lock-owner-proxy/src/Main.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+public class Main {
+    static final int numberOfThreads = 5;
+    static final int totalOperations = 10000;
+
+    final static Object lockObject = new Object();
+    static SimpleInterface inf;
+    static volatile boolean finish = false;
+
+    public static void main(String[] args) throws Exception {
+        inf = (SimpleInterface)Proxy.newProxyInstance(SimpleInterface.class.getClassLoader(),
+            new Class[] { SimpleInterface.class }, new EmptyInvocationHandler());
+
+        Thread garbageThread = new Thread(new GarbageRunner());
+        garbageThread.start();
+
+        final Thread[] threads = new Thread[numberOfThreads];
+        for (int t = 0; t < threads.length; t++) {
+            threads[t] = new Thread((t % 2 == 0) ? new ProxyRunner() : new SyncRunner());
+        }
+        for (Thread t : threads) {
+            t.start();
+        }
+
+        // Now wait.
+        for (Thread t : threads) {
+            t.join();
+        }
+        finish = true;
+        garbageThread.join();
+    }
+
+    private static interface SimpleInterface {
+        // Add some primitives to force some allocation when calling.
+        public void foo(int i1, int i2, int i3, int i4, int i5, int i6);
+    }
+
+    private static class EmptyInvocationHandler implements InvocationHandler {
+        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+            return null;
+        }
+    }
+
+    private static class ProxyRunner implements Runnable {
+        public void run() {
+            int count = totalOperations;
+            while (count > 0) {
+                synchronized (lockObject) {
+                    inf.foo(10000 - count, 11000 - count, 12000 - count, 13000 - count,
+                          14000 - count, 15000 - count);
+              }
+              count--;
+            }
+        }
+    }
+
+    private static class SyncRunner implements Runnable {
+        public void run() {
+            int count = totalOperations;
+            while (count > 0) {
+                synchronized (lockObject) {
+                    // "Wait" a small amount of time.
+                    long start = System.nanoTime();
+                    long delta = 10 * 1000;  // 10 us.
+                    long elapsed;
+                    do {
+                      elapsed = System.nanoTime();
+                    } while (elapsed - start < delta);
+                }
+                count--;
+            }
+        }
+    }
+
+    private static class GarbageRunner implements Runnable {
+        public void run() {
+            while (!finish) {
+                // Some random allocations adding up to almost 2M.
+                for (int i = 0; i < 188; i++) {
+                    byte b[] = new byte[i * 100 + 10];
+                }
+                try {
+                    Thread.sleep(10);
+                } catch (Exception e) {
+                }
+            }
+        }
+    }
+}
diff --git a/test/646-checker-hadd-alt-short/build b/test/646-checker-hadd-alt-short/build
deleted file mode 100755
index 10ffcc5..0000000
--- a/test/646-checker-hadd-alt-short/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/646-checker-hadd-char/build b/test/646-checker-hadd-char/build
deleted file mode 100755
index 10ffcc5..0000000
--- a/test/646-checker-hadd-char/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/646-checker-hadd-short/build b/test/646-checker-hadd-short/build
deleted file mode 100755
index 10ffcc5..0000000
--- a/test/646-checker-hadd-short/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/651-checker-short-simd-minmax/build b/test/651-checker-short-simd-minmax/build
deleted file mode 100755
index 10ffcc5..0000000
--- a/test/651-checker-short-simd-minmax/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/660-checker-simd-sad-short2/build b/test/660-checker-simd-sad-short2/build
deleted file mode 100755
index 10ffcc5..0000000
--- a/test/660-checker-simd-sad-short2/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index bf964a6..753fc39 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -169,6 +169,7 @@
     elif [ "x$1" = "x--no-dex2oat" ]; then
         DEX2OAT="-Xcompiler:${FALSE_BIN}"
         USE_DEX2OAT_AND_PATCHOAT="n"
+        PREBUILD="n" # Do not use prebuilt odex, either.
         shift
     elif [ "x$1" = "x--no-patchoat" ]; then
         PATCHOAT="-Xpatchoat:${FALSE_BIN}"
diff --git a/test/testrunner/env.py b/test/testrunner/env.py
index 92cc977..5556962 100644
--- a/test/testrunner/env.py
+++ b/test/testrunner/env.py
@@ -35,7 +35,7 @@
                         'HOST_OUT_EXECUTABLES',
                         'ANDROID_JAVA_TOOLCHAIN',
                         'ANDROID_COMPILE_WITH_JACK',
-                        'USE_D8']
+                        'USE_D8_BY_DEFAULT']
 _DUMP_MANY_VARS = None  # To be set to a dictionary with above list being the keys,
                         # and the build variable being the value.
 def _dump_many_vars(var_name):
@@ -109,7 +109,7 @@
 ANDROID_COMPILE_WITH_JACK = _get_build_var_boolean('ANDROID_COMPILE_WITH_JACK', 'default')
 
 # Follow the build system's D8 usage.
-USE_D8 = _get_build_var_boolean('USE_D8', False)
+USE_D8_BY_DEFAULT = _get_build_var_boolean('USE_D8_BY_DEFAULT', False)
 
 # Directory used for temporary test files on the host.
 ART_HOST_TEST_DIR = tempfile.mkdtemp(prefix = 'test-art-')
diff --git a/test/testrunner/testrunner.py b/test/testrunner/testrunner.py
index 20a0cd9..e750382 100755
--- a/test/testrunner/testrunner.py
+++ b/test/testrunner/testrunner.py
@@ -460,7 +460,7 @@
       elif env.ANDROID_COMPILE_WITH_JACK == False:
         options_test += ' --build-with-javac-dx'
 
-      if env.USE_D8 == True:
+      if env.USE_D8_BY_DEFAULT == True:
         options_test += ' --build-with-d8'
 
       # TODO(http://36039166): This is a temporary solution to
diff --git a/tools/libcore_failures.txt b/tools/libcore_failures.txt
index ea26b0e..23a70f7 100644
--- a/tools/libcore_failures.txt
+++ b/tools/libcore_failures.txt
@@ -211,15 +211,15 @@
           "libcore.java.lang.ProcessBuilderTest#testRedirect_nullStreams"]
 },
 {
-  description: "Repeated annotations do not work in javac (OpenJDK8), fixed in OpenJDK9.
-                Blacklisted to support javac/dx build (b/36902714)",
-  result: EXEC_FAILED,
-  bug: 62408076,
-  names: ["libcore.java.lang.reflect.annotations.AnnotatedElementParameterTest#testImplicitConstructorParameters_singleAnnotation"]
-},
-{
   description: "java.io.IOException: Error writing ASN.1 encoding",
   result: EXEC_FAILED,
   names: ["libcore.javax.crypto.spec.AlgorithmParametersTestGCM#testEncoding"]
+},
+{
+  description: "Failure only on device. Blacklist it temporarily",
+  result: EXEC_FAILED,
+  modes: [device],
+  bug: 69023954,
+  names: ["libcore.io.OsTest#test_setgroups"]
 }
 ]