OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student
-
Upload
open-world-forum -
Category
Documents
-
view
1.031 -
download
1
Transcript of OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student
![Page 1: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/1.jpg)
![Page 2: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/2.jpg)
Jérôme Pilliet
Université Paris-Est de Marne-la-Vallée
Dalvik 292
![Page 3: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/3.jpg)
Sommaire
● Avant propos● JVM vs DVM
● Principe● Comportement
● JSR 292● Principe● java.lang.invoke● Exemple
● Optimisation● VMs modernes ● JSR 292
● Dalvik 292● Problèmes et solutions partielles
● Conclusion
![Page 4: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/4.jpg)
Avant propos
● Langages typés dynamiquement● sémantique déterminée à l'exécution
● Smartphone / tablette● mémoire restreinte● puissance de calcul restreinte
● Android et Dalvik● OS le plus utilisé● technologie Java - Dalvik
![Page 5: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/5.jpg)
JVM vs DVMPrincipe
● Machine à piles / machine à registres● Spécification ~ Java 6
![Page 6: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/6.jpg)
JVM vs DVMPrincipe
● Machine à piles / machine à registres● Spécification ~ Java 6
![Page 7: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/7.jpg)
JVM vs DVMPrincipe
● Machine à piles / machine à registres● Spécification ~ Java 6
![Page 8: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/8.jpg)
JVM vs DVMComportement
● Dalvik● Bytecode
– readonly● ODEX
– bytecode
– vtables (methodes)
– offsets (attributs)
– method inlining● Zygote
– pre-load VM● Trace/Method JIT Compiler● Garbage Collector
– restreint
● Java Virtual Machine● JIT Compiler
![Page 9: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/9.jpg)
JSR 292Principe
![Page 10: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/10.jpg)
JSR 292Principe
![Page 11: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/11.jpg)
JSR 292Principe
![Page 12: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/12.jpg)
JSR 292java.lang.invoke
● invokedynamic● édition de lien
● MethodHandle● invokeExact● invoke● combinateurs● GuardWithTest● ...
● MethodHandle Tree● combinaison de MH
● CallSite● conteneur de MH
● SwitchPoint● désoptimisation
![Page 13: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/13.jpg)
JSR 292Exemple
class A { foo() { … }}
…b.foo()...
.
.
.
. invokevirtual java/lang/Object.foo:()Object
![Page 14: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/14.jpg)
JSR 292Exemple
class A { foo() { … }}
…b.foo()...
.
.
.
. invokevirtual java/lang/Object.foo:()Object
invokedynamic ''foo'':()Object
![Page 15: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/15.jpg)
JSR 292Exemple
…invokedynamic "+" (Object, Object)Object bsm: RT.bsm(Lookup, String, MethodType)CallSite...
// exemple…A = B + C ;...
![Page 16: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/16.jpg)
JSR 292Exemple
…invokedynamic "+" (Object, Object)Object bsm: RT.bsm(Lookup, String, MethodType)CallSite...
CallSite bsm(Lookup lookup, String name, MethodType type) { CallSite cs = ... MethodHandle mh = ... cs.setTarget(mh); return cs;}
1. appel methode d'amorce
// exemple…A = B + C ;...
![Page 17: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/17.jpg)
JSR 292Exemple
…invokedynamic "+" (Object, Object)Object bsm: RT.bsm(Lookup, String, MethodType)CallSite...
CallSite bsm(Lookup lookup, String name, MethodType type) { CallSite cs = ... MethodHandle mh = ... cs.setTarget(mh); return cs;}
1. appel methode d'amorce2. associe un CallSite au site d'appel
// exemple…A = B + C ;...
![Page 18: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/18.jpg)
JSR 292Exemple
…invokedynamic "+" (Object, Object)Object bsm: RT.bsm(Lookup, String, MethodType)CallSite...
CallSite bsm(Lookup lookup, String name, MethodType type) { CallSite cs = ... MethodHandle mh = ... cs.setTarget(mh); return cs;}
Arbre deMethodHandles
1. appel methode d'amorce2. associe un CallSite au site d'appel
3. appels suivants
// exemple…A = B + C ;...
![Page 19: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/19.jpg)
JSR 292Exemple
…invokedynamic "+" (Object, Object)Object bsm: RT.bsm(Lookup, String, MethodType)CallSite...
CallSite bsm(Lookup lookup, String name, MethodType type) { CallSite cs = ... MethodHandle mh = ... cs.setTarget(mh); return cs;}
+(int, int)
+(double, double)Arbre deMethodHandles
1. appel methode d'amorce2. associe un CallSite au site d'appel
3. appels suivants
// exemple…A = B + C ;...
![Page 20: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/20.jpg)
JSR 292Exemple
…invokedynamic "+" (Object, Object)Object bsm: RT.bsm(Lookup, String, MethodType)CallSite...
CallSite bsm(Lookup lookup, String name, MethodType type) { CallSite cs = ... MethodHandle mh = ... cs.setTarget(mh); return cs;}
+(int, int)
+(double, double)
fallback(CallSite cs) { ... cs.setTarget(...)}
Arbre deMethodHandles
1. appel methode d'amorce2. associe un CallSite au site d'appel
3. appels suivants
change la cible
// exemple…A = B + C ;...
![Page 21: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/21.jpg)
OptimisationVMs modernes
● Génération de code machine optimiste● pas de test à null si jamais null● pas de branche non prise● inlining des appels virtuels● cheap-cast● désoptimisation si assomption fausse
● Profiling● présence de ''null''● receveurs d'appels virtuels● classes pour les cast/instanceof● fréquence des branches des if
● Détection de code chaud● méthode chaude● boucle chaude (OSR)
![Page 22: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/22.jpg)
OptimisationJSR 292
● Profiling● détection de MethodHandle chaud et stabilité de invokedynamic● receveur de l’appel virtuel● branche pour le GuardWithTest
● Détection ● stabilité target d'un invokedynamic
● invokeExact / génération de bytecode● MethodHandle chaud
● appel en assembleur● MethodHandles Tree
● génération de bytecode => Out Of Memory !!!● (Pré-JDK 7) appel en Java● (JDK 7) mini-interpréteur (AST)● (JDK 8) LambdaForm + paramètres JITé
![Page 23: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/23.jpg)
Dalvik 292Problèmes et solutions
![Page 24: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/24.jpg)
Dalvik 292Problèmes et solutions
mh.args
skeleton.args
Pile
● Détection de MethodHandle chaud● MethodHandle
● bytecode spécifique● MethodHandle Tree
● squelette en code DEX● convention d'appel spécifique
● gère l'optimisation des lambdas (Java 8)
● JIT● MethodHandle et petit MethodHandle Tree
● inlining● Squelette
● JITé
![Page 25: OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student](https://reader034.fdocuments.net/reader034/viewer/2022042700/5596407a1a28ab58558b4659/html5/thumbnails/25.jpg)
● Avancement● ajout des instructions● nouveau format DEX● génération du fichier DEX
● Intérêt● Dalvik : une VM comme les autres● suivre évolution Java
Conclusion