Hi list,

we are planing to port dalvikvm to a new cpu.  we're worry about
emulator issue because clearly qemu doesn't support own homebrew cpu.
so i took a dirty investigation on the relationship between qemu-
emulator-dalvik.  could you go through my sum up and give me some
comments?

The role of emulator in dalvik
applications storing in android system in the form of apk(android
package). actually it's a zip archive with some metadata. it contains
a file named classes.dex. the file is compact to save storage.
however, dex file can not execute directly after memory-mapped. it
needs to transform to ODEX file, which O means "optimized" here.

i think the name of ODEX is a little misleading since the phrase
contains 3 purposes, while "optimization" is only one of them.
  i) realignment and byte-swapping.
  ii) verification  dex code
  iii) optimization

There're at least 3 different ways to get odex job done. i iterate
them in chronicle order:
  i)[build-time] The building system does it ahead of time.
  ii)[install-time] The system installer does it when an application
is first added(to device).
  iii)[run-time] The VM does it "just in time"

It is the #1 choice needs the emulator, which will communicate with
underlying QEMU. as doc said, The building system use a hairy process
that involves the emulator , force JIT optimization of all relevant
dex files and then extract the result from dalvik-cache. i don't know
the exact meaning of "hairy" here. but i found the hairy process in
android source. it is android/build/tools/dexpreopt/dexpreopt.py. The
python script will spawn the emulator in shell form(no GUI like
attachment), secretely run dexopt on it with dex files, and pull
optimized results from emulator. In default, android building system
performs dexpreopt for system-level java programs instead of
applications. i also notices that it forbid the dexpreopt on Mac OSX,
as the comments said in android/build/core/product_config.mk

# Hack to make the linux build servers use dexpreopt.
# OSX is still a little flaky.

so i think we can skip choice #1 and leave dalvik perform dex-odex at
install-time or runtime. it's clear that #2 and #3 occurs on real
device. no emulator need.



-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-porting

Reply via email to