Why does android still keep dx
along its newer replacement d8
?
$ cd cmdline-tools/build-tools/30.0.3 && ls d*
d8 dexdump dx
Here is the program I used:
$ cat Primes.java
class Primes {
private static boolean isPrime(int p)
{
for (int i=2;i<p;i++) {
for (int j=2;j<p;j++) {
if (i*j == p) {
return false; }}}
return true;
}
public static void main(String[] args) {
for (int i=2;i<100;i++) {
if (isPrime(i)) {
System.out.format("%d ",i);}}}}
And here is how I compile it to dex:
$ javac Primes.java
$ cmdline-tools/build-tools/30.0.3/dx --dex --output dx/classes.dex Primes.class
$ cmdline-tools/build-tools/30.0.3/d8 --output d8 Primes.class
$ cmdline-tools/build-tools/30.0.3/dexdump -d dx/classes.dex > dx.human
$ cmdline-tools/build-tools/30.0.3/dexdump -d d8/classes.dex > d8.human
Then I clean up addresses, register names and comments to be able to compare:
$ cat dx.human | awk "/\'main\'/,/catches/" | sed "s/.*|[0-9a-f]*: //g" | sed "s/\/\/.*//g" | sed "s/Ljava.*//g" | sed "s/v[0-9]/v/g" | sed "s/v[0-9]/v/g" > dx.main.human
$ cat d8.human | awk "/\'main\'/,/catches/" | sed "s/.*|[0-9a-f]*: //g" | sed "s/\/\/.*//g" | sed "s/Ljava.*//g" | sed "s/v[0-9]/v/g" | sed "s/v[0-9]/v/g" > d8.main.human
They are almost identical then, but not entirely:
$ diff -u dx.main.human d8.main.human
--- dx.main.human 2021-04-12 19:49:37.110476376 +0300
+++ d8.main.human 2021-04-12 19:49:44.650101698 +0300
@@ -2,11 +2,11 @@
...
- registers : 7
+ registers : 5
...
const/4 v, #int 2
const/16 v, #int 100
if-ge v, v, 001f
@@ -14,13 +14,13 @@
move-result v
if-eqz v, 001c
sget-object v,
-const-string v, "%d " <----------------+
const/4 v, #int 1 |
new-array v, v, [ |
const/4 v, #int 0 |
invoke-static {v}, |
move-result-object v |
aput-object v, v, v |
+const-string v, "%d " <----------------+
invoke-virtual {v, v, v},
add-int/lit8 v, v, #int 1
goto 0001
from Why does android keep dx when it was replaced by d8?
No comments:
Post a Comment