GC-independent image layout.
Make sure we visit objects in a defined order, independent
of their order in the heap. The new order depends only on
dex file contents and contents of initialized classes,
thus any non-determinism would have to be contributed by
the class initialization itself rather than GC.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: aosp_taimen-userdebug boots.
Test: run-gtests.sh
Test: testrunner.py --target --optimizing
Bug: 26687569
Change-Id: I62521322289a22eb13faae526ba2c3589e6ab381
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 0c8d539..2d19bfc 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2538,7 +2538,9 @@
self->AssertPendingOOMException();
return nullptr;
}
- ObjPtr<mirror::String> location = intern_table_->InternStrong(dex_file.GetLocation().c_str());
+ // Use InternWeak() so that the location String can be collected when the ClassLoader
+ // with this DexCache is collected.
+ ObjPtr<mirror::String> location = intern_table_->InternWeak(dex_file.GetLocation().c_str());
if (location == nullptr) {
self->AssertPendingOOMException();
return nullptr;