Revert "Add "linkage" test options"

This reverts commit 873bb64b8815b3f6a350ce109eb54ec770369d22.

Reason for revert: Test in CL fails on device, see:
https://ci.chromium.org/p/art/builders/ci/angler-armv7-ndebug/1302?

Change-Id: I18d8204f40bbc0f89eb230656e14966035b0b1c3
diff --git a/compiler/driver/compiler_options.cc b/compiler/driver/compiler_options.cc
index f4189e2..cde6ae9 100644
--- a/compiler/driver/compiler_options.cc
+++ b/compiler/driver/compiler_options.cc
@@ -73,7 +73,6 @@
       dump_cfg_file_name_(""),
       dump_cfg_append_(false),
       force_determinism_(false),
-      crash_on_linkage_violation_(false),
       deduplicate_code_(true),
       count_hotness_in_compiled_code_(false),
       resolve_startup_const_strings_(false),
diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h
index 639c547..79ba1c2 100644
--- a/compiler/driver/compiler_options.h
+++ b/compiler/driver/compiler_options.h
@@ -311,14 +311,6 @@
     return force_determinism_;
   }
 
-  bool IsCheckLinkageConditions() const {
-    return check_linkage_conditions_;
-  }
-
-  bool IsCrashOnLinkageViolation() const {
-    return crash_on_linkage_violation_;
-  }
-
   bool DeduplicateCode() const {
     return deduplicate_code_;
   }
@@ -439,13 +431,6 @@
   // outcomes.
   bool force_determinism_;
 
-  // Whether the compiler should check for violation of the conditions required to perform AOT
-  // "linkage".
-  bool check_linkage_conditions_;
-  // Whether the compiler should crash when encountering a violation of one of
-  // the conditions required to perform AOT "linkage".
-  bool crash_on_linkage_violation_;
-
   // Whether code should be deduplicated.
   bool deduplicate_code_;
 
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 2c94e72..fbe1c0a 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -800,9 +800,7 @@
       app_image_fd_(kInvalidFd),
       profile_file_fd_(kInvalidFd),
       timings_(timings),
-      force_determinism_(false),
-      check_linkage_conditions_(false),
-      crash_on_linkage_violation_(false)
+      force_determinism_(false)
       {}
 
   ~Dex2Oat() {
@@ -1102,9 +1100,6 @@
     }
     compiler_options_->force_determinism_ = force_determinism_;
 
-    compiler_options_->check_linkage_conditions_ = check_linkage_conditions_;
-    compiler_options_->crash_on_linkage_violation_ = crash_on_linkage_violation_;
-
     if (passes_to_run_filename_ != nullptr) {
       passes_to_run_ = ReadCommentedInputFromFile<std::vector<std::string>>(
           passes_to_run_filename_,
@@ -1323,8 +1318,6 @@
     AssignIfExists(args, M::DirtyImageObjects, &dirty_image_objects_filename_);
     AssignIfExists(args, M::ImageFormat, &image_storage_mode_);
     AssignIfExists(args, M::CompilationReason, &compilation_reason_);
-    AssignTrueIfExists(args, M::CheckLinkageConditions, &check_linkage_conditions_);
-    AssignTrueIfExists(args, M::CrashOnLinkageViolation, &crash_on_linkage_violation_);
 
     AssignIfExists(args, M::Backend, &compiler_kind_);
     parser_options->requested_specific_compiler = args.Exists(M::Backend);
@@ -3017,10 +3010,6 @@
 
   // See CompilerOptions.force_determinism_.
   bool force_determinism_;
-  // See CompilerOptions.crash_on_linkage_violation_.
-  bool check_linkage_conditions_;
-  // See CompilerOptions.crash_on_linkage_violation_.
-  bool crash_on_linkage_violation_;
 
   // Directory of relative classpaths.
   std::string classpath_dir_;
diff --git a/dex2oat/dex2oat_options.cc b/dex2oat/dex2oat_options.cc
index ea72d54..58944ff 100644
--- a/dex2oat/dex2oat_options.cc
+++ b/dex2oat/dex2oat_options.cc
@@ -224,10 +224,6 @@
           .IntoKey(M::VeryLargeAppThreshold)
       .Define("--force-determinism")
           .IntoKey(M::ForceDeterminism)
-      .Define("--check-linkage-conditions")
-          .IntoKey(M::CheckLinkageConditions)
-      .Define("--crash-on-linkage-violation")
-          .IntoKey(M::CrashOnLinkageViolation)
       .Define("--copy-dex-files=_")
           .WithType<linker::CopyOption>()
           .WithValueMap({{"true", linker::CopyOption::kOnlyIfCompressed},
diff --git a/dex2oat/dex2oat_options.def b/dex2oat/dex2oat_options.def
index e324e8b..f48806c 100644
--- a/dex2oat/dex2oat_options.def
+++ b/dex2oat/dex2oat_options.def
@@ -91,7 +91,5 @@
 DEX2OAT_OPTIONS_KEY (std::string,                    DirtyImageObjects)
 DEX2OAT_OPTIONS_KEY (std::vector<std::string>,       RuntimeOptions)
 DEX2OAT_OPTIONS_KEY (std::string,                    CompilationReason)
-DEX2OAT_OPTIONS_KEY (Unit,                           CheckLinkageConditions)
-DEX2OAT_OPTIONS_KEY (Unit,                           CrashOnLinkageViolation)
 
 #undef DEX2OAT_OPTIONS_KEY
diff --git a/dex2oat/driver/compiler_driver.cc b/dex2oat/driver/compiler_driver.cc
index b97f1db..15c7c65 100644
--- a/dex2oat/driver/compiler_driver.cc
+++ b/dex2oat/driver/compiler_driver.cc
@@ -1596,7 +1596,7 @@
     // generated code.
     const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
     ScopedObjectAccess soa(self);
-    StackHandleScope<5> hs(soa.Self());
+    StackHandleScope<2> hs(soa.Self());
     Handle<mirror::ClassLoader> class_loader(
         hs.NewHandle(soa.Decode<mirror::ClassLoader>(jclass_loader)));
     Handle<mirror::DexCache> dex_cache(hs.NewHandle(class_linker->FindDexCache(
@@ -1611,40 +1611,6 @@
       CheckAndClearResolveException(soa.Self());
       resolve_fields_and_methods = false;
     } else {
-      Handle<mirror::Class> hklass(hs.NewHandle(klass));
-      if (manager_->GetCompiler()->GetCompilerOptions().IsCheckLinkageConditions() &&
-          !manager_->GetCompiler()->GetCompilerOptions().IsBootImage()) {
-        bool is_fatal = manager_->GetCompiler()->GetCompilerOptions().IsCrashOnLinkageViolation();
-        ObjPtr<mirror::ClassLoader> resolving_class_loader = hklass->GetClassLoader();
-        if (resolving_class_loader != soa.Decode<mirror::ClassLoader>(jclass_loader)) {
-          // Redefinition via different ClassLoaders.
-          // This OptStat stuff is to enable logging from the APK scanner.
-          if (is_fatal)
-            LOG(FATAL) << "OptStat#" << hklass->PrettyClassAndClassLoader() << ": 1";
-          else
-            LOG(ERROR)
-                << "LINKAGE VIOLATION: "
-                << hklass->PrettyClassAndClassLoader()
-                << " was redefined";
-        }
-        // Check that the current class is not a subclass of java.lang.ClassLoader.
-        if (!hklass->IsInterface() &&
-            hklass->IsSubClass(class_linker->FindClass(self,
-                                                       "Ljava/lang/ClassLoader;",
-                                                       hs.NewHandle(resolving_class_loader)))) {
-          // Subclassing of java.lang.ClassLoader.
-          // This OptStat stuff is to enable logging from the APK scanner.
-          if (is_fatal)
-            LOG(FATAL) << "OptStat#" << hklass->PrettyClassAndClassLoader() << ": 1";
-          else
-            LOG(ERROR)
-                << "LINKAGE VIOLATION: "
-                << hklass->PrettyClassAndClassLoader()
-                << " is a subclass of java.lang.ClassLoader";
-        }
-        CHECK(hklass->IsResolved()) << hklass->PrettyClass();
-        klass.Assign(hklass.Get());
-      }
       // We successfully resolved a class, should we skip it?
       if (SkipClass(jclass_loader, dex_file, klass)) {
         return;
diff --git a/test/1964-linkage/check b/test/1964-linkage/check
deleted file mode 100755
index f2520ae..0000000
--- a/test/1964-linkage/check
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2020 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.
-
-# Search for the linkage failure lines and remove unnecessary characters.
-sed -e 's/.*\(LINKAGE VIOLATION:.*\)/\1/g' "$2" > "$2.tmp1"
-
-# Remove all other dex2oat/dalvikvm log lines.
-grep -v dex2oat "$2.tmp1" | grep -v dalvikvm >> "$2.tmp2"
-
-./default-check "$1" "$2.tmp2"
diff --git a/test/1964-linkage/expected.txt b/test/1964-linkage/expected.txt
deleted file mode 100644
index f60a85c..0000000
--- a/test/1964-linkage/expected.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-LINKAGE VIOLATION: java.lang.Class<java.lang.Object,null> was redefined
-LINKAGE VIOLATION: java.lang.Class<MyClassLoader,dalvik.system.PathClassLoader> is a subclass of java.lang.ClassLoader
diff --git a/test/1964-linkage/info.txt b/test/1964-linkage/info.txt
deleted file mode 100644
index 621fd26..0000000
--- a/test/1964-linkage/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Test that redefining a class in the boot classpath produces a warning.
diff --git a/test/1964-linkage/run b/test/1964-linkage/run
deleted file mode 100755
index 354fee1..0000000
--- a/test/1964-linkage/run
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2020 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.
-
-export ANDROID_LOG_TAGS='*:e'
-exec ${RUN} -Xcompiler-option --check-linkage-conditions "${@}"
diff --git a/test/1964-linkage/smali/Main.smali b/test/1964-linkage/smali/Main.smali
deleted file mode 100644
index 267dacf..0000000
--- a/test/1964-linkage/smali/Main.smali
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2020 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.
-
-.class public LMain;
-.super Ljava/lang/Object;
-
-.method public static main([Ljava/lang/String;)V
-  .registers 1
-  return-void
-.end method
diff --git a/test/1964-linkage/smali/MyClassLoader.smali b/test/1964-linkage/smali/MyClassLoader.smali
deleted file mode 100644
index e06e9a0..0000000
--- a/test/1964-linkage/smali/MyClassLoader.smali
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (C) 2020 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.
-
-.class public LMyClassLoader;
-.super Ldalvik/system/PathClassLoader;
-
-.method public static getNull()Ljava/lang/Object;
-  .registers 1
-  const v0, 0x0
-  return-object v0
-.end method
diff --git a/test/1964-linkage/smali/Object.smali b/test/1964-linkage/smali/Object.smali
deleted file mode 100644
index 35c6c77..0000000
--- a/test/1964-linkage/smali/Object.smali
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2020 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.
-
-.class public Ljava/lang/Object;
-
-.method public static $noinline$bar()LUnresolved;
-  .registers 1
-  const v0, 0x0
-  return-object v0
-.end method
diff --git a/test/knownfailures.json b/test/knownfailures.json
index f019a6a..f9111b7 100644
--- a/test/knownfailures.json
+++ b/test/knownfailures.json
@@ -802,15 +802,6 @@
     },
     {
         "tests": [
-          "1964-linkage"
-        ],
-        "variant": "speed-profile | interpreter | interp-ac",
-        "description": [
-          "Linkage warnings are only emitted from dex2oat."
-        ]
-    },
-    {
-        "tests": [
           "1965-get-set-local-primitive-no-tables",
           "1966-get-set-local-objects-no-table"
         ],