[Vm-dev] [Pharo-dev] [ANN] PharoNOS

Ronie Salgado roniesalg at gmail.com
Wed Mar 22 22:03:34 UTC 2017


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 <siguctua at gmail.com>:

>
> 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20170322/8222f886/attachment-0001.html>


More information about the Vm-dev mailing list