Squeak + Android and Dalvik!? (was Re: [Vm-dev] Performance, Quality
and Process [was Array new: SmallInteger maxVal])
Göran Krampe
goran at krampe.se
Thu Oct 22 09:38:28 UTC 2009
Hi all!
Eliot Miranda wrote:
> I need to at least hurry up and get the StackInterpreter released.
Which of course tickles me enough to ask again about your status? :)
Let me indulge in some "braindumping" here about Squeak vs Android:
Android is coming on a broad front right now and I am interested in how
Squeak can "fit" into that platform.
Unless you have been living under a rock (or working hard on a JIT we
all want!) the mobile industry is heating up a LOT. Android is really
impressive and is getting thrown on all sorts of interesting hardware,
not only phones. I think that it really will be disruptive in a way that
IPhone can never be since it is a "high end only" product from a single
hardware company.
The Android SDK/dev stack is interesting, it is a Linux kernel etc, has
the Dalvik VM which is a VM with its own bytecode set that is designed
for phones and "runs Java". It does it by using a cross compiler from
java .class files to so called "dex" files and then runs those. So it is
not a "Java VM (tm)".
It is actually *register based* and I have peeked at its sources. It
seems to have been written with a "brute force" approach by C-coders -
nothing wrong in that of course.
First they wrote a simple interpreter core in a single C function. Then
they split it up using macros etc in order to be able to implement each
bytecode in assembler for each major CPU. The "old" C-only interpreter
is still there and it basically is a "while (!) { FETCH; switch
(bytecode) for-each-bytecode}"-loop. :)
There is no JIT. It is not fast. BUT... it is the VM on the Android and
it comes with tons of libraries etc.
Now... there is also an NDK (Native SDK) that allows one to compile C to
libraries (but not executables, not sure) that can in turn be used from
java/Dalvik... humm...
So in order to be able to write anything remotely interesting for an
Android one needs to go "through" Dalvik somehow.
My silly first "funny idea" was to somehow marry the Squeak VM with the
Dalvik VM. Merge the sources and somehow make it possibly to "drive" the
Dalvik interpreter by feeding it "dex" bytecodes from Squeak. Sure, this
will only work on a "rooted phone" I presume, but anyway, would be cool.
If we could do that I guess one could open a VNC connection into the
Squeak VM (if we can get Sockets to work) running inside the Android
simulator/device and then using Squeak producing dex bytecodes one could
perhaps dynamically "drive" Dalvik?
I am probably talking totally "out of my hat". Would be really
interesting to hear thoughts from Eliot on all this.
Anyway, getting Squeak running on Android in any fashion would be
awesomely interesting :) - it IS coming, all over.
Sidenote: Getting Squeak to run on Maemo (Nokia's Linux based OS for
n900 etc) and derivatives of Maemo is probably tons of less work
(because it is not a java centric thing and has much more standard Linux
stuff) - but tons of less interesting given the market...
regards, Göran
PS. This article + comments (by Dan Bernstein also, creator of Dalvik)
is a bit interesting.
More information about the Vm-dev
mailing list