<div dir="ltr">Hi Michael, Eliot,<br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 20, 2017 at 10:08 AM, Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Michael,<div><br></div><div>    take what I'm about to say with skepticism because I've not used the Android VM but as I understand it there is already a Cog Android VM for ARM v7 Androids.  If you look at the HowToBuilds in opensmalltalk/vm's build.linux32ARMv6 & build.linux32ARMv7 you'll see</div><div><br></div><div><div>$ diff build.linux32ARMv*/HowToBuild</div><div>1c1</div><div>< How To Build On Linux ARMv6 (i.e. Raspbian for Raspberry Pi (*))</div><div>---</div><div>> How To Build On Linux ARM v7 (e.g. Android devices (*))</div></div><div>...</div><div><br></div><div>I'm pretty sure that the Rasperry Pi VM does crash on Android and vice verse, because of floating point issues.  In the v6/RPi build we use</div><div>CC="gcc -march=armv6 -mfpu=vfp -mfloat-abi=hard"</div><div>and in the v7/Android build we use no such settings.</div><div><br></div><div>Right now there are only newspeak builds for Android (build.linux32ARMv7/{newspeak.<wbr>cog.spur,newspeak.stack.spur}, but if you copy across build.linux32ARMv6/<wbr>squeak.cog.spur and make the matching edits to the mvm files then you should have a working Android build.  I'm cc'ing Ryan Macnak who is the person behind the New3speak Android VM.  Ryan also did a MIPS back end so there's a possibility of running on those devices too.</div></div></blockquote><div><br></div><div>The Newspeak ARMv7 builds are configured for running on Linux (Debian armhf), not Android. Android would require building with a different toolchain and using different settings for the floating point ABI (-mfloat-abi=softfp)(Eliot, this difference will affect the JIT if you pass any floats from generated code to runtime functions, perhaps the primitive for sin calls directly to libm's sin?). That would still only produce a VM that isn't connected to the UI or other Android APIs; I expect getting this hooked up properly is a far bigger task than getting a working JIT.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I'm also pretty sure that this VM is missing the event-driven features of Andreas' VM and it would be great to have that folded back in.</div></div></blockquote><div><br></div><div>Right, a VM that isn't event driven should be killed by the system for blocking the UI thread, and hacking around that by periodically yielding will just a produce a VM that is terrible on battery life.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_extra"><div><div class="gmail-h5"><div class="gmail_quote">On Fri, Jun 16, 2017 at 12:48 PM, Michael Rueger <span dir="ltr"><<a href="mailto:lists@andience.co.nz" target="_blank">lists@andience.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Hi all,<br>
<br>
long time no see :-)<br>
<br>
Recently I spent a bit of time trying to piece together an Android VM using the up to date versions of AndroidStudio, SDK and NDK. Once things are building and running, I was planning to fold everything back into the proper build process.<br>
<br>
Current (somewhat messy) state of things here<br>
<a href="https://github.com/mrueger42/st-android" rel="noreferrer" target="_blank">https://github.com/mrueger42/s<wbr>t-android</a><br>
<br>
It has been quite a long time since I looked at building VMs, so forgive me if I'm just being stupid here...<br>
<br>
I was able to get the original port from Andreas to build and run, but it is a very outdated version. Still nice to have it as a piece of history, I think (AndroidVM in the above repo).<br>
<br>
Some puzzle pieces later I have something running that is based on recent CogSpur opensmalltalk code and bits and pieces I found. Unfortunately CogSpur doesn't seem to play well with the setjmp/longjmp used in the code (CogDroid in the above repo).<br>
<br>
Plus, the VM is running on the UI thread, not something that is viewed well on mobile. Actually it makes Android just kill the app if you block the UI thread for too long.<br>
<br>
Trying to run the VM on a thread runs into a division by 0 exception (I think) and finds me way out of my league to track down why that would be. Crash below...<br>
<br>
I haven't really tried getting Dmitry's version to build/work in a current environment, partly because I'm not sure I'm looking at the most up to date version (see below).<br>
<br>
Any help, pointers, code snippets highly appreciated!<br>
<br>
Cheers<br>
<br>
Michael<br>
<br>
P.S. Sending this to vm-dev and pharo-dev, but should probably send any followup to vm-dev?<br>
<br>
--------<br>
<br>
<br>
list of sources I looked at:<br>
<br>
-opensmalltalk<br>
-pharo<br>
<br>
-original port by Andreas<br>
git@github.com:timfel/squeak-a<wbr>ndroid-vm.git<br>
<br>
-stack<br>
<a href="https://github.com/sbragagnolo/pharo-vm/" rel="noreferrer" target="_blank">https://github.com/sbragagnolo<wbr>/pharo-vm/</a><br>
<br>
-dmitry<br>
gitorious is no longer, just an archival snapshot<br>
clicking on snapshot gives you the sources<br>
<a href="https://gitorious.org/cogvm/dmg-blessed?p=cogvm:dmg-blessed.git;a=summary" rel="noreferrer" target="_blank">https://gitorious.org/cogvm/dm<wbr>g-blessed?p=cogvm:dmg-blessed.<wbr>git;a=summary</a><br>
non-functional jenkins setup<br>
<a href="https://ci.inria.fr/pharo-contribution/view/VM/job/CogDroid/configure-readonly/" rel="noreferrer" target="_blank">https://ci.inria.fr/pharo-cont<wbr>ribution/view/VM/job/CogDroid/<wbr>configure-readonly/</a><br>
<br>
<br>
<br>
-------------<br>
<br>
The Cog VM crash when running on a Thread:<br>
<br>
<br>
D/jni-vm: Java_org_smalltalk_android_vm_<wbr>VM_runVM<br>
D/jni-vm: runVM<br>
D/jni-vm: interpret<br>
<br>
A/libc: Fatal signal 8 (SIGFPE), code -6, fault addr 0x67db in tid 26636 (Thread-5)<br>
<br>
Revision: '6'<br>
ABI: 'arm'<br>
pid: 26587, tid: 26636, name: Thread-5  >>> org.smalltalk.android <<<<br>
signal 8 (SIGFPE), code -6 (SI_TKILL), fault addr 0x67db<br>
    r0 00000000  r1 0000680c  r2 00000008  r3 00000000<br>
    r4 e4f7f978  r5 00000008  r6 e4f7f920  r7 0000010c<br>
    r8 e4f7ef60  r9 e3516400  sl e351648c  fp e4f7ecb4<br>
    ip 00000002  sp e4f7ce30  lr efca84c7  pc efcaad30  cpsr 600e0010<br>
<br>
backtrace:<br>
    #00 pc 0004ad30  /system/lib/libc.so (tgkill+12)<br>
    #01 pc 000484c3  /system/lib/libc.so (pthread_kill+34)<br>
    #02 pc 0001dd99  /system/lib/libc.so (raise+10)<br>
    #03 pc 000c54a3  /data/app/org.smalltalk.androi<wbr>d-2/lib/arm/libStackVM.so<br>
    #04 pc 00051507  /data/app/org.smalltalk.androi<wbr>d-2/lib/arm/libStackVM.so<br>
    #05 pc 0003d38b  /data/app/org.smalltalk.androi<wbr>d-2/lib/arm/libStackVM.so (interpret+238)<br>
    #06 pc 000a4e6f  /data/app/org.smalltalk.androi<wbr>d-2/lib/arm/libStackVM.so (runVM+22)<br>
    #07 pc 000a4a55  /data/app/org.smalltalk.androi<wbr>d-2/lib/arm/libStackVM.so (Java_org_smalltalk_android_vm<wbr>_VM_runVM+36)<br>
    #08 pc 0031ec99  /data/app/org.smalltalk.androi<wbr>d-2/oat/arm/base.odex (offset 0x302000)<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="gmail-HOEnZb"><font color="#888888">-- <br><div class="gmail-m_3223995976436957507gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</font></span></div>
</blockquote></div><br></div></div>