Further to my previous post, I’ve been working this week on the new native compiler for Deelang on Android. This is a drop-in replacement for the standard custom bytecode compiler and VM that compiles Deelang scripts directly to Dalvik Executable (DEX) bytecode for use on the Dalvik VM used in Android.
Development has moved fairly quickly, and there is now support for some of the basic features of the language. Not everything is supported at present (there’s no field access, no method blocks, and no arithmetic support) but the basics of function/method calls are implemented, along with local variable assignment and access, and a lot of behind the scenes support that make implementing the missing features a lot easier.
The compiler is being written largely test-first, so there’s good test coverage of new features as they go in (using Dex2Jar to generate readable dumps of the generated code, which is then compared against the expected code), but this doesn’t prove a crucial fact – that we can load the code into a running device, and execute it. To this end, there’s a small sample app that lets us write code on a device, compile it and run it against a simple binding we provide.
The screenshot shows this simple (and, if I’m honest, ugly) app running on an HTC One X. Compiling the code is quick enough given the early stage of development, but it’s actually running it where the native compiler shines – because the code is a standard Java class (it’s implemented as a subclass of the
com.roscopeco.deelang.runtime.CompiledScript class, which is also a
java.lang.Runnable) there’s no discernible difference between running a script and calling any other Java method.
We’re not benchmarking this in any serious way at this early stage in the project, but it’s nice to get a feel for how things are going from a performance perspective.
If you’re interested in taking a look at the work so far, you can get the sample app from SVN at the following repository URL:
The sample includes a snapshot Deelang jar, so you don’t need the actual project to try it out. Of course, if you want to play around with the code you can grab it from:
Updating the snapshot is as simple as running ‘
ant jar‘ in the
deelang directory, and then copying out the new snapshot over to the DeeSample
One thought on “DEXing Deelang – On a real device!”
Reblogged this on Sutoprise Avenue, A SutoCom Source.