Hi Noah! Noah Lavine <noah...@gmail.com> writes:
> Here is my understanding of the three approaches: > > The approach in my project was to make machine code a Guile datatype, > which you could allocate with a special init function and write to > with writing functions which are just Guile versions of the Lightning > macros. It could be called as a function through the dynamic FFI. > > The approach in the other guile-lightning project is to represent the > Lightning code as a Guile list which mirrors the Lightning virtual > instruction set. When a list is completely built, it would then be > passed to a special function (written in C) to assemble it. It also > has some infrastructure for labels and a special method of calling > these functions, neither of which I understand yet. > > The approach in your plan for JIT, as I understand it, is to implement > this completely in the C layer. The machine code would be stored as > part of the representation of a procedure, and would be invisible from > the Scheme side. Yes. > The reason I did not use the approach of the other guile-lightning, to > make a list and then assemble it, was that it seemed inelegant and > possibly slow It depends on when and how the instruction stream is written. From a usability viewpoint, having a simple s-exp for asm instructions is nice (and elegant, IMO). OTOH, I find the ‘make-integer-id’ example at <http://github.com/noahl/guile-lightning/blob/master/binds.scm> quite elegant too. BTW, note that end-of-buffer situations must be handled, somehow. If the whole call generation procedure is burried in a single C functions, it can hide these details to the application. Otherwise, it’d be up to the application to handle this situation, e.g., by linking two code buffers together and adding a jump instruction in the first one to the second one. Anyway, these are just random thoughts. Thanks, Ludo’.