<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-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="font-size:12.800000190734863px">Hey, guys, i'd like to stress, that AsmJit </div><div style="font-size:12.800000190734863px">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.800000190734863px">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.800000190734863px">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>Best regards,</div><div>Ronie</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-03-22 14:29 GMT-03:00 Igor Stasenko <span dir="ltr"><<a href="mailto:siguctua@gmail.com" target="_blank">siguctua@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br>Hey, guys, i'd like to stress, that AsmJit </div><div>is quite standalone part of NB, and nothing prevents you to use it in own way, not the way NB was.. </div><div>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>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.<span class="HOEnZb"><font color="#888888"><br><br></font></span></div></div><span class="HOEnZb"><font color="#888888">-- <br><div class="m_-1589081920369758859gmail_signature" data-smartmail="gmail_signature">Best regards,<br>Igor Stasenko.</div>
</font></span></div></div>
</blockquote></div><br></div>