Jit Implementation

Philip Herron <herron.philip@googlemail.com>
Thu, 18 Mar 2010 21:13:56 +0000

          From comp.compilers

Related articles
Jit Implementation herron.philip@googlemail.com (Philip Herron) (2010-03-18)
Re: Jit Implementation bobduff@shell01.TheWorld.com (Robert A Duff) (2010-03-19)
Re: Jit Implementation bartc@freeuk.com (bartc) (2010-03-20)
Re: Jit Implementation jgd@cix.compulink.co.uk (2010-03-20)
Re: Jit Implementation anton@mips.complang.tuwien.ac.at (2010-03-21)
Re: Jit Implementation gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-03-21)
Re: Jort programs, was Jit Implementation bobduff@shell01.TheWorld.com (Robert A Duff) (2010-03-21)
[13 later articles]
| List of all articles for this month |

From: Philip Herron <herron.philip@googlemail.com>
Newsgroups: comp.compilers
Date: Thu, 18 Mar 2010 21:13:56 +0000
Organization: Compilers Central
Keywords: code, practice, question
Posted-Date: 19 Mar 2010 13:12:23 EDT

Hey guys

This is still bugging me, a while back i started a similar topic on
this. But really i still don't quite understand how a Jit works
completely. So i hope someone here can show what i am missing.

From what i understand to Jit some kind of language, do your parsing
into an IR maybe some optimizations to a code generator. So ok if we
have successfully output target code for the processor would you use
simply a system assembler or what i see some people have runtime
assemblers to assemble this code, then where would this target code
go? Then how do you link it in a useful way? And ultimately how would
you execute this but that depends on how you link it or where you link
it. What might work but i doubt seriously if it works like this, to
generate a dynamic library .so and use dlsym to execute them from your
runtime. That is if you were to have a nice dynamic jit rather than a
fully AOT jit which generates code fully so you really compile your

I've been peeking at libjit a good bit, but most jit implementations
(although i haven't obviously looked deep enough), have lots of static
pre-processor CPU specifications and ELF specifications i guess for
the runtime assembler and linker for the Jit. But i just don't
understand where the code might be output or what way its compiled and
used. Since it is definitely not helpful if you were to ouput code and
link it into an executable in /tmp and execute the binary as is with
execv or something.

I know i am missing something or not seeing something but its bugging
me so i hope someone can fill in the gaps for me. Its just annoying
I've been toying with some small programs to generate code at runtime
on a basic language, but all i do is output to a file descriptor i
specify; simply to see if the code looks good so far, it would be nice
what do you do next.


[A JIT compiler has to do the moral equivalent of dlopen(), take a
chunk of data and make it be code, with everything in memory rather
than in files. On many architectures, you don't actually have to do
anything since code and data are in the same address space so you can
set a pointer to point to the code you just wrote and call it, but on
others you do need some help from the system, e.g., on recent x86
where data pages are usually marked no-execute. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.