Merge "Fix a few comments in vectorization code that were incorrect or incomplete."
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index f27db0e..ed34a8d 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -170,12 +170,6 @@
 # TODO: document why this is needed.
 ART_GTEST_proxy_test_HOST_DEPS := $(HOST_CORE_IMAGE_DEFAULT_64) $(HOST_CORE_IMAGE_DEFAULT_32)
 
-# The dexdiag test requires the dexdiag utility.
-ART_GTEST_dexdiag_test_HOST_DEPS := \
-  $(HOST_OUT_EXECUTABLES)/dexdiag
-ART_GTEST_dexdiag_test_TARGET_DEPS := \
-  dexdiag
-
 # The dexdump test requires an image and the dexdump utility.
 # TODO: rename into dexdump when migration completes
 ART_GTEST_dexdump_test_HOST_DEPS := \
@@ -247,7 +241,6 @@
     art_compiler_tests \
     art_compiler_host_tests \
     art_dex2oat_tests \
-    art_dexdiag_tests \
     art_dexdump_tests \
     art_dexlayout_tests \
     art_dexlist_tests \
diff --git a/compiler/common_compiler_test.h b/compiler/common_compiler_test.h
index 98dcf20..0683577 100644
--- a/compiler/common_compiler_test.h
+++ b/compiler/common_compiler_test.h
@@ -117,25 +117,6 @@
   std::list<std::vector<uint8_t>> header_code_and_maps_chunks_;
 };
 
-// TODO: When read barrier works with all Optimizing back ends, get rid of this.
-#define TEST_DISABLED_FOR_READ_BARRIER_WITH_OPTIMIZING_FOR_UNSUPPORTED_INSTRUCTION_SETS() \
-  if (kUseReadBarrier && GetCompilerKind() == Compiler::kOptimizing) {                    \
-    switch (GetInstructionSet()) {                                                        \
-      case kArm64:                                                                        \
-      case kThumb2:                                                                       \
-      case kX86:                                                                          \
-      case kX86_64:                                                                       \
-        /* Instruction set has read barrier support. */                                   \
-        break;                                                                            \
-                                                                                          \
-      default:                                                                            \
-        /* Instruction set does not have barrier support. */                              \
-        printf("WARNING: TEST DISABLED FOR READ BARRIER WITH OPTIMIZING "                 \
-               "FOR THIS INSTRUCTION SET\n");                                             \
-        return;                                                                           \
-    }                                                                                     \
-  }
-
 }  // namespace art
 
 #endif  // ART_COMPILER_COMMON_COMPILER_TEST_H_
diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc
index 35aa1ee..fa1b3a3 100644
--- a/compiler/driver/compiler_driver_test.cc
+++ b/compiler/driver/compiler_driver_test.cc
@@ -148,7 +148,6 @@
 }
 
 TEST_F(CompilerDriverTest, AbstractMethodErrorStub) {
-  TEST_DISABLED_FOR_READ_BARRIER_WITH_OPTIMIZING_FOR_UNSUPPORTED_INSTRUCTION_SETS();
   jobject class_loader;
   {
     ScopedObjectAccess soa(Thread::Current());
@@ -191,7 +190,6 @@
 };
 
 TEST_F(CompilerDriverMethodsTest, Selection) {
-  TEST_DISABLED_FOR_READ_BARRIER_WITH_OPTIMIZING_FOR_UNSUPPORTED_INSTRUCTION_SETS();
   Thread* self = Thread::Current();
   jobject class_loader;
   {
@@ -299,7 +297,6 @@
 };
 
 TEST_F(CompilerDriverProfileTest, ProfileGuidedCompilation) {
-  TEST_DISABLED_FOR_READ_BARRIER_WITH_OPTIMIZING_FOR_UNSUPPORTED_INSTRUCTION_SETS();
   Thread* self = Thread::Current();
   jobject class_loader;
   {
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index 79cd704..298ae5c 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -371,6 +371,12 @@
     // invoke-virtual because a proxy method doesn't have a real dex file.
     return nullptr;
   }
+  if (!single_impl->GetDeclaringClass()->IsResolved()) {
+    // There's a race with the class loading, which updates the CHA info
+    // before setting the class to resolved. So we just bail for this
+    // rare occurence.
+    return nullptr;
+  }
   return single_impl;
 }
 
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index eb88fde..e542cbb 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -449,17 +449,6 @@
       || instruction_set == kX86_64;
 }
 
-// Read barrier are supported on ARM, ARM64, x86 and x86-64 at the moment.
-// TODO: Add support for other architectures and remove this function
-static bool InstructionSetSupportsReadBarrier(InstructionSet instruction_set) {
-  return instruction_set == kArm64
-      || instruction_set == kThumb2
-      || instruction_set == kMips
-      || instruction_set == kMips64
-      || instruction_set == kX86
-      || instruction_set == kX86_64;
-}
-
 // Strip pass name suffix to get optimization name.
 static std::string ConvertPassNameToOptimizationName(const std::string& pass_name) {
   size_t pos = pass_name.find(kPassNameSeparator);
@@ -914,12 +903,6 @@
     return nullptr;
   }
 
-  // When read barriers are enabled, do not attempt to compile for
-  // instruction sets that have no read barrier support.
-  if (kEmitCompilerReadBarrier && !InstructionSetSupportsReadBarrier(instruction_set)) {
-    return nullptr;
-  }
-
   if (Compiler::IsPathologicalCase(*code_item, method_idx, dex_file)) {
     MaybeRecordStat(MethodCompilationStat::kNotCompiledPathological);
     return nullptr;
@@ -1110,13 +1093,10 @@
 
   if (kIsDebugBuild &&
       IsCompilingWithCoreImage() &&
-      IsInstructionSetSupported(compiler_driver->GetInstructionSet()) &&
-      (!kEmitCompilerReadBarrier ||
-       InstructionSetSupportsReadBarrier(compiler_driver->GetInstructionSet()))) {
+      IsInstructionSetSupported(compiler_driver->GetInstructionSet())) {
     // For testing purposes, we put a special marker on method names
-    // that should be compiled with this compiler (when the the
-    // instruction set is supported -- and has support for read
-    // barriers, if they are enabled). This makes sure we're not
+    // that should be compiled with this compiler (when the
+    // instruction set is supported). This makes sure we're not
     // regressing.
     std::string method_name = dex_file.PrettyMethod(method_idx);
     bool shouldCompile = method_name.find("$opt$") != std::string::npos;
diff --git a/dexlayout/Android.bp b/dexlayout/Android.bp
index 75f134e..e26d051 100644
--- a/dexlayout/Android.bp
+++ b/dexlayout/Android.bp
@@ -19,7 +19,7 @@
         "dexlayout.cc",
         "dex_ir.cc",
         "dex_ir_builder.cc",
-    "dex_verify.cc",
+	"dex_verify.cc",
         "dex_visualize.cc",
         "dex_writer.cc",
     ],
@@ -59,27 +59,13 @@
 
 art_cc_binary {
     name: "dexdiag",
-    host_supported: true,
+    host_supported: false,
     srcs: ["dexdiag.cc"],
     cflags: ["-Wall"],
     shared_libs: [
         "libart",
         "libart-dexlayout",
+        "libpagemap",
     ],
-    target: {
-        android: {
-            shared_libs: [
-                "libpagemap",
-            ]
-        },
-    }
 }
 
-art_cc_test {
-    name: "art_dexdiag_tests",
-    host_supported: true,
-    defaults: [
-        "art_gtest_defaults",
-    ],
-    srcs: ["dexdiag_test.cc"],
-}
diff --git a/dexlayout/dexdiag.cc b/dexlayout/dexdiag.cc
index b2d98e1..211bfdf 100644
--- a/dexlayout/dexdiag.cc
+++ b/dexlayout/dexdiag.cc
@@ -27,9 +27,7 @@
 #include "dex_file.h"
 #include "dex_ir.h"
 #include "dex_ir_builder.h"
-#ifdef ART_TARGET_ANDROID
 #include "pagemap/pagemap.h"
-#endif
 #include "runtime.h"
 #include "vdex_file.h"
 
@@ -37,6 +35,8 @@
 
 using android::base::StringPrintf;
 
+static constexpr size_t kLineLength = 32;
+
 static bool g_show_key = false;
 static bool g_verbose = false;
 static bool g_show_statistics = false;
@@ -96,7 +96,6 @@
   }
 }
 
-#ifdef ART_TARGET_ANDROID
 static char PageTypeChar(uint16_t type) {
   if (kDexSectionInfoMap.find(type) == kDexSectionInfoMap.end()) {
     return '-';
@@ -127,7 +126,6 @@
                            size_t end,
                            const std::vector<dex_ir::DexFileSection>& sections,
                            PageCount* page_counts) {
-  static constexpr size_t kLineLength = 32;
   for (size_t page = start; page < end; ++page) {
     char type_char = '.';
     if (PM_PAGEMAP_PRESENT(pagemap[page])) {
@@ -321,7 +319,6 @@
   free(pagemap);
   return true;
 }
-#endif
 
 
 static void Usage(const char* cmd) {
@@ -355,7 +352,6 @@
   InitLogging(argv, Runtime::Aborter);
   MemMap::Init();
 
-#ifdef ART_TARGET_ANDROID
   pid_t pid;
   char* endptr;
   pid = (pid_t)strtol(argv[argc - 1], &endptr, 10);
@@ -395,7 +391,6 @@
       return EXIT_FAILURE;
     }
   }
-#endif
 
   if (g_show_key) {
     PrintLetterKey();
diff --git a/dexlayout/dexdiag_test.cc b/dexlayout/dexdiag_test.cc
deleted file mode 100644
index 34c4dae..0000000
--- a/dexlayout/dexdiag_test.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.
- */
-
-#include <string>
-#include <vector>
-
-#include "common_runtime_test.h"
-
-#include "runtime/os.h"
-#include "runtime/exec_utils.h"
-
-namespace art {
-
-static const char* kDexDiagKey = "-k";
-static const char* kDexDiagVerbose = "-v";
-static const char* kDexDiagSummary = "-s";
-static const char* kDexDiagBinaryName = "dexdiag";
-
-class DexDiagTest : public CommonRuntimeTest {
- protected:
-  virtual void SetUp() {
-    CommonRuntimeTest::SetUp();
-  }
-
-  // Path to the dexdiag(d?)[32|64] binary.
-  std::string GetDexDiagFilePath() {
-    std::string root = GetTestAndroidRoot();
-
-    root += "/bin/";
-    root += kDexDiagBinaryName;
-
-    std::string root32 = root + "32";
-    // If we have both a 32-bit and a 64-bit build, the 32-bit file will have a 32 suffix.
-    if (OS::FileExists(root32.c_str()) && !Is64BitInstructionSet(kRuntimeISA)) {
-      return root32;
-    } else {
-      // This is a 64-bit build or only a single build exists.
-      return root;
-    }
-  }
-
-  // Run dexdiag with a custom boot image location.
-  bool Exec(pid_t this_pid, const std::vector<std::string>& args, std::string* error_msg) {
-    // Invoke 'dexdiag' against the current process.
-    // This should succeed because we have a runtime and so it should
-    // be able to map in the boot.art and do a diff for it.
-    std::vector<std::string> exec_argv;
-
-    // Build the command line "dexdiag <args> this_pid".
-    std::string executable_path = GetDexDiagFilePath();
-    EXPECT_TRUE(OS::FileExists(executable_path.c_str())) << executable_path
-                                                         << " should be a valid file path";
-    exec_argv.push_back(executable_path);
-    for (const auto& arg : args) {
-      exec_argv.push_back(arg);
-    }
-    exec_argv.push_back(std::to_string(this_pid));
-
-    return ::art::Exec(exec_argv, error_msg);
-  }
-};
-
-// We can't run these tests on the host, as they will fail when trying to open
-// /proc/pid/pagemap.
-// On the target, we invoke 'dexdiag' against the current process.
-// This should succeed because we have a runtime and so dexdiag should
-// be able to find the map for, e.g., boot.vdex and friends.
-#if defined (ART_TARGET)
-TEST_F(DexDiagTest, DexDiagLetterKeyTest) {
-#else
-TEST_F(DexDiagTest, DexDiagLetterKeyTest) {
-#endif
-  std::string error_msg;
-  ASSERT_TRUE(Exec(getpid(), { kDexDiagKey }, &error_msg)) << "Failed to execute -- because: "
-                                                           << error_msg;
-}
-
-#if defined (ART_TARGET)
-TEST_F(DexDiagTest, DexDiagSummaryTest) {
-#else
-TEST_F(DexDiagTest, DISABLED_DexDiagSummaryTest) {
-#endif
-  std::string error_msg;
-  ASSERT_TRUE(Exec(getpid(), { kDexDiagSummary }, &error_msg)) << "Failed to execute -- because: "
-                                                               << error_msg;
-}
-
-#if defined (ART_TARGET)
-TEST_F(DexDiagTest, DexDiagVerboseTest) {
-#else
-TEST_F(DexDiagTest, DISABLED_DexDiagVerboseTest) {
-#endif
-  std::string error_msg;
-  ASSERT_TRUE(Exec(getpid(), { kDexDiagVerbose }, &error_msg)) << "Failed to execute -- because: "
-                                                               << error_msg;
-}
-
-}  // namespace art
diff --git a/runtime/reflection_test.cc b/runtime/reflection_test.cc
index e254dfe..2f70ded 100644
--- a/runtime/reflection_test.cc
+++ b/runtime/reflection_test.cc
@@ -509,7 +509,6 @@
 };
 
 TEST_F(ReflectionTest, StaticMainMethod) {
-  TEST_DISABLED_FOR_READ_BARRIER_WITH_OPTIMIZING_FOR_UNSUPPORTED_INSTRUCTION_SETS();
   ScopedObjectAccess soa(Thread::Current());
   jobject jclass_loader = LoadDex("Main");
   StackHandleScope<1> hs(soa.Self());
diff --git a/test/run-test b/test/run-test
index 91ffdfa..e46099d 100755
--- a/test/run-test
+++ b/test/run-test
@@ -716,36 +716,13 @@
 
 export TEST_NAME=`basename ${test_dir}`
 
-# arch_supports_read_barrier ARCH
-# -------------------------------
-# Return whether the Optimizing compiler has read barrier support for ARCH.
-function arch_supports_read_barrier() {
-  # Optimizing has read barrier support for ARM, ARM64, x86 and x86-64 at the
-  # moment.
-  [ "x$1" = xarm ] || [ "x$1" = xarm64 ] || [ "x$1" = xx86 ] || [ "x$1" = xx86_64 ]
-}
-
 # Tests named '<number>-checker-*' will also have their CFGs verified with
 # Checker when compiled with Optimizing on host.
 if [[ "$TEST_NAME" =~ ^[0-9]+-checker- ]]; then
   if [ "$runtime" = "art" -a "$image_suffix" = "" -a "$USE_JACK" = "true" ]; then
-    # Optimizing has read barrier support for certain architectures
-    # only. On other architectures, compiling is disabled when read
-    # barriers are enabled, meaning that we do not produce a CFG file
-    # as a side-effect of compilation, thus the Checker assertions
-    # cannot be checked. Disable Checker for those cases.
-    #
-    # TODO: Enable Checker when read barrier support is added to more
-    # architectures (b/12687968).
-    if [ "x$ART_USE_READ_BARRIER" != xfalse ]                  \
-       && (([ "x$host_mode" = "xyes" ]                         \
-            && ! arch_supports_read_barrier "$host_arch_name") \
-           || ([ "x$target_mode" = "xyes" ]                    \
-               && ! arch_supports_read_barrier "$target_arch_name")); then
-      run_checker="no"
     # In no-prebuild mode, the compiler is only invoked if both dex2oat and
     # patchoat are available. Disable Checker otherwise (b/22552692).
-    elif [ "$prebuild_mode" = "yes" ] \
+    if [ "$prebuild_mode" = "yes" ] \
          || [ "$have_patchoat" = "yes" -a "$have_dex2oat" = "yes" ]; then
       run_checker="yes"
 
diff --git a/test/testrunner/testrunner.py b/test/testrunner/testrunner.py
index 49dc657..6a8b0ae 100755
--- a/test/testrunner/testrunner.py
+++ b/test/testrunner/testrunner.py
@@ -499,7 +499,7 @@
     else:
       print_test_info(test_name, '')
   except subprocess.TimeoutExpired as e:
-    failed_tests.append((test_name, 'Timed out in %d seconds'))
+    failed_tests.append((test_name, 'Timed out in %d seconds' % timeout))
     print_test_info(test_name, 'TIMEOUT', 'Timed out in %d seconds\n%s' % (
         timeout, command))
   except Exception as e:
diff --git a/tools/libcore_failures.txt b/tools/libcore_failures.txt
index 55b2c59..07d7fb8 100644
--- a/tools/libcore_failures.txt
+++ b/tools/libcore_failures.txt
@@ -209,55 +209,5 @@
   modes: [device],
   names: ["libcore.java.lang.ProcessBuilderTest#testRedirectInherit",
           "libcore.java.lang.ProcessBuilderTest#testRedirect_nullStreams"]
-},
-{
-  description: "Linker issues with libjavacoretests",
-  result: EXEC_FAILED,
-  bug: 35417197,
-  modes: [device],
-  names: [
-    "dalvik.system.JniTest#testGetSuperclass",
-    "dalvik.system.JniTest#testPassingBooleans",
-    "dalvik.system.JniTest#testPassingBytes",
-    "dalvik.system.JniTest#testPassingChars",
-    "dalvik.system.JniTest#testPassingClass",
-    "dalvik.system.JniTest#testPassingDoubles",
-    "dalvik.system.JniTest#testPassingFloats",
-    "dalvik.system.JniTest#testPassingInts",
-    "dalvik.system.JniTest#testPassingLongs",
-    "dalvik.system.JniTest#testPassingObjectReferences",
-    "dalvik.system.JniTest#testPassingShorts",
-    "dalvik.system.JniTest#testPassingThis",
-    "libcore.java.lang.OldSystemTest#test_load",
-    "libcore.java.lang.ThreadTest#testContextClassLoaderIsInherited",
-    "libcore.java.lang.ThreadTest#testContextClassLoaderIsNotNull",
-    "libcore.java.lang.ThreadTest#testGetAllStackTracesIncludesAllGroups",
-    "libcore.java.lang.ThreadTest#testGetStackTrace",
-    "libcore.java.lang.ThreadTest#testJavaContextClassLoader",
-    "libcore.java.lang.ThreadTest#testLeakingStartedThreads",
-    "libcore.java.lang.ThreadTest#testLeakingUnstartedThreads",
-    "libcore.java.lang.ThreadTest#testNativeThreadNames",
-    "libcore.java.lang.ThreadTest#testParkUntilWithUnderflowValue",
-    "libcore.java.lang.ThreadTest#testThreadDoubleStart",
-    "libcore.java.lang.ThreadTest#testThreadInterrupted",
-    "libcore.java.lang.ThreadTest#testThreadRestart",
-    "libcore.java.lang.ThreadTest#testThreadSleep",
-    "libcore.java.lang.ThreadTest#testThreadSleepIllegalArguments",
-    "libcore.java.lang.ThreadTest#testThreadWakeup",
-    "libcore.java.lang.ThreadTest#testUncaughtExceptionPreHandler_calledBeforeDefaultHandler",
-    "libcore.java.lang.ThreadTest#testUncaughtExceptionPreHandler_noDefaultHandler",
-    "libcore.java.util.TimeZoneTest#testDisplayNamesWithScript",
-    "libcore.java.util.zip.ZipEntryTest#testCommentAndExtraInSameOrder",
-    "libcore.java.util.zip.ZipEntryTest#testMaxLengthExtra",
-    "libcore.util.NativeAllocationRegistryTest#testBadSize",
-    "libcore.util.NativeAllocationRegistryTest#testEarlyFree",
-    "libcore.util.NativeAllocationRegistryTest#testNativeAllocationAllocatorAndNoSharedRegistry",
-    "libcore.util.NativeAllocationRegistryTest#testNativeAllocationAllocatorAndSharedRegistry",
-    "libcore.util.NativeAllocationRegistryTest#testNativeAllocationNoAllocatorAndNoSharedRegistry",
-    "libcore.util.NativeAllocationRegistryTest#testNativeAllocationNoAllocatorAndSharedRegistry",
-    "libcore.util.NativeAllocationRegistryTest#testNullArguments",
-    "org.apache.harmony.tests.java.text.SimpleDateFormatTest#test_parse_y",
-    "org.apache.harmony.tests.java.text.SimpleDateFormatTest#test_parse_yy"
-  ]
 }
 ]