Re: basic question about runtime query parsing

Chris Dollin <kers@hpl.hp.com>
31 Jul 2005 00:39:15 -0400

          From comp.compilers

Related articles
[4 earlier articles]
Re: basic question about runtime query parsing gneuner2@comcast.net (George Neuner) (2005-07-12)
Re: basic question about runtime query parsing kers@hpl.hp.com (Chris Dollin) (2005-07-17)
Re: basic question about runtime query parsing lfinsto1@gwdg.de (Laurence Finston) (2005-07-22)
Re: basic question about runtime query parsing shahbazc@gmail.com (falcon) (2005-07-22)
Re: basic question about runtime query parsing kers@hpl.hp.com (Chris Dollin) (2005-07-26)
Re: basic question about runtime query parsing lfinsto1@gwdg.de (Laurence Finston) (2005-07-28)
Re: basic question about runtime query parsing kers@hpl.hp.com (Chris Dollin) (2005-07-31)
Re: basic question about runtime query parsing skandgoe@gwdg.de (Skandinavisches Seminar) (2005-08-01)
Re: basic question about runtime query parsing marcov@stack.nl (Marco van de Voort) (2005-08-03)
Re: basic question about runtime query parsing kers@hpl.hp.com (Chris Dollin) (2005-08-03)
| List of all articles for this month |

From: Chris Dollin <kers@hpl.hp.com>
Newsgroups: comp.compilers
Date: 31 Jul 2005 00:39:15 -0400
Organization: HPLB
References: 05-07-045 05-07-056 05-07-066 05-07-079 05-07-103 05-07-115
Keywords: code

Laurence Finston wrote:


> On Tue, 26 Jul 2005, Chris Dollin wrote:


>> Run-time code generation eg JIT.
>
> Sorry, I don't know what this is.


JIT - "just in time" code generation - is where you generate the
native code for some program/method just before you run it, or
sometimes, only after you've run it enough times to be convinced that
it's worth it.


> Please correct me if I'm wrong, but I would assume that "code
> generation" means that new code is created, not that existing code
> in memory is overwritten while the program is running.


Generally, yes. But sometimes you want to update existing code. For
example, you may have compiled a call to some method M with a single
definition as a `call address-of-M` instruction. When a later dynamic
load introduces a new definition of M - say, as an over-riding method
in some subclass - you have to either (a) patch the call instructions
to refer to a new (dispatch) method or (b) patch the code at
address-of-M to do additional work.


[You might have chosen to do some kind of indirect call instead,
  but then when M is never overridden every call is paying a penalty.
  It All Depends.]


Or consider garbage-collecting dead methods. If you relocate the
remaining methods, you may well have to patch them with new
addresses. If you don't, you may want to re-use the empty space where
the dead methods lived.


Even if you're not garbage-collecting, you may have a situation where
the efficient solution to your problem is to generate specialised
code, execute it, and discard it, re-using the space for the next
chunk of specialised code. I have this vague recall of ... live code
generation for fast bitblts? ... from multiple years ago.


So you may not /have/ to do self-modifying code. But it may be a
reasonable solution to a problem.


--
Chris "electric hedgehog" Dollin
predicting self-predictors' predictions is predictably unpredictable.


Post a followup to this message

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