Fix two tests after vdex change.
- Clear entries of verification results, to avoid hitting a
DCHECK while running verifier_deps_test
- Backlist 629-vdex-speed for relocate-npatchoat, as the test
needs compiled code.
test: verifier_deps_test, 629-vdex-speed
bug: 30937355
Change-Id: I9788599dafcbfe63522c58f85692601466d191db
diff --git a/compiler/dex/verification_results.h b/compiler/dex/verification_results.h
index ab735c1..22749fa 100644
--- a/compiler/dex/verification_results.h
+++ b/compiler/dex/verification_results.h
@@ -32,6 +32,7 @@
namespace verifier {
class MethodVerifier;
+class VerifierDepsTest;
} // namespace verifier
class CompilerOptions;
@@ -80,6 +81,8 @@
// Rejected classes.
ReaderWriterMutex rejected_classes_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
std::set<ClassReference> rejected_classes_ GUARDED_BY(rejected_classes_lock_);
+
+ friend class verifier::VerifierDepsTest;
};
} // namespace art
diff --git a/compiler/utils/atomic_method_ref_map-inl.h b/compiler/utils/atomic_method_ref_map-inl.h
index 70ea028..d71c2fe 100644
--- a/compiler/utils/atomic_method_ref_map-inl.h
+++ b/compiler/utils/atomic_method_ref_map-inl.h
@@ -78,6 +78,15 @@
}
}
+template <typename T>
+inline void AtomicMethodRefMap<T>::ClearEntries() {
+ for (auto& it : arrays_) {
+ for (auto& element : it.second) {
+ element.StoreRelaxed(nullptr);
+ }
+ }
+}
+
} // namespace art
#endif // ART_COMPILER_UTILS_ATOMIC_METHOD_REF_MAP_INL_H_
diff --git a/compiler/utils/atomic_method_ref_map.h b/compiler/utils/atomic_method_ref_map.h
index 11ab211..fed848f 100644
--- a/compiler/utils/atomic_method_ref_map.h
+++ b/compiler/utils/atomic_method_ref_map.h
@@ -55,6 +55,8 @@
template <typename Visitor>
void Visit(const Visitor& visitor);
+ void ClearEntries();
+
private:
// Verified methods. The method array is fixed to avoid needing a lock to extend it.
using ElementArray = dchecked_vector<Atomic<T>>;
diff --git a/compiler/verifier_deps_test.cc b/compiler/verifier_deps_test.cc
index 90fe6da..52765f9 100644
--- a/compiler/verifier_deps_test.cc
+++ b/compiler/verifier_deps_test.cc
@@ -19,8 +19,11 @@
#include "class_linker.h"
#include "compiler/common_compiler_test.h"
+#include "compiler/dex/verification_results.h"
+#include "compiler/dex/verified_method.h"
#include "compiler/driver/compiler_options.h"
#include "compiler/driver/compiler_driver.h"
+#include "compiler/utils/atomic_method_ref_map-inl.h"
#include "compiler_callbacks.h"
#include "dex_file.h"
#include "dex_file_types.h"
@@ -90,6 +93,14 @@
verifier_deps_.reset(callbacks_->GetVerifierDeps());
}
callbacks_->SetVerifierDeps(nullptr);
+ // Clear entries in the verification results to avoid hitting a DCHECK that
+ // we always succeed inserting a new entry after verifying.
+ AtomicMethodRefMap<const VerifiedMethod*>* map =
+ &compiler_driver_->GetVerificationResults()->atomic_verified_methods_;
+ map->Visit([](const MethodReference& ref ATTRIBUTE_UNUSED, const VerifiedMethod* method) {
+ delete method;
+ });
+ map->ClearEntries();
}
void SetVerifierDeps(const std::vector<const DexFile*>& dex_files) {
@@ -112,6 +123,9 @@
for (const DexFile* dex_file : dex_files_) {
class_linker_->RegisterDexFile(*dex_file, loader.Get());
}
+ for (const DexFile* dex_file : dex_files_) {
+ compiler_driver_->GetVerificationResults()->AddDexFile(dex_file);
+ }
}
void LoadDexFile(ScopedObjectAccess* soa) REQUIRES_SHARED(Locks::mutator_lock_) {
diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk
index d7dfe5a..28e1e60 100644
--- a/test/Android.run-test.mk
+++ b/test/Android.run-test.mk
@@ -427,6 +427,7 @@
# explicitly test for them. These all also assume we have an image.
# 147-stripped-dex-fallback is disabled because it requires --prebuild.
# 554-jit-profile-file is disabled because it needs a primary oat file to know what it should save.
+# 629-vdex-speed requires compiled code.
TEST_ART_BROKEN_FALLBACK_RUN_TESTS := \
116-nodex2oat \
117-nopatchoat \
@@ -435,7 +436,8 @@
137-cfi \
138-duplicate-classes-check2 \
147-stripped-dex-fallback \
- 554-jit-profile-file
+ 554-jit-profile-file \
+ 629-vdex-speed
# This test fails without an image.
TEST_ART_BROKEN_NO_IMAGE_RUN_TESTS := \