In general, a process of the generated code execution is not SBCL-specific. One of the possible scenarios is (on Windows):

1. Allocate a memory region with VirtualAllocEx, using the appropriate protection constant. See
    http://msdn.microsoft.com/en-us/library/aa366890%28v=vs.85%29.aspx

2. Write the function's machine code to the allocated region.

3. To execute the function, pass the arguments using registers/stack, and jump to the machine code (see CALL instruction).

I don't know whether the above approach is used by SBCL, but it works. Maybe there are some other ways.


Roman


2011/2/3 Michael J. Barillier <blackwolf@blackwolfinfosys.net>
I've been curious about how the SBCL compiler works (but not enough to
code-dive).  Docs say that SBCL compiles to native code, and
disassembling a function shows native instructions, but how does SBCL
load that into an executable area of memory?  Intel processors and
others don't allow execution of memory segments (as I recall from
assembly hacking in a previous life), so how does SBCL generate a stream
of machine instructions and call the entry point?

--
Michael J. Barillier   ///   http://www.blackwolfinfosys.net/~blackwolf/
_O_|  ``Ignorance breeds monsters to fill up the vacancies of the soul
__O|  that are unoccupied by the verities of knowledge.''
OOO|      -- Horace Mann

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Sbcl-help mailing list
Sbcl-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-help