Postpone DexCache preloading in the ImageWriter.

Preload the DexCache with deterministic contents just before
we're about to copy it to the image memory.

Previously the contents of the preloaded dex cache arrays
were further modified by the OatWriter. As long as OatWriter
was processing the same data on a single thread, this was
deterministic but it was not working as originally intended.

Also fix OatWriter::InitImageMethodVisitor::StartClass() to
use the deterministic ClassLinker::LookupResolvedType()
rather than checking only the DexCache.

Clean up OatWriter::InitImageMethodVisitor::VisitMethod(),
call LookupResolvedMethod() instead of ResolveMethod() for
boot image methods as they should be already resolved.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: Manually verify with oatdump that dex cache array
      contents are the same when compiling on host and
      on the device.
Bug: 119436742
Change-Id: Ifa324beabac2482621529655f72b4f734bd62030
3 files changed