Allow ThreadLocal object allocation during AOT.

The class ThreadLocal has a static field nextHashCode used
for assigning hash codes to new ThreadLocal objects. Since
the class and the object referenced by the field are in the
boot image, they cannot be modified under normal rules for
AOT compilation. However, since this is a private detail
that's used only for assigning hash codes and everything
should work fine with different hash codes, we override the
field for the compilation, providing another object that
the AOT class initialization can modify. We select the
initial hash code based on dex file checksums.

Use similar hash code selection for the identity hash code.

Test: aosp_taimen-userdebug boots.
Test: m dump-oat && \
      grep -cE 'Class.*VisiblyInitialized' \
          out/soong/boot.arm64.oatdump.txt
      # before: 8635
      # after: 8706
Test: EMMA_INSTRUMENT_FRAMEWORK=true m
Bug: 150319075
Change-Id: I46ebd8eed43860241533a8c061d7667ac84dda1f
1 file changed