Does dex2oat compile all methods?

1.7k views Asked by At

I understand that on recent versions of Android, Dex files are compiled into OAT files on-device. Do OAT files contain compiled versions of all methods in a Dex file, or are some methods left as Dex bytecode and interpreted at run time?

1

There are 1 answers

0
Jackie chen On

Dex2oat does not compile all methods if the level of application compilation options is not high, or if the method is not considered hot after running for a while.
As we know, dex2oat has many compile filter options: Verify, Quicken, space-profile, space, speed-profile, speed, everything. From Verify to everything, compilations take longer and longer, more and more classes and methods are compiled to bytecode.
You can use the oatdump command to check the compiled status of the methods in a specific package (check the OatClassAllCompiled oatclasssomecomcompiled keyword).
e.g. Lcom/android/listviewtest/MainActivity$1; (offset=0x000015c8) (type_idx=98) (Verified) (OatClassAllCompiled)

In addition, Android dex2oat is configured with properties in different scenarios:

[pm.dexopt.ab-ota]: [speed-profile]
[pm.dexopt.bg-dexopt]: [speed-profile]
[pm.dexopt.boot]: [verify]
[pm.dexopt.first-boot]: [quicken]
[pm.dexopt.inactive]: [verify]
[pm.dexopt.install]: [speed-profile]
[pm.dexopt.shared]: [speed]

Refs:https://source.android.com/devices/tech/dalvik/configure