classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Inlining (Was: Re: Math patch)


From: Dalibor Topic
Subject: Inlining (Was: Re: Math patch)
Date: Fri, 28 Feb 2003 02:16:04 -0800 (PST)

Hi Chris,

--- Chris Gray <address@hidden> wrote:
> On Fri, 28 Feb 2003, Dalibor Topic wrote:

> > In my opinion, the safest place to do constant 
> > inlining is in a class loader, when you know that
> > which specific implementation you're going to
> 'link'
> > to. Method inlining is possible during class
> loading
> > as well, but  would probably require a good
> heuristic
> > to avoid a huge increase in code size. 
> 
> Yes, that's right: the logical place to do this
> would be in the phase we 
> call "referencing", or maybe a bit later in a
> verifying/bytecode rewriting 
> phase if one exists. In the latter case one could
> encode the actual value 
> directly into the instruction, by-passing the
> constant pool entirely.

Actually, that would not only make the code faster but
also smaller in the cases where the constant fits into
a xload_y instruction. ;)
 
> > I intend to experiment with that in kaffe, but I'm
> too 
> > busy merging stuff in to do much development at
> the
> > moment ;)
> 
> Know the feeling. ;> It's got me thinking too though
> - I might at least 
> instrument Wonka to find out what the size
> distribution of static methods 
> is. If there are a lot of one-liners or empty(!)
> methods then there may be 
> some low-hanging fruit to be had ...

Well written code should use getter/setter methods for
field access (flamebait, I know ;). Such classes
should benefit quite a bit from inlining their field
access methods (which usually are one liners ;). 

I believe that some Java IDE's come with wizards which
let you generate this kind of code automatically (JDEE
for example). And it's the proper form of field access
for java beans, AFAIK.

I think it's safe to inline 
a) private members (at compile time)
b) superclass methods (at load time)
c) static final members (at load time)

at least.

a) covers chained constructors, getters/setters etc.
b) covers finalize, equals, read/write in IO classes
c) covers Math.abs, Double.isNan, etc.

It may be possible to inline non-static methods from
final classes (String.charAt), but I haven't figured
out how if the method is not using public fields only
;) 

If someone knows of a free software/open source java
inliner, I'd like to have a link ...

cheers,
dalibor topic

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]