Poring Shark to Google Android Dalvik Virtual Machine

Xerxes Rånby xerxes at zafena.se
Wed Jul 15 01:27:48 PDT 2009


Ілля Романенко skrev:
> Hi Xerxes,
> Thanks for your answer!
>
> Can we port only Shark(JIT) into Dalvik?
Shark are designed to slot into the OpenJDK hotspot on top of zero, the
JIT inside Shark are from the LLVM project, i will quote a nice article
on this matter:

"To implement a JIT without introducing platform-specific code, we
turned to another free software library, LLVM (Low Level Virtual
Machine). LLVM has a wide range of applicability -- it's an
infrastructure for building both compilers and virtual machines -- but
the feature that was interesting for this project is that it includes
JITs that generate native functions from code expressed in LLVM's
intermediate representation (IR).

Shark is, in essence, very simple. It uses the same interface as
HotSpot's platform-specific compilers, so it slots in with very little
modification to HotSpot itself. When running in mixed mode, HotSpot's
compiler scheduler locates hot methods and invokes Shark to compile
them, one at a time. Shark translates the Java bytecode of these methods
to LLVM IR, and invokes LLVM's JIT to generate the native code. The
native code is then installed in the VM, where it replaces the
interpreted version of the method, and control returns to the compiler
scheduler."

http://today.java.net/pub/a/today/2009/05/21/zero-and-shark-openjdk-port.html


Thus you can use the LLVM compiler infrastructure libraries to fit a JIT
into Dalvik in a similar way that we have used LLVM in Shark to fit the
LLVM JIT into Hotspot.
Try work with the LLVM JIT tutorials to see how the LLVM JIT can be
fitted into Dalvik.
http://llvm.org/docs/tutorial/

Now the main issue for you are: *where do you obtain the Dalvik sourcecode?*
AFAIK it are not available outside of Google. so sorry you cant port the
Shark JIT to Dalvik unless Dalvik are released as free software.
The Dalivk interpreter looks on the surface as a obfuscated Jamvm  so
try fit the LLVM JIT to JamVM and it will probably end up in Dalvik
automagically.

If the Dalvik sourcecode have been released please give me a pointer to it.
 
Cheers
Xerxes

>
> 15 липня 2009 р. 00:18 Xerxes Rånby <xerxes at zafena.se
> <mailto:xerxes at zafena.se>> написав:
>
>     Den 2009-07-14 21:26, Ілля Романенко skrev:
>     > Hi,
>     > I was wondering if it would be good idea to port Shark Dalvik
>     Virtual
>     > Machine? As dalvik didn't have JIT for now so apps works very slow.
>     > You may look at
>     > http://www.koushikdutta.com/2009/01/dalvik-vs-mono.html to see
>     how bad
>     > is it  :)
>     >
>     > Let me know what do you think about it...
>     >
>     > Cheers,
>     > Illia Romanenko
>
>     It would actually be quite a good idea to get OpenJDK using zero/shark
>     running on Android as is as an alternative java implementation instead
>     of using Dalvik, it will give Android Java SE compatibility and
>     prevent
>     a split in the embedded Java world.
>
>     OpenJDK currently have two jits for ARM  the and Shark JIT (work in
>     progress on stabilising llvm for ARM) and the Cacao JIT we also have a
>     brand new and fast ASM optimized interpreter for ARM to be used on top
>     of Zero.
>
>     Another option are to use PhoneME on Android as is, it also contains a
>     JIT and would give Android Java ME compatibility,
>
>     currently as fair as i know Android are only compatible with itself
>     since it only uses a subset of apache harmony.
>
>     You can probably use the caciocavallo project to enable OpenJDK to
>     draw
>     all swing and awt guis on Android.
>     http://openjdk.java.net/projects/caciocavallo/
>
>     Cheers
>     Xerxes
>
>




More information about the zero-dev mailing list