[ANN] PharoNOS

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

[ANN] PharoNOS

jan.struz
Hi,
I successfully ported SqueakNOS to Pharo, and want to share it with you!
It works with Pharo 4.0 image, networking included, ping works!

What is different:
- I use my own CMake build file, with "out-of-tree" build support, instead of "build.xyz" directories inside source tree + some template scripts to build any VM type, but it is not complete...
- I use MUSL instead of GlibC, cross-compiling GlibC statically on 64bit for 32bit seems impossible, but anyway I use 32bit environment to build it
- It works with pre-opensmalltalk-vm migration directory structure, so the "sync" with latest trunk remains #TODO, or maybe start a new branch again from the latest upstream commit should work too
- freetype is included, but will not load any fonts, since the filesystem driver is image-side... so you will need to make new fonts embedded, if you want them
- known issues: image snapshot and fileout are not working, current date+time hacked to make fat32 timestamps work
- revision needed: timer (heartbeat) vs. GC vs. interrupts enable/disable
- there are even some hacks to image-side methods

PharoNOS platform directory sources: [pharonos branch]
SRC: https://gitlab.com/johnnyzz/pharonos

VM sources: [dev branch]
SRC: https://gitlab.com/johnnyzz/pharo-vm
- added platform directory, build scripts and CMake templates
- added VMMaker configs

Build Environment (32bit) - Docker image repository, with CI:
https://gitlab.com/johnnyzz/dev-build

PharoNOS CI (uses previous Docker image):
CI: https://gitlab.com/johnnyzz/pharo-nos-build

How to run it:
You can download fresh disk image from CI and then run:
(sudo) kvm -hda build/NOS.img -enable-kvm -cpu kvm32 -vga qxl -m 256 -netdev tap,id=user.3,ifname=tap2,vhost=on -net nic,model=rtl8139,netdev=user.3 -global isa-fdc.driveA= -serial stdio

One more thing:
Statically linked Pharo Spur32 (headless) VM, with only one dependency - Linux kernel:
CI: https://gitlab.com/johnnyzz/pharo-build-static
Size: 2,4MB (too big?, but Freetype included too!)

enjoy

Jan
Save The World!
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] PharoNOS

jan.struz
I forgot, the source points to repository @ smalltalkhub
http://smalltalkhub.com/#!/~JanStruz/PharoNOS/
Save The World!
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] PharoNOS

stepharong
In reply to this post by jan.struz
Thanks Jan

This is super coooooooooooooooooooooooooooooooooooooooooooooooooool :)
Since we are bootstrapping a kernel for Pharo70. 
And we can really get much smaller images in the future, let us know if you want a special image. 
Jonathan is working on making sure than other people than guille can use the process. 

Stef


On Sun, 19 Mar 2017 00:30:40 +0100, jan.struz <[hidden email]> wrote:

Hi,
I successfully ported SqueakNOS to Pharo, and want to share it with you!
It works with Pharo 4.0 image, networking included, ping works!

What is different:
- I use my own CMake build file, with "out-of-tree" build support, instead of "build.xyz" directories inside source tree + some template scripts to build any VM type, but it is not complete...
- I use MUSL instead of GlibC, cross-compiling GlibC statically on 64bit for 32bit seems impossible, but anyway I use 32bit environment to build it
- It works with pre-opensmalltalk-vm migration directory structure, so the "sync" with latest trunk remains #TODO, or maybe start a new branch again from the latest upstream commit should work too
- freetype is included, but will not load any fonts, since the filesystem driver is image-side... so you will need to make new fonts embedded, if you want them
- known issues: image snapshot and fileout are not working, current date+time hacked to make fat32 timestamps work
- revision needed: timer (heartbeat) vs. GC vs. interrupts enable/disable
- there are even some hacks to image-side methods

PharoNOS platform directory sources: [pharonos branch]
SRC: https://gitlab.com/johnnyzz/pharonos

VM sources: [dev branch]
SRC: https://gitlab.com/johnnyzz/pharo-vm
- added platform directory, build scripts and CMake templates
- added VMMaker configs

Build Environment (32bit) - Docker image repository, with CI:
https://gitlab.com/johnnyzz/dev-build

PharoNOS CI (uses previous Docker image):
CI: https://gitlab.com/johnnyzz/pharo-nos-build

How to run it:
You can download fresh disk image from CI and then run:
(sudo) kvm -hda build/NOS.img -enable-kvm -cpu kvm32 -vga qxl -m 256 -netdev tap,id=user.3,ifname=tap2,vhost=on -net nic,model=rtl8139,netdev=user.3 -global isa-fdc.driveA= -serial stdio

One more thing:
Statically linked Pharo Spur32 (headless) VM, with only one dependency - Linux kernel:
CI: https://gitlab.com/johnnyzz/pharo-build-static
Size: 2,4MB (too big?, but Freetype included too!)

enjoy

Jan
Save The World!


View this message in context: [ANN] PharoNOS
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.



--
Using Opera's mail client: http://www.opera.com/mail/
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] PharoNOS

Denis Kudriashov
In reply to this post by jan.struz
Hi.

How difficult it would be to support ARM processor?

2017-03-19 0:30 GMT+01:00 jan.struz <[hidden email]>:
Hi,
I successfully ported SqueakNOS to Pharo, and want to share it with you!
It works with Pharo 4.0 image, networking included, ping works!

What is different:
- I use my own CMake build file, with "out-of-tree" build support, instead of "build.xyz" directories inside source tree + some template scripts to build any VM type, but it is not complete...
- I use MUSL instead of GlibC, cross-compiling GlibC statically on 64bit for 32bit seems impossible, but anyway I use 32bit environment to build it
- It works with pre-opensmalltalk-vm migration directory structure, so the "sync" with latest trunk remains #TODO, or maybe start a new branch again from the latest upstream commit should work too
- freetype is included, but will not load any fonts, since the filesystem driver is image-side... so you will need to make new fonts embedded, if you want them
- known issues: image snapshot and fileout are not working, current date+time hacked to make fat32 timestamps work
- revision needed: timer (heartbeat) vs. GC vs. interrupts enable/disable
- there are even some hacks to image-side methods

PharoNOS platform directory sources: [pharonos branch]
SRC: https://gitlab.com/johnnyzz/pharonos

VM sources: [dev branch]
SRC: https://gitlab.com/johnnyzz/pharo-vm
- added platform directory, build scripts and CMake templates
- added VMMaker configs

Build Environment (32bit) - Docker image repository, with CI:
https://gitlab.com/johnnyzz/dev-build

PharoNOS CI (uses previous Docker image):
CI: https://gitlab.com/johnnyzz/pharo-nos-build

How to run it:
You can download fresh disk image from CI and then run:
(sudo) kvm -hda build/NOS.img -enable-kvm -cpu kvm32 -vga qxl -m 256 -netdev tap,id=user.3,ifname=tap2,vhost=on -net nic,model=rtl8139,netdev=user.3 -global isa-fdc.driveA= -serial stdio

One more thing:
Statically linked Pharo Spur32 (headless) VM, with only one dependency - Linux kernel:
CI: https://gitlab.com/johnnyzz/pharo-build-static
Size: 2,4MB (too big?, but Freetype included too!)

enjoy

Jan
Save The World!


View this message in context: [ANN] PharoNOS
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] PharoNOS

Damien Pollet
Is it specific to KVM, or is it possible to run it on top of different hypervisors?
E.g. is it possible to make a demo VirtualBox image, or to launch PharoNOS as a Docker container?

On 19 March 2017 at 15:33, Denis Kudriashov <[hidden email]> wrote:
Hi.

How difficult it would be to support ARM processor?

2017-03-19 0:30 GMT+01:00 jan.struz <[hidden email]>:
Hi,
I successfully ported SqueakNOS to Pharo, and want to share it with you!
It works with Pharo 4.0 image, networking included, ping works!

What is different:
- I use my own CMake build file, with "out-of-tree" build support, instead of "build.xyz" directories inside source tree + some template scripts to build any VM type, but it is not complete...
- I use MUSL instead of GlibC, cross-compiling GlibC statically on 64bit for 32bit seems impossible, but anyway I use 32bit environment to build it
- It works with pre-opensmalltalk-vm migration directory structure, so the "sync" with latest trunk remains #TODO, or maybe start a new branch again from the latest upstream commit should work too
- freetype is included, but will not load any fonts, since the filesystem driver is image-side... so you will need to make new fonts embedded, if you want them
- known issues: image snapshot and fileout are not working, current date+time hacked to make fat32 timestamps work
- revision needed: timer (heartbeat) vs. GC vs. interrupts enable/disable
- there are even some hacks to image-side methods

PharoNOS platform directory sources: [pharonos branch]
SRC: https://gitlab.com/johnnyzz/pharonos

VM sources: [dev branch]
SRC: https://gitlab.com/johnnyzz/pharo-vm
- added platform directory, build scripts and CMake templates
- added VMMaker configs

Build Environment (32bit) - Docker image repository, with CI:
https://gitlab.com/johnnyzz/dev-build

PharoNOS CI (uses previous Docker image):
CI: https://gitlab.com/johnnyzz/pharo-nos-build

How to run it:
You can download fresh disk image from CI and then run:
(sudo) kvm -hda build/NOS.img -enable-kvm -cpu kvm32 -vga qxl -m 256 -netdev tap,id=user.3,ifname=tap2,vhost=on -net nic,model=rtl8139,netdev=user.3 -global isa-fdc.driveA= -serial stdio

One more thing:
Statically linked Pharo Spur32 (headless) VM, with only one dependency - Linux kernel:
CI: https://gitlab.com/johnnyzz/pharo-build-static
Size: 2,4MB (too big?, but Freetype included too!)

enjoy

Jan
Save The World!


View this message in context: [ANN] PharoNOS
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.




--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] PharoNOS

jan.struz
Hi Damien,
I just tried it under Virtualbox. The disk image is RAW format, it should run everywhere, but VB is dumb, you need to convert it first. And the size is not divisible by 512, so can't even convert it with VB tools...
qemu-img convert -f raw -O vmdk NOS.img NOS.vmdk
But current PharoNOS version supports only "Realtek8139" network card, and I don't see it in Virtualbox...
You should set the pointing device to PS/2 (mouse), not USB, but I personally don't see the cursor either then...

Docker relies on Linux kernel, but PharoNOS has its own kernel, so you can't run it there.
But, if you want, you can use the last link, with statically linked (single binary) version of Pharo Spur VM, which works in Docker! In addition to this, you will need only Pharo image, changes and sources.
Regarding the ARM version, Denis, I don't know, there are many inlined assembler x86 instructions, I don't know how virtual memory works on ARM. I think some refactoring is needed first, to support multiple processors.
Save The World!
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] PharoNOS

jan.struz
In reply to this post by stepharong
Hi Stef,
what I want, is NativeBoost for Pharo 5+. Because we could do this:

primInPortByte: portNumber 
	<primitive: 'primitiveNativeCall' module: 'NativeBoostPlugin' error: errorCode>

	^ self nbCallout function: #(uint8 ( uint16 portNumber )) emit: [:gen | 
			| asm result proxy | 
			asm := gen asm.
			proxy := gen proxy.
			result := gen reserveTemp.
			asm
				pop: asm EDX;	"EDX = portNumber"
				push: asm EDI;	"save EDI"
				mov: result to: asm EDI; "EDI = temp address for result"
				db: 16rEC;		"IN AL, DX"
				pop: asm EDI.  "restore EDI"
			gen releaseTemps: 1.
		].

This is a rewrite of one method from C source(calling asm) in internal SqueakNOSPlugin into NativeBoost Smalltalk code. It calls privileged (kernel mode only) instruction to directly access HW I/O - disk access.
I have tried to run it, and it worked fine. However there is one little problem. NativeBoost needs method source, which is stored where? On the disk it wants to access... Solution - the source code can be embedded into compiled method trailer - this is only way to make it work. The first run will generate native code, and replaces the embedded source, so you can't touch the method anymore (at runtime)... so it is not perfect.
This is how SqueakNOSPlugin can be removed entirelly. But I'm afraid nobody can play with it in Pharo7 images...
Save The World!
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] PharoNOS

EstebanLM

On 19 Mar 2017, at 21:46, jan.struz <[hidden email]> wrote:

Hi Stef,
what I want, is NativeBoost for Pharo 5+. Because we could do this:

primInPortByte: portNumber 
	<primitive: 'primitiveNativeCall' module: 'NativeBoostPlugin' error: errorCode>

	^ self nbCallout function: #(uint8 ( uint16 portNumber )) emit: [:gen | 
			| asm result proxy | 
			asm := gen asm.
			proxy := gen proxy.
			result := gen reserveTemp.
			asm
				pop: asm EDX;	"EDX = portNumber"
				push: asm EDI;	"save EDI"
				mov: result to: asm EDI; "EDI = temp address for result"
				db: 16rEC;		"IN AL, DX"
				pop: asm EDI.  "restore EDI"
			gen releaseTemps: 1.
		].

This is a rewrite of one method from C source(calling asm) in internal SqueakNOSPlugin into NativeBoost Smalltalk code. It calls privileged (kernel mode only) instruction to directly access HW I/O - disk access.
I have tried to run it, and it worked fine. However there is one little problem. NativeBoost needs method source, which is stored where? On the disk it wants to access... Solution - the source code can be embedded into compiled method trailer - this is only way to make it work. The first run will generate native code, and replaces the embedded source, so you can't touch the method anymore (at runtime)... so it is not perfect.
This is how SqueakNOSPlugin can be removed entirelly. But I'm afraid nobody can play with it in Pharo7 images…

well… NB for Pharo5 will not be there unless someone takes it and make it work. 
And even then, it will not go back to the image… but it would be very nice to have it as a loadable package. 

Now, to make it work “as is” on Pharo5+ you will also need to modify somethings in the VM, for example make the memory executable… and there are security observations against it so the “original” way will need an important refactor (to execute NB methods in a special segment).

And I’m sure there are a lot of more stuff there I’m not thinking about, being 8:30am here ;)

Esteban

Save The World!


View this message in context: Re: [ANN] PharoNOS
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] PharoNOS

Eliot Miranda-2
In reply to this post by jan.struz
Hi Jan,

On Sun, Mar 19, 2017 at 1:46 PM, jan.struz <[hidden email]> wrote:
Hi Stef,
what I want, is NativeBoost for Pharo 5+. Because we could do this:

primInPortByte: portNumber 
	<primitive: 'primitiveNativeCall' module: 'NativeBoostPlugin' error: errorCode>

	^ self nbCallout function: #(uint8 ( uint16 portNumber )) emit: [:gen | 
			| asm result proxy | 
			asm := gen asm.
			proxy := gen proxy.
			result := gen reserveTemp.
			asm
				pop: asm EDX;	"EDX = portNumber"
				push: asm EDI;	"save EDI"
				mov: result to: asm EDI; "EDI = temp address for result"
				db: 16rEC;		"IN AL, DX"
				pop: asm EDI.  "restore EDI"
			gen releaseTemps: 1.
		].

This is a rewrite of one method from C source(calling asm) in internal SqueakNOSPlugin into NativeBoost Smalltalk code. It calls privileged (kernel mode only) instruction to directly access HW I/O - disk access.
I have tried to run it, and it worked fine. However there is one little problem. NativeBoost needs method source, which is stored where? On the disk it wants to access... Solution - the source code can be embedded into compiled method trailer - this is only way to make it work. The first run will generate native code, and replaces the embedded source, so you can't touch the method anymore (at runtime)... so it is not perfect.
This is how SqueakNOSPlugin can be removed entirelly. But I'm afraid nobody can play with it in Pharo7 images...

Can you not use the new UnifiedFFI which uses the ThreadedFFIPlugin at the bottom level?
 
Save The World!


View this message in context: Re: [ANN] PharoNOS



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

Re: [ANN] PharoNOS

Hernan Wilkinson-3
In reply to this post by jan.struz
Hi Jan,
 I feel kind of stupid but I can not find how to download a disk image to bootstrap... I don't see them on gitlab, could you give me a hint? :-)

Thanks!
Hernan.

On Sat, Mar 18, 2017 at 8:30 PM, jan.struz <[hidden email]> wrote:
Hi,
I successfully ported SqueakNOS to Pharo, and want to share it with you!
It works with Pharo 4.0 image, networking included, ping works!

What is different:
- I use my own CMake build file, with "out-of-tree" build support, instead of "build.xyz" directories inside source tree + some template scripts to build any VM type, but it is not complete...
- I use MUSL instead of GlibC, cross-compiling GlibC statically on 64bit for 32bit seems impossible, but anyway I use 32bit environment to build it
- It works with pre-opensmalltalk-vm migration directory structure, so the "sync" with latest trunk remains #TODO, or maybe start a new branch again from the latest upstream commit should work too
- freetype is included, but will not load any fonts, since the filesystem driver is image-side... so you will need to make new fonts embedded, if you want them
- known issues: image snapshot and fileout are not working, current date+time hacked to make fat32 timestamps work
- revision needed: timer (heartbeat) vs. GC vs. interrupts enable/disable
- there are even some hacks to image-side methods

PharoNOS platform directory sources: [pharonos branch]
SRC: https://gitlab.com/johnnyzz/pharonos

VM sources: [dev branch]
SRC: https://gitlab.com/johnnyzz/pharo-vm
- added platform directory, build scripts and CMake templates
- added VMMaker configs

Build Environment (32bit) - Docker image repository, with CI:
https://gitlab.com/johnnyzz/dev-build

PharoNOS CI (uses previous Docker image):
CI: https://gitlab.com/johnnyzz/pharo-nos-build

How to run it:
You can download fresh disk image from CI and then run:
(sudo) kvm -hda build/NOS.img -enable-kvm -cpu kvm32 -vga qxl -m 256 -netdev tap,id=user.3,ifname=tap2,vhost=on -net nic,model=rtl8139,netdev=user.3 -global isa-fdc.driveA= -serial stdio

One more thing:
Statically linked Pharo Spur32 (headless) VM, with only one dependency - Linux kernel:
CI: https://gitlab.com/johnnyzz/pharo-build-static
Size: 2,4MB (too big?, but Freetype included too!)

enjoy

Jan
Save The World!


View this message in context: [ANN] PharoNOS
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.



--
Hernán Wilkinson
Agile Software Development, Teaching & Coaching
Phone: +54-011-4893-2057
Twitter: @HernanWilkinson
Address: Alem 896, Floor 6, Buenos Aires, Argentina
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] PharoNOS

jan.struz
Hi Hernan,
the disk image is built on CI, you can find it under "Pipelines", go to https://gitlab.com/johnnyzz/pharo-nos-build/pipelines and you will see the download button ("Download artifacts").
The archive contains the raw disk image, and the .kernel file.
The "dev-build" project, you requested access to, is intended to build a "Docker image" with the build environment, if you had problem there, it was because I forgot to allow public access to this repository. It is now fixed.
Jan
Save The World!
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] PharoNOS

Hernan Wilkinson-3
Hi Jan,
 I tried to download the artifacts but I get a 404 error (the link related with the "Download artifacts" is https://gitlab.com/johnnyzz/pharo-nos-build/builds/12516481/artifacts/download)...

On Wed, Mar 22, 2017 at 10:52 AM, jan.struz <[hidden email]> wrote:
Hi Hernan,
the disk image is built on CI, you can find it under "Pipelines", go to https://gitlab.com/johnnyzz/pharo-nos-build/pipelines and you will see the download button ("Download artifacts").
The archive contains the raw disk image, and the .kernel file.
The "dev-build" project, you requested access to, is intended to build a "Docker image" with the build environment, if you had problem there, it was because I forgot to allow public access to this repository. It is now fixed.
Jan
Save The World!


View this message in context: Re: [ANN] PharoNOS



--
Hernán Wilkinson
Agile Software Development, Teaching & Coaching
Phone: +54-011-4893-2057
Twitter: @HernanWilkinson
Address: Alem 896, Floor 6, Buenos Aires, Argentina
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] PharoNOS

jan.struz
It is working now, thanks for feedback.
Link here - Download the latest build artifact for PharoNOS
Save The World!
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] PharoNOS

melkyades
Cool!!! I just tried and loads nicely :))).

For the curious, easy way to test (ubuntu 16.04):

you'll need qemu (sudo apt-get install qemu)

unzip
chmod +x NOS.img
qemu-system-i386 NOS.img
enjoy!

Cheers!!!
Pocho

On Wed, Mar 22, 2017 at 12:40 PM, jan.struz <[hidden email]> wrote:
It is working now, thanks for feedback.
Link here - Download the latest build artifact for PharoNOS
Save The World!


View this message in context: Re: [ANN] PharoNOS
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.



--
Javier Pimás
Ciudad de Buenos Aires
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] PharoNOS

Igor Stasenko

Hey, guys, i'd like to stress, that AsmJit 
is quite standalone part of NB, and nothing prevents you to use it in own way, not the way NB was.. 
Because NB was born to make nice integration between machine code and VM , and providing FFI,
and as a demonstration that generating machine code IS possible and quite doable from within an image.

But there's a tons of ways how you could generate machine code, and then use it outside the scope of FFI.
You could just make own llittle primitive, that just makes a call on arbitrary address, and put your generated code on it.. Voila.
Again, you could store generated code not in method(s) trailer , but somewhere else.. it just up to you, after all.
For instance i had parts that were storing generated code directly in COG's JITter, replacing its primitive section.
So, that make a nice integration with JIT, that just using your code as a primitive for given method..
All is doable, when you working at lowest level, you just need to think how to expose it in convenient way.

--
Best regards,
Igor Stasenko.
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] PharoNOS

Ronie Salgado
Hi,

With the experimental Lowcode backend for the UFFI, it is possible to call functions with almost arbitrary calling conventions. For some of the special assembly instructions that are required by this project, I could add the following extra instruction:
 - storeIntoSpecialRegister: {CR0, CR1, CR2, CR3, CR4, CR5, GDT, LDT, IDT)
 - loadFromSpecialRegister:
 - loadFromIOPortU?Int{8,16,32}:
 - storeIntoIOPortU?Int{8,16,32}:

As for the interruptions, there are far trickier because they can be triggered in any time. They probably would require some special trampoline for storing/restoring the VM state, something similar to the callbacks.

Currently I am finishing a refactoring of the Lowcode register allocator, so the Lowcode VM is out of service for this week :) .

Hey, guys, i'd like to stress, that AsmJit 
is quite standalone part of NB, and nothing prevents you to use it in own way, not the way NB was.. 
Because NB was born to make nice integration between machine code and VM , and providing FFI,
and as a demonstration that generating machine code IS possible and quite doable from within an image.

But there's a tons of ways how you could generate machine code, and then use it outside the scope of FFI.
You could just make own llittle primitive, that just makes a call on arbitrary address, and put your generated code on it.. Voila.
Again, you could store generated code not in method(s) trailer , but somewhere else.. it just up to you, after all.
For instance i had parts that were storing generated code directly in COG's JITter, replacing its primitive section.
So, that make a nice integration with JIT, that just using your code as a primitive for given method..
All is doable, when you working at lowest level, you just need to think how to expose it in convenient way.
 
For GPU compilation, I implemented a SSA based intermediate representation very similar to the one used by LLVM. As a experiment, I did a very basic machine code generator which can produce relocatable ELF32 and ELF64 object files, which can be linked with any C library or program. With this I managed to implement a basic ahead of time compiled Smalltalk runtime.

Before starting that backend, I took a look on AsmJit and the VirtualCPU and I did not like the dependencies and some details about the stack. However, now I do not like the low level backend so I started refactoring into a separate package, but I still think that I should take yet another look to AsmJit and the VirtualCPU, so I am wondering where is actually located the latest version of these two projects.

Best regards,
Ronie

2017-03-22 14:29 GMT-03:00 Igor Stasenko <[hidden email]>:

Hey, guys, i'd like to stress, that AsmJit 
is quite standalone part of NB, and nothing prevents you to use it in own way, not the way NB was.. 
Because NB was born to make nice integration between machine code and VM , and providing FFI,
and as a demonstration that generating machine code IS possible and quite doable from within an image.

But there's a tons of ways how you could generate machine code, and then use it outside the scope of FFI.
You could just make own llittle primitive, that just makes a call on arbitrary address, and put your generated code on it.. Voila.
Again, you could store generated code not in method(s) trailer , but somewhere else.. it just up to you, after all.
For instance i had parts that were storing generated code directly in COG's JITter, replacing its primitive section.
So, that make a nice integration with JIT, that just using your code as a primitive for given method..
All is doable, when you working at lowest level, you just need to think how to expose it in convenient way.

--
Best regards,
Igor Stasenko.

Reply | Threaded
Open this post in threaded view
|

Re: [Vm-dev] [ANN] PharoNOS

Igor Stasenko


On 23 March 2017 at 00:03, Ronie Salgado <[hidden email]> wrote:
 
Hi,

With the experimental Lowcode backend for the UFFI, it is possible to call functions with almost arbitrary calling conventions. For some of the special assembly instructions that are required by this project, I could add the following extra instruction:
 - storeIntoSpecialRegister: {CR0, CR1, CR2, CR3, CR4, CR5, GDT, LDT, IDT)
 - loadFromSpecialRegister:
 - loadFromIOPortU?Int{8,16,32}:
 - storeIntoIOPortU?Int{8,16,32}:

As for the interruptions, there are far trickier because they can be triggered in any time. They probably would require some special trampoline for storing/restoring the VM state, something similar to the callbacks.

Currently I am finishing a refactoring of the Lowcode register allocator, so the Lowcode VM is out of service for this week :) .

Hey, guys, i'd like to stress, that AsmJit 
is quite standalone part of NB, and nothing prevents you to use it in own way, not the way NB was.. 
Because NB was born to make nice integration between machine code and VM , and providing FFI,
and as a demonstration that generating machine code IS possible and quite doable from within an image.

But there's a tons of ways how you could generate machine code, and then use it outside the scope of FFI.
You could just make own llittle primitive, that just makes a call on arbitrary address, and put your generated code on it.. Voila.
Again, you could store generated code not in method(s) trailer , but somewhere else.. it just up to you, after all.
For instance i had parts that were storing generated code directly in COG's JITter, replacing its primitive section.
So, that make a nice integration with JIT, that just using your code as a primitive for given method..
All is doable, when you working at lowest level, you just need to think how to expose it in convenient way.
 
For GPU compilation, I implemented a SSA based intermediate representation very similar to the one used by LLVM. As a experiment, I did a very basic machine code generator which can produce relocatable ELF32 and ELF64 object files, which can be linked with any C library or program. With this I managed to implement a basic ahead of time compiled Smalltalk runtime.

Before starting that backend, I took a look on AsmJit and the VirtualCPU and I did not like the dependencies and some details about the stack. However, now I do not like the low level backend so I started refactoring into a separate package, but I still think that I should take yet another look to AsmJit and the VirtualCPU, so I am wondering where is actually located the latest version of these two projects.

IIRC, the stack (but more precisely - temporaries) management in AsmJIT are implemented in own classes, that doing the job of allocating stack space and assigning each temporary to specific place on stack.
As well, as calling convention. Nothing prevents you from adding own by implementing their protocol(s).
Or you may leave it as a whole, except that then you'll have to handle it by yourself. And of course, it is already there, since initial version has no such functionality at all,
all you have to do is to tell:
asm noStackFrame.
And so, it will leave you without it. 

As for where it located - see at smalltalkhub , if i remember Max  were working on that and made quite complete coverage of ARM instruction set. (http://smalltalkhub.com/#!/~maxmattone/AsmJit-ARM)
I don't remember if we merged the ARM support into main branch.. But i think you can figure it out.
 
P.S. ohh, you see.. it just never ending quest to keep dispelling people's perception, that there's something impossible or wrong with these things
or that's there are something that won't make things possible.. So, they choose to go with C :)

Best regards,
Ronie


--
Best regards,
Igor Stasenko.