Re: Jit Implementation

jgd@cix.compulink.co.uk
Sat, 20 Mar 2010 10:47:31 -0500

          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: Jit Implementation herron.philip@googlemail.com (Philip Herron) (2010-03-21)
Re: Jit Implementation jthorn@astro.indiana-zebra.edu (Jonathan Thornburg \[remove -animal to reply\]) (2010-03-21)
Re: Jit Implementation cr88192@hotmail.com (BGB / cr88192) (2010-03-21)
Re: Jit Implementation herron.philip@googlemail.com (Philip Herron) (2010-03-21)
[9 later articles]
| List of all articles for this month |

From: jgd@cix.compulink.co.uk
Newsgroups: comp.compilers
Date: Sat, 20 Mar 2010 10:47:31 -0500
Organization: Compilers Central
References: 10-03-054
Keywords: code
Posted-Date: 21 Mar 2010 11:38:39 EDT

herron.philip@googlemail.com (Philip Herron) wrote:


> So ok if we have successfully output target code for the processor
> would you use simply a system assembler


No. Most consumer computers - Windows PCs and Macs - don't have an
assembler installed. You have to generate binary machine language, for
the target machine. This is not completely trivial to do, but neither
does it require inventing anything new. It's up to the JIT designer if
this goes through a stage involving text in memory with assembler
mnemonics and symbols, or if he goes straight to machine language. Since
performance is important, I'd guess that the assembler code step is
usually bypassed.


> or what i see some people have runtime assemblers to assemble this
> code, then where would this target code go?


Basically, you get some memory from somewhere - maybe malloc(), maybe an
OS call, maybe even a block on the stack if you don't need much, and
then put your machine language code into it. Depending on the platform,
you may have to tell the OS that you want to make this memory
executable, since many platforms won't let you execute memory that the
OS thinks is for data.


> Then how do you link it in a useful way?


You generally let it call some kind of run-time library, which might be
the same as the one that the program containing the JITer is using, or
might be a separate one provided for the purpose.


> And ultimately how would you execute this but that depends on how
> you link it or where you link it.


To call it, you set up a function pointer to the entry point and call
through that.


> ... i doubt seriously if it works like this, to generate a dynamic
> library .so and use dlsym to execute them from your runtime.


Your doubt is correct. It could be done that way, but that demands a
load of infrastructure on the machine, and the most commonly used JITers
- for Java and .NET code - are intended to behave like self-contained
interpreters, which can run on any old machine without requiring that
development tools be installed.


--
John Dallman jgd@cix.co.uk
                    "C++ - the FORTRAN of the early 21st century."


Post a followup to this message

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