ART: Disable CHA for AoT
App images and boot image CHA do not interact well. If boot image
methods have been marked single-implementation, but lose that
status when compiling an app image, that information is not
retained, and after loading the image at runtime, the state will
be inconsistent. As a workaround, disable CHA during AoT.
Modify expectations of run-test 616-cha.
Bug: 34193647
Test: m test-art-host
Change-Id: I53eacd97c66645c20318c71568fffb1219b0dc61
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index d06ba78..e5ed8ae 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -371,7 +371,9 @@
quick_generic_jni_trampoline_(nullptr),
quick_to_interpreter_bridge_trampoline_(nullptr),
image_pointer_size_(kRuntimePointerSize),
- cha_(new ClassHierarchyAnalysis()) {
+ cha_(Runtime::Current()->IsAotCompiler() ? nullptr : new ClassHierarchyAnalysis()) {
+ // For CHA disabled during Aot, see b/34193647.
+
CHECK(intern_table_ != nullptr);
static_assert(kFindArrayCacheSize == arraysize(find_array_class_cache_),
"Array cache size wrong.");
diff --git a/test/616-cha/src/Main.java b/test/616-cha/src/Main.java
index beea90a..27da7cc 100644
--- a/test/616-cha/src/Main.java
+++ b/test/616-cha/src/Main.java
@@ -187,7 +187,12 @@
System.loadLibrary(args[0]);
// CHeck some boot-image methods.
- assertSingleImplementation(java.util.ArrayList.class, "size", true);
+
+ // We would want to have this, but currently setting single-implementation in the boot image
+ // does not work well with app images. b/34193647
+ final boolean ARRAYLIST_SIZE_EXPECTED = false;
+ assertSingleImplementation(java.util.ArrayList.class, "size", ARRAYLIST_SIZE_EXPECTED);
+
// java.util.LinkedHashMap overrides get().
assertSingleImplementation(java.util.HashMap.class, "get", false);