From mboxrd@z Thu Jan 1 00:00:00 1970 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> In-reply-to: Your message of "Tue, 09 Sep 2014 22:45:01 BST." <5027045b88fe7d178a0926131e4205f1@quintile.net> References: <5027045b88fe7d178a0926131e4205f1@quintile.net> Date: Tue, 9 Sep 2014 21:48:14 -0700 From: Bakul Shah Message-Id: <20140910044814.78442B827@mail.bitblocks.com> Subject: Re: [9fans] JIT (mostly off topic) Topicbox-Message-UUID: 158f8828-ead9-11e9-9d60-3106f5b1d025 On Tue, 09 Sep 2014 22:45:01 BST "Steve Simon" wrote: > Years ago The Commander and Bart Locanthi used JIT > in the form of some C that write machine code into an > array of chars, cast it to a function pointer, and called it. > (I appologise if the details are not correct but this is the idea). > > I have a need for such a thing again - trying to speed up > a compressed video decoder. > > Anyone done such a thing this millenium? Does the x86 data execution > prevention mean you just cannot do this - my targets are desktop OSs > other than plan9 (sadly). Have you looked at libjit or luajit? There are a bunch of projects using JIT on the fly! You may also want to look at Nils Holm's subc (a 5Kloc compiler for a subset of C + codegens for 386,arm,x86-64, each in 260..427 lines). For an example of generating assembly code using C functions.