Reviving the Android VM

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Reviving the Android VM

Michael Rueger
 
Hi all,

long time no see :-)

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.

Current (somewhat messy) state of things here
https://github.com/mrueger42/st-android

It has been quite a long time since I looked at building VMs, so forgive me if I'm just being stupid here...

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).

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).

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.

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...

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).

Any help, pointers, code snippets highly appreciated!

Cheers

Michael

P.S. Sending this to vm-dev and pharo-dev, but should probably send any followup to vm-dev?

--------


list of sources I looked at:

-opensmalltalk
-pharo

-original port by Andreas
[hidden email]:timfel/squeak-android-vm.git

-stack
https://github.com/sbragagnolo/pharo-vm/

-dmitry
gitorious is no longer, just an archival snapshot
clicking on snapshot gives you the sources
https://gitorious.org/cogvm/dmg-blessed?p=cogvm:dmg-blessed.git;a=summary
non-functional jenkins setup
https://ci.inria.fr/pharo-contribution/view/VM/job/CogDroid/configure-readonly/



-------------

The Cog VM crash when running on a Thread:


D/jni-vm: Java_org_smalltalk_android_vm_VM_runVM
D/jni-vm: runVM
D/jni-vm: interpret

A/libc: Fatal signal 8 (SIGFPE), code -6, fault addr 0x67db in tid 26636 (Thread-5)

Revision: '6'
ABI: 'arm'
pid: 26587, tid: 26636, name: Thread-5  >>> org.smalltalk.android <<<
signal 8 (SIGFPE), code -6 (SI_TKILL), fault addr 0x67db
     r0 00000000  r1 0000680c  r2 00000008  r3 00000000
     r4 e4f7f978  r5 00000008  r6 e4f7f920  r7 0000010c
     r8 e4f7ef60  r9 e3516400  sl e351648c  fp e4f7ecb4
     ip 00000002  sp e4f7ce30  lr efca84c7  pc efcaad30  cpsr 600e0010

backtrace:
     #00 pc 0004ad30  /system/lib/libc.so (tgkill+12)
     #01 pc 000484c3  /system/lib/libc.so (pthread_kill+34)
     #02 pc 0001dd99  /system/lib/libc.so (raise+10)
     #03 pc 000c54a3  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so
     #04 pc 00051507  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so
     #05 pc 0003d38b  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so (interpret+238)
     #06 pc 000a4e6f  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so (runVM+22)
     #07 pc 000a4a55  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so (Java_org_smalltalk_android_vm_VM_runVM+36)
     #08 pc 0031ec99  /data/app/org.smalltalk.android-2/oat/arm/base.odex (offset 0x302000)

Reply | Threaded
Open this post in threaded view
|

Re: Reviving the Android VM

Denis Kudriashov
 

2017-06-16 21:48 GMT+02:00 Michael Rueger <[hidden email]>:

Hi all,

long time no see :-)

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.

Current (somewhat messy) state of things here
https://github.com/mrueger42/st-android

It has been quite a long time since I looked at building VMs, so forgive me if I'm just being stupid here...

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).

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).

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.

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...

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).

Any help, pointers, code snippets highly appreciated!

Cheers

Michael

P.S. Sending this to vm-dev and pharo-dev, but should probably send any followup to vm-dev?

--------


list of sources I looked at:

-opensmalltalk
-pharo

-original port by Andreas
[hidden email]:timfel/squeak-android-vm.git

-stack
https://github.com/sbragagnolo/pharo-vm/

-dmitry
gitorious is no longer, just an archival snapshot
clicking on snapshot gives you the sources
https://gitorious.org/cogvm/dmg-blessed?p=cogvm:dmg-blessed.git;a=summary
non-functional jenkins setup
https://ci.inria.fr/pharo-contribution/view/VM/job/CogDroid/configure-readonly/



-------------

The Cog VM crash when running on a Thread:


D/jni-vm: Java_org_smalltalk_android_vm_VM_runVM
D/jni-vm: runVM
D/jni-vm: interpret

A/libc: Fatal signal 8 (SIGFPE), code -6, fault addr 0x67db in tid 26636 (Thread-5)

Revision: '6'
ABI: 'arm'
pid: 26587, tid: 26636, name: Thread-5  >>> org.smalltalk.android <<<
signal 8 (SIGFPE), code -6 (SI_TKILL), fault addr 0x67db
    r0 00000000  r1 0000680c  r2 00000008  r3 00000000
    r4 e4f7f978  r5 00000008  r6 e4f7f920  r7 0000010c
    r8 e4f7ef60  r9 e3516400  sl e351648c  fp e4f7ecb4
    ip 00000002  sp e4f7ce30  lr efca84c7  pc efcaad30  cpsr 600e0010

backtrace:
    #00 pc 0004ad30  /system/lib/libc.so (tgkill+12)
    #01 pc 000484c3  /system/lib/libc.so (pthread_kill+34)
    #02 pc 0001dd99  /system/lib/libc.so (raise+10)
    #03 pc 000c54a3  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so
    #04 pc 00051507  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so
    #05 pc 0003d38b  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so (interpret+238)
    #06 pc 000a4e6f  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so (runVM+22)
    #07 pc 000a4a55  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so (Java_org_smalltalk_android_vm_VM_runVM+36)
    #08 pc 0031ec99  /data/app/org.smalltalk.android-2/oat/arm/base.odex (offset 0x302000)


Reply | Threaded
Open this post in threaded view
|

Re: Reviving the Android VM

David T. Lewis
In reply to this post by Michael Rueger
 
Hi Michael,

Nice to see you here :-)

I am CCing squeak-dev because there is likely to be interest there, and some
historical expertise also.

Yes, vm-dev is a good place for follow ups.

Dave


On Sat, Jun 17, 2017 at 07:48:31AM +1200, Michael Rueger wrote:

>
> Hi all,
>
> long time no see :-)
>
> 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.
>
> Current (somewhat messy) state of things here
> https://github.com/mrueger42/st-android
>
> It has been quite a long time since I looked at building VMs, so forgive me
> if I'm just being stupid here...
>
> 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).
>
> 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).
>
> 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.
>
> 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...
>
> 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).
>
> Any help, pointers, code snippets highly appreciated!
>
> Cheers
>
> Michael
>
> P.S. Sending this to vm-dev and pharo-dev, but should probably send any
> followup to vm-dev?
>
> --------
>
>
> list of sources I looked at:
>
> -opensmalltalk
> -pharo
>
> -original port by Andreas
> [hidden email]:timfel/squeak-android-vm.git
>
> -stack
> https://github.com/sbragagnolo/pharo-vm/
>
> -dmitry
> gitorious is no longer, just an archival snapshot
> clicking on snapshot gives you the sources
> https://gitorious.org/cogvm/dmg-blessed?p=cogvm:dmg-blessed.git;a=summary
> non-functional jenkins setup
> https://ci.inria.fr/pharo-contribution/view/VM/job/CogDroid/configure-readonly/
>
>
>
> -------------
>
> The Cog VM crash when running on a Thread:
>
>
> D/jni-vm: Java_org_smalltalk_android_vm_VM_runVM
> D/jni-vm: runVM
> D/jni-vm: interpret
>
> A/libc: Fatal signal 8 (SIGFPE), code -6, fault addr 0x67db in tid 26636
> (Thread-5)
>
> Revision: '6'
> ABI: 'arm'
> pid: 26587, tid: 26636, name: Thread-5  >>> org.smalltalk.android <<<
> signal 8 (SIGFPE), code -6 (SI_TKILL), fault addr 0x67db
>     r0 00000000  r1 0000680c  r2 00000008  r3 00000000
>     r4 e4f7f978  r5 00000008  r6 e4f7f920  r7 0000010c
>     r8 e4f7ef60  r9 e3516400  sl e351648c  fp e4f7ecb4
>     ip 00000002  sp e4f7ce30  lr efca84c7  pc efcaad30  cpsr 600e0010
>
> backtrace:
>     #00 pc 0004ad30  /system/lib/libc.so (tgkill+12)
>     #01 pc 000484c3  /system/lib/libc.so (pthread_kill+34)
>     #02 pc 0001dd99  /system/lib/libc.so (raise+10)
>     #03 pc 000c54a3  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so
>     #04 pc 00051507  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so
>     #05 pc 0003d38b  
>     /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so (interpret+238)
>     #06 pc 000a4e6f  
>     /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so (runVM+22)
>     #07 pc 000a4a55  
>     /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so
>     (Java_org_smalltalk_android_vm_VM_runVM+36)
>     #08 pc 0031ec99  /data/app/org.smalltalk.android-2/oat/arm/base.odex
>     (offset 0x302000)
>
Reply | Threaded
Open this post in threaded view
|

Re: Reviving the Android VM

Eliot Miranda-2
In reply to this post by Michael Rueger
 
Hi Michael,

    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

$ diff build.linux32ARMv*/HowToBuild
1c1
< How To Build On Linux ARMv6 (i.e. Raspbian for Raspberry Pi (*))
---
> How To Build On Linux ARM v7 (e.g. Android devices (*))
...

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
CC="gcc -march=armv6 -mfpu=vfp -mfloat-abi=hard"
and in the v7/Android build we use no such settings.

Right now there are only newspeak builds for Android (build.linux32ARMv7/{newspeak.cog.spur,newspeak.stack.spur}, but if you copy across build.linux32ARMv6/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.

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.

On Fri, Jun 16, 2017 at 12:48 PM, Michael Rueger <[hidden email]> wrote:

Hi all,

long time no see :-)

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.

Current (somewhat messy) state of things here
https://github.com/mrueger42/st-android

It has been quite a long time since I looked at building VMs, so forgive me if I'm just being stupid here...

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).

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).

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.

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...

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).

Any help, pointers, code snippets highly appreciated!

Cheers

Michael

P.S. Sending this to vm-dev and pharo-dev, but should probably send any followup to vm-dev?

--------


list of sources I looked at:

-opensmalltalk
-pharo

-original port by Andreas
[hidden email]:timfel/squeak-android-vm.git

-stack
https://github.com/sbragagnolo/pharo-vm/

-dmitry
gitorious is no longer, just an archival snapshot
clicking on snapshot gives you the sources
https://gitorious.org/cogvm/dmg-blessed?p=cogvm:dmg-blessed.git;a=summary
non-functional jenkins setup
https://ci.inria.fr/pharo-contribution/view/VM/job/CogDroid/configure-readonly/



-------------

The Cog VM crash when running on a Thread:


D/jni-vm: Java_org_smalltalk_android_vm_VM_runVM
D/jni-vm: runVM
D/jni-vm: interpret

A/libc: Fatal signal 8 (SIGFPE), code -6, fault addr 0x67db in tid 26636 (Thread-5)

Revision: '6'
ABI: 'arm'
pid: 26587, tid: 26636, name: Thread-5  >>> org.smalltalk.android <<<
signal 8 (SIGFPE), code -6 (SI_TKILL), fault addr 0x67db
    r0 00000000  r1 0000680c  r2 00000008  r3 00000000
    r4 e4f7f978  r5 00000008  r6 e4f7f920  r7 0000010c
    r8 e4f7ef60  r9 e3516400  sl e351648c  fp e4f7ecb4
    ip 00000002  sp e4f7ce30  lr efca84c7  pc efcaad30  cpsr 600e0010

backtrace:
    #00 pc 0004ad30  /system/lib/libc.so (tgkill+12)
    #01 pc 000484c3  /system/lib/libc.so (pthread_kill+34)
    #02 pc 0001dd99  /system/lib/libc.so (raise+10)
    #03 pc 000c54a3  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so
    #04 pc 00051507  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so
    #05 pc 0003d38b  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so (interpret+238)
    #06 pc 000a4e6f  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so (runVM+22)
    #07 pc 000a4a55  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so (Java_org_smalltalk_android_vm_VM_runVM+36)
    #08 pc 0031ec99  /data/app/org.smalltalk.android-2/oat/arm/base.odex (offset 0x302000)




--
_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|

Re: Reviving the Android VM

Ryan Macnak
 
Hi Michael, Eliot,

On Tue, Jun 20, 2017 at 10:08 AM, Eliot Miranda <[hidden email]> wrote:
Hi Michael,

    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

$ diff build.linux32ARMv*/HowToBuild
1c1
< How To Build On Linux ARMv6 (i.e. Raspbian for Raspberry Pi (*))
---
> How To Build On Linux ARM v7 (e.g. Android devices (*))
...

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
CC="gcc -march=armv6 -mfpu=vfp -mfloat-abi=hard"
and in the v7/Android build we use no such settings.

Right now there are only newspeak builds for Android (build.linux32ARMv7/{newspeak.cog.spur,newspeak.stack.spur}, but if you copy across build.linux32ARMv6/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.

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.

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.

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.
 
On Fri, Jun 16, 2017 at 12:48 PM, Michael Rueger <[hidden email]> wrote:

Hi all,

long time no see :-)

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.

Current (somewhat messy) state of things here
https://github.com/mrueger42/st-android

It has been quite a long time since I looked at building VMs, so forgive me if I'm just being stupid here...

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).

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).

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.

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...

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).

Any help, pointers, code snippets highly appreciated!

Cheers

Michael

P.S. Sending this to vm-dev and pharo-dev, but should probably send any followup to vm-dev?

--------


list of sources I looked at:

-opensmalltalk
-pharo

-original port by Andreas
[hidden email]:timfel/squeak-android-vm.git

-stack
https://github.com/sbragagnolo/pharo-vm/

-dmitry
gitorious is no longer, just an archival snapshot
clicking on snapshot gives you the sources
https://gitorious.org/cogvm/dmg-blessed?p=cogvm:dmg-blessed.git;a=summary
non-functional jenkins setup
https://ci.inria.fr/pharo-contribution/view/VM/job/CogDroid/configure-readonly/



-------------

The Cog VM crash when running on a Thread:


D/jni-vm: Java_org_smalltalk_android_vm_VM_runVM
D/jni-vm: runVM
D/jni-vm: interpret

A/libc: Fatal signal 8 (SIGFPE), code -6, fault addr 0x67db in tid 26636 (Thread-5)

Revision: '6'
ABI: 'arm'
pid: 26587, tid: 26636, name: Thread-5  >>> org.smalltalk.android <<<
signal 8 (SIGFPE), code -6 (SI_TKILL), fault addr 0x67db
    r0 00000000  r1 0000680c  r2 00000008  r3 00000000
    r4 e4f7f978  r5 00000008  r6 e4f7f920  r7 0000010c
    r8 e4f7ef60  r9 e3516400  sl e351648c  fp e4f7ecb4
    ip 00000002  sp e4f7ce30  lr efca84c7  pc efcaad30  cpsr 600e0010

backtrace:
    #00 pc 0004ad30  /system/lib/libc.so (tgkill+12)
    #01 pc 000484c3  /system/lib/libc.so (pthread_kill+34)
    #02 pc 0001dd99  /system/lib/libc.so (raise+10)
    #03 pc 000c54a3  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so
    #04 pc 00051507  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so
    #05 pc 0003d38b  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so (interpret+238)
    #06 pc 000a4e6f  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so (runVM+22)
    #07 pc 000a4a55  /data/app/org.smalltalk.android-2/lib/arm/libStackVM.so (Java_org_smalltalk_android_vm_VM_runVM+36)
    #08 pc 0031ec99  /data/app/org.smalltalk.android-2/oat/arm/base.odex (offset 0x302000)




--
_,,,^..^,,,_
best, Eliot

Reply | Threaded
Open this post in threaded view
|

Re: Reviving the Android VM

Michael Rueger
 
Hi Ryan,

> 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,

thank you for the insight!
Yes, that is why I started to pull the build directly into AndroidStudio and building with the CMake toolchain. Google
still supports the .mk based builds, but they are on their way out. Also the newer NDKs seem to work quite differently
from older ones, so most of the builds I found based on old -sometimes really old- NKD versions just won't build anymore.

> 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.

Yes, that is the tricky part. As I mentioned, I got the VM  basically working, but as it is crashing when running on a
background thread I'm stuck. By working I mean it is running, even making display callbacks into Android. But as it is
blocking the UI thread, it's not very useful...

>     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.

Dmitry's VM seems to be event-driven, still need to try to get that to build.

Cheers

Michael
Reply | Threaded
Open this post in threaded view
|

Re: Reviving the Android VM

EstebanLM
 
Hi, 

I guess the most advanced ARM vm now are the ARMv6 and ARMv7 builds from osvm, but for Android you need several other things. 
Some other work besides the original has been done to adapt the vm to android which you can take a look too, notably the work by Santiago (which is based on work from JB), that can be found here: https://github.com/sbragagnolo/pharo-vm (but is based in old pharo-vm, before we re-joined with osvm). 

Also, no VM for android has solved what is the most important piece missing to do something for real on Android: the VM needs to be an “idle VM” (a vm that goes idle when not used), so it can be run as android wants, not killing the battery of the portable :)
Also, IMO it would be nice to incorporate the work from Ronnie (I think is here: https://github.com/ronsaldo/opensmalltalk-vm) to strip out the display from VM (Display initialisation should be a decision of the image, after all), which would put us closer to have an “embeddable vm”, and that can lead to very cool applications in the mobile world. 

yes, I didn’t help here, just added more complexity… but well, I’m trying to add elements to analyse ;)

cheers, 
Esteban


On 21 Jun 2017, at 05:22, Michael Rueger <[hidden email]> wrote:

Hi Ryan,

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,

thank you for the insight!
Yes, that is why I started to pull the build directly into AndroidStudio and building with the CMake toolchain. Google still supports the .mk based builds, but they are on their way out. Also the newer NDKs seem to work quite differently from older ones, so most of the builds I found based on old -sometimes really old- NKD versions just won't build anymore.

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.

Yes, that is the tricky part. As I mentioned, I got the VM  basically working, but as it is crashing when running on a background thread I'm stuck. By working I mean it is running, even making display callbacks into Android. But as it is blocking the UI thread, it's not very useful...

   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.

Dmitry's VM seems to be event-driven, still need to try to get that to build.

Cheers

Michael

Reply | Threaded
Open this post in threaded view
|

Re: Reviving the Android VM

Ben Coman
In reply to this post by Michael Rueger
 


On Sat, Jun 17, 2017 at 3:48 AM, Michael Rueger <[hidden email]> wrote:

Hi all,

long time no see :-)

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.

Current (somewhat messy) state of things here
https://github.com/mrueger42/st-android

It has been quite a long time since I looked at building VMs, so forgive me if I'm just being stupid here...

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).

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).

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.

Maybe of interest is Ronnie's work towards an embeddable VM...
 
cheers -ben