Linked by Thom Holwerda on Tue 10th Jul 2012 17:08 UTC
PDAs, Cellphones, Wireless I've been flashing CyanogenMod 9 nightlies for months now, and the process to do so has become pretty much muscle memory at this point (if cwm ever changes its menu order I'm screwed). One step of this process has always fascinated me simply because I have no idea what exactly it does and why I have to do it: clearing Dalvik cache.
Thread beginning with comment 526364
To read all comments associated with this story, please click here.
JVM Bytecode to "native"
by Lennie on Wed 11th Jul 2012 11:50 UTC
Lennie
Member since:
2007-09-22

Java is compiled to processor independant bytecode so you can run it on any device which has a JVM which understands that bytecode. The bytecode is "the program" you download onto your device.

That bytecode than gets "compiled" at runtime optimized for the processor it is running on (x86, ARM, AMD64, etc.). This is what they call Just-In-Time compilation is. Depending on how JIT is done, it can mean that only the part of the code that is used will be JIT compiled.

As some examples: PHP files are also compiles to bytecode before it is run. The bytecode is what is actually 'running' when a PHP-script is doing it's work, it is interpreting the bytecode.

JavaScript doesn't use a bytecode intermediate, I believe. But it does do the JIT compilation to optimise for the processor it is running on.

Anyway, I assume the cache you mentioned is the used for the result of the JIT compilation.

And the reason why it needs to be cleared I guess is because for Android system classes it would always use the JIT and not even check if it the bytecode is newer/different/has been updated.

Edited 2012-07-11 11:53 UTC

Reply Score: 1

RE: JVM Bytecode to "native"
by Lennie on Fri 13th Jul 2012 23:59 in reply to "JVM Bytecode to "native""
Lennie Member since:
2007-09-22

Seems I was wrong, at least the Firefox JavaScript engine (and I assume the other do too) compiles the script source to bytecode as well.

Reply Parent Score: 2

RE[2]: JVM Bytecode to "native"
by zima on Tue 17th Jul 2012 23:33 in reply to "RE: JVM Bytecode to "native""
zima Member since:
2005-07-06

Overall, you mix a bit carelessly interpretation, compilation, and JIT over there.

Reply Parent Score: 2