<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 23 March 2017 at 00:03, Ronie Salgado <span dir="ltr"><<a href="mailto:roniesalg@gmail.com" target="_blank">roniesalg@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"> <br><div dir="ltr">Hi,<div><br></div><div>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:</div><div> - storeIntoSpecialRegister: {CR0, CR1, CR2, CR3, CR4, CR5, GDT, LDT, IDT)</div><div> - loadFromSpecialRegister:</div><div> - loadFromIOPortU?Int{8,16,32}:</div> - storeIntoIOPortU?Int{8,16,32}:<div><br></div><div>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.</div><div><br></div><div>Currently I am finishing a refactoring of the Lowcode register allocator, so the Lowcode VM is out of service for this week :) .</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 style="font-size:12.8px">Hey, guys, i'd like to stress, that AsmJit </div><div style="font-size:12.8px">is quite standalone part of NB, and nothing prevents you to use it in own way, not the way NB was.. </div><div style="font-size:12.8px">Because NB was born to make nice integration between machine code and VM , and providing FFI,<br>and as a demonstration that generating machine code IS possible and quite doable from within an image.<br><br></div><div style="font-size:12.8px">But there's a tons of ways how you could generate machine code, and then use it outside the scope of FFI.<br>You could just make own llittle primitive, that just makes a call on arbitrary address, and put your generated code on it.. Voila.<br>Again, you could store generated code not in method(s) trailer , but somewhere else.. it just up to you, after all.<br>For instance i had parts that were storing generated code directly in COG's JITter, replacing its primitive section.<br>So, that make a nice integration with JIT, that just using your code as a primitive for given method..<br>All is doable, when you working at lowest level, you just need to think how to expose it in convenient way.</div></blockquote><div> </div><div>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.</div><div><br></div><div>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.</div><div><br></div></div></blockquote><div>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.</div><div>As well, as calling convention. Nothing prevents you from adding own by implementing their protocol(s).<br>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,</div><div>all you have to do is to tell:<br>asm noStackFrame. <br>And so, it will leave you without it. </div><div><br>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. (<a href="http://smalltalkhub.com/#!/~maxmattone/AsmJit-ARM">http://smalltalkhub.com/#!/~maxmattone/AsmJit-ARM</a>)<br>I don't remember if we merged the ARM support into main branch.. But i think you can figure it out.</div><div> <br>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</div><div>or that's there are something that won't make things possible.. So, they choose to go with C :)<br><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></div><div>Best regards,</div><div>Ronie</div></div><div class="gmail_extra"><br></div></blockquote></div><div><br></div>-- <br><div class="gmail_signature">Best regards,<br>Igor Stasenko.</div>
</div></div>