public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* RFC: Java inliner
@ 2002-06-11  7:00 Andrew Haley
  2002-06-11  7:25 ` Daniel Berlin
                   ` (2 more replies)
  0 siblings, 3 replies; 29+ messages in thread
From: Andrew Haley @ 2002-06-11  7:00 UTC (permalink / raw)
  To: gcc; +Cc: java

We need a tree inliner for Java.  We've already disabled RTL inlining.

tree-inline.c is rather C- and C++-centric, although I guess we'll get
a real languge independent AST inliner sometime.

In the meantime, I intend to work on a Java specific tree inliner.

Comments?

Andrew.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-11  7:00 RFC: Java inliner Andrew Haley
@ 2002-06-11  7:25 ` Daniel Berlin
  2002-06-11  7:26   ` Andrew Haley
  2002-06-11  7:56 ` Fergus Henderson
  2002-06-11  8:39 ` profiling shared libraries Taha Mannan Jiruwala
  2 siblings, 1 reply; 29+ messages in thread
From: Daniel Berlin @ 2002-06-11  7:25 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc, java


On Tuesday, June 11, 2002, at 09:58  AM, Andrew Haley wrote:

> We need a tree inliner for Java.  We've already disabled RTL inlining.
>
> tree-inline.c is rather C- and C++-centric, although I guess we'll get
> a real languge independent AST inliner sometime.
>
> In the meantime, I intend to work on a Java specific tree inliner.
>
> Comments?

Get rid of the use of statement expressions in tree-inline, and i'll be your best friend.

>
> Andrew.
>

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-11  7:25 ` Daniel Berlin
@ 2002-06-11  7:26   ` Andrew Haley
  0 siblings, 0 replies; 29+ messages in thread
From: Andrew Haley @ 2002-06-11  7:26 UTC (permalink / raw)
  To: Daniel Berlin; +Cc: gcc, java

Daniel Berlin writes:
 > 
 > Get rid of the use of statement expressions in tree-inline, and
 > i'll be your best friend.

I might well need to do that.

Andrew.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-11  7:00 RFC: Java inliner Andrew Haley
  2002-06-11  7:25 ` Daniel Berlin
@ 2002-06-11  7:56 ` Fergus Henderson
  2002-06-11  9:18   ` Andrew Haley
  2002-06-11  8:39 ` profiling shared libraries Taha Mannan Jiruwala
  2 siblings, 1 reply; 29+ messages in thread
From: Fergus Henderson @ 2002-06-11  7:56 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc, java

On 11-Jun-2002, Andrew Haley <aph@cambridge.redhat.com> wrote:
> We need a tree inliner for Java.  We've already disabled RTL inlining.
> 
> tree-inline.c is rather C- and C++-centric, although I guess we'll get
> a real languge independent AST inliner sometime.
> 
> In the meantime, I intend to work on a Java specific tree inliner.
> 
> Comments?

I doubt we'll get a real language-independent AST inliner soon
if everyone who could benefit from it decides that it will be easier
for them to build their own language-specific tree inliner instead ;-)

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* profiling shared libraries
  2002-06-11  7:00 RFC: Java inliner Andrew Haley
  2002-06-11  7:25 ` Daniel Berlin
  2002-06-11  7:56 ` Fergus Henderson
@ 2002-06-11  8:39 ` Taha Mannan Jiruwala
  2 siblings, 0 replies; 29+ messages in thread
From: Taha Mannan Jiruwala @ 2002-06-11  8:39 UTC (permalink / raw)
  To: gcc

Hi,

I have tried profiling shared libraries using the following:

program=test.c
main()
{
           printf("hello world\n");
}

$ gcc test.c -lc

$ ldd a.out
        libc.so.6 => /lib/libc.so.6 (0x4001a000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)b

$ export LD_PROFILE=/lib/libc.so.6

$ ./a.out

hello world

$ unset LD_PROFILE

$ gprof /lib/libc.so.6 libc.so.6.profile

The versions are
gcc -> egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
gprof ->GNU gprof 2.9.5

Here I am getting the message:
"gprof: file `libc.so.6.profile' has unsupported version 131071 "

Please help me in this regard..

Thanks in advance,
taha


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-11  7:56 ` Fergus Henderson
@ 2002-06-11  9:18   ` Andrew Haley
  2002-06-11  9:49     ` Joe Buck
  2002-06-11 22:36     ` Mark Mitchell
  0 siblings, 2 replies; 29+ messages in thread
From: Andrew Haley @ 2002-06-11  9:18 UTC (permalink / raw)
  To: Fergus Henderson; +Cc: gcc, java

Fergus Henderson writes:
 > On 11-Jun-2002, Andrew Haley <aph@cambridge.redhat.com> wrote:
 > > I intend to work on a Java specific tree inliner.
 > > 
 > > Comments?
 > 
 > I doubt we'll get a real language-independent AST inliner soon
 > if everyone who could benefit from it decides that it will be easier
 > for them to build their own language-specific tree inliner instead ;-)

I take your point!

However, at the moment Java doesn't have an inliner of any kind, so...

Andrew.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-11  9:18   ` Andrew Haley
@ 2002-06-11  9:49     ` Joe Buck
  2002-06-11 10:59       ` Andrew Haley
  2002-06-11 22:36     ` Mark Mitchell
  1 sibling, 1 reply; 29+ messages in thread
From: Joe Buck @ 2002-06-11  9:49 UTC (permalink / raw)
  To: Andrew Haley; +Cc: Fergus Henderson, gcc, java

On 11-Jun-2002, Andrew Haley <aph@cambridge.redhat.com> wrote:
>  > > I intend to work on a Java specific tree inliner.
>  > > 
>  > > Comments?

Fergus Henderson writes:
>  > I doubt we'll get a real language-independent AST inliner soon
>  > if everyone who could benefit from it decides that it will be easier
>  > for them to build their own language-specific tree inliner instead ;-)

Andrew writes:
> I take your point!
> 
> However, at the moment Java doesn't have an inliner of any kind, so...

You could work with the ast-optimizer-branch folks and see if you can get
their stuff working well for Java.  Then you'd be contributing to the
language-independent inliner as well as making Java better.



^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-11  9:49     ` Joe Buck
@ 2002-06-11 10:59       ` Andrew Haley
  2002-06-11 11:29         ` Diego Novillo
  0 siblings, 1 reply; 29+ messages in thread
From: Andrew Haley @ 2002-06-11 10:59 UTC (permalink / raw)
  To: Joe Buck; +Cc: Fergus Henderson, gcc, java

Joe Buck writes:
 > On 11-Jun-2002, Andrew Haley <aph@cambridge.redhat.com> wrote:
 > >  > > I intend to work on a Java specific tree inliner.
 > >  > > 
 > >  > > Comments?
 > 
 > Fergus Henderson writes:
 > >  > I doubt we'll get a real language-independent AST inliner soon
 > >  > if everyone who could benefit from it decides that it will be easier
 > >  > for them to build their own language-specific tree inliner instead ;-)
 > 
 > Andrew writes:
 > > I take your point!
 > > 
 > > However, at the moment Java doesn't have an inliner of any kind, so...
 > 
 > You could work with the ast-optimizer-branch folks and see if you can get
 > their stuff working well for Java.  Then you'd be contributing to the
 > language-independent inliner as well as making Java better.

I may do both.

Andrew.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-11 10:59       ` Andrew Haley
@ 2002-06-11 11:29         ` Diego Novillo
  0 siblings, 0 replies; 29+ messages in thread
From: Diego Novillo @ 2002-06-11 11:29 UTC (permalink / raw)
  To: Andrew Haley; +Cc: Joe Buck, Fergus Henderson, gcc, java

On Tue, 11 Jun 2002, Andrew Haley wrote:

> Joe Buck writes:
>
>  > You could work with the ast-optimizer-branch folks and see if you can get
>  > their stuff working well for Java.  Then you'd be contributing to the
>  > language-independent inliner as well as making Java better.
> 
> I may do both.
> 
Excellent.  It's a matter of implementing
lang_hooks.simplify_function_tree.  If you do that, you should be
able to use the C inliner with little/no modifications.


Diego.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-11  9:18   ` Andrew Haley
  2002-06-11  9:49     ` Joe Buck
@ 2002-06-11 22:36     ` Mark Mitchell
  2002-06-12  2:24       ` Per Bothner
  1 sibling, 1 reply; 29+ messages in thread
From: Mark Mitchell @ 2002-06-11 22:36 UTC (permalink / raw)
  To: Andrew Haley, Fergus Henderson; +Cc: gcc, java



--On Tuesday, June 11, 2002 04:46:38 PM +0100 Andrew Haley 
<aph@cambridge.redhat.com> wrote:

> Fergus Henderson writes:
>  > On 11-Jun-2002, Andrew Haley <aph@cambridge.redhat.com> wrote:
>  > > I intend to work on a Java specific tree inliner.
>  > >
>  > > Comments?
>  >
>  > I doubt we'll get a real language-independent AST inliner soon
>  > if everyone who could benefit from it decides that it will be easier
>  > for them to build their own language-specific tree inliner instead ;-)
>
> I take your point!
>
> However, at the moment Java doesn't have an inliner of any kind, so...

The right thing to do is clear: convert the Java front end to use trees
that are more like the C/C++ trees.  (C++ is C plus some C++-specific
extensions; I expect you want C plus some Java-specific extensions.)
Then, use the existing inliner.

Anything else leads to greater incompatibility between the front ends,
and, as such, constitutes a step in distinctly the wrong direction.

This really should not be hard; the Java source language looks very
much like the C/C++ source language.  The control-flow constructs are
very similar.

I know that some of the Java developers think that the Java front end's
representation is superior.  That's a fine opinion to have, and maybe
switching the C/C++ front end to the Java representation is OK too -- but
that's a lot more work.  The Java representation certainly isn't
sufficiently more superior to justify that.

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-11 22:36     ` Mark Mitchell
@ 2002-06-12  2:24       ` Per Bothner
  2002-06-12  4:47         ` Andrew Haley
  2002-06-12  6:38         ` Mark Mitchell
  0 siblings, 2 replies; 29+ messages in thread
From: Per Bothner @ 2002-06-12  2:24 UTC (permalink / raw)
  To: Mark Mitchell; +Cc: Andrew Haley, Fergus Henderson, gcc, java

Mark Mitchell wrote:
> The right thing to do is clear: convert the Java front end to use trees
> that are more like the C/C++ trees.

Let us recap:

(1) Gcc orignally has a set of generic tree codes designed to be
more-or-less language-independent.
(2) Java carefully adds a few new tree codes in the sprit of the
original, re-using existing tree-codes where it makes sense, for example
using COMPOUND_EXPR for (e1; e3;) and COND_EXPR for if-then-else.
(3) The C++ people add a whole new slew of tree-codes that are
   (a) redundant, and
   (b) less general and only suitable for C/C++ (e.g. not it appears
   useful for expression languages).
(4) The C++ people want the Java people to switch to using their
tree-codes, and say this is "the right thing to do".

I beg to disagree.

I believe the right thing to do in the short term is extend the C/C++
inliner to understand the Java trees.  Almost all of the tree codes 
encountered will be generic tree codes defined in tree.def.  There are
some tree-codes in java-tree.def; most of these are specific to parse.y,
and will have disappeared by the time they reach the inliner.

Now it may turn out that some of the Java tree representations should
be changed, but switching e.g. to using IF_STMT is a step in the
wrong direction.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-12  2:24       ` Per Bothner
@ 2002-06-12  4:47         ` Andrew Haley
  2002-06-12  6:38         ` Mark Mitchell
  1 sibling, 0 replies; 29+ messages in thread
From: Andrew Haley @ 2002-06-12  4:47 UTC (permalink / raw)
  To: Per Bothner; +Cc: Mark Mitchell, Fergus Henderson, gcc, java

Per Bothner writes:
 > Mark Mitchell wrote:
 > > The right thing to do is clear: convert the Java front end to use trees
 > > that are more like the C/C++ trees.
 > 
 > Let us recap:
 > 
 > (1) Gcc orignally has a set of generic tree codes designed to be
 > more-or-less language-independent.
 > (2) Java carefully adds a few new tree codes in the sprit of the
 > original, re-using existing tree-codes where it makes sense, for example
 > using COMPOUND_EXPR for (e1; e3;) and COND_EXPR for if-then-else.
 > (3) The C++ people add a whole new slew of tree-codes that are
 >    (a) redundant, and
 >    (b) less general and only suitable for C/C++ (e.g. not it appears
 >    useful for expression languages).
 > (4) The C++ people want the Java people to switch to using their
 > tree-codes, and say this is "the right thing to do".
 > 
 > I beg to disagree.
 > 
 > I believe the right thing to do in the short term is extend the C/C++
 > inliner to understand the Java trees.  Almost all of the tree codes 
 > encountered will be generic tree codes defined in tree.def.  There are
 > some tree-codes in java-tree.def; most of these are specific to parse.y,
 > and will have disappeared by the time they reach the inliner.

I agree.  

Java needs an inliner.  It seems to me completely crazy to convert the
front end to require Java to use C++ trees in order to get it.

I'm going to look at doing what Per suggests.  If it turns out not to
be a clean patch I'll abandon the idea.

Andrew.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-12  2:24       ` Per Bothner
  2002-06-12  4:47         ` Andrew Haley
@ 2002-06-12  6:38         ` Mark Mitchell
  2002-06-12  8:45           ` Andrew Haley
  2002-07-01 11:21           ` Andrew Haley
  1 sibling, 2 replies; 29+ messages in thread
From: Mark Mitchell @ 2002-06-12  6:38 UTC (permalink / raw)
  To: Per Bothner; +Cc: Andrew Haley, Fergus Henderson, gcc, java



--On Wednesday, June 12, 2002 01:42:18 AM -0700 Per Bothner 
<per@bothner.com> wrote:

> Mark Mitchell wrote:
>> The right thing to do is clear: convert the Java front end to use trees
>> that are more like the C/C++ trees.
>
> Let us recap:

I deliberately tried to avoid reopening this issue.  The whole IF_STMT
vs. COND_EXPR debate isn't relevant at this point.  We are where we are.

We could have the argument about *why* we are here again -- but I don't
think anybody cares.  Lots of people (including me) think the C/C++
representation is better; at least some people (including you) think
the Java representation is better.  That's OK.

Reopening that -- and adding fuel to the fire by talking about who did
what to whom -- just isn't productive.

> I believe the right thing to do in the short term is extend the C/C++
> inliner to understand the Java trees.  Almost all of the tree codes
> encountered will be generic tree codes defined in tree.def.

If that is true -- and if languages other than Java are actually using
these tree codes -- that is fine.

The current inliner already has mechanisms for language-specific
extensions.  If those can be used, or it can be easily extended so that
they can be used, great.

The contention was that the current inliner could *not* be used, and that
an entirely new one had to be written.  It would be better to change the
Java front end as necessary to make the current inliner usable than to
write a new one.

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-12  6:38         ` Mark Mitchell
@ 2002-06-12  8:45           ` Andrew Haley
  2002-06-12  9:13             ` Daniel Berlin
  2002-07-01 11:21           ` Andrew Haley
  1 sibling, 1 reply; 29+ messages in thread
From: Andrew Haley @ 2002-06-12  8:45 UTC (permalink / raw)
  To: Mark Mitchell; +Cc: Per Bothner, Fergus Henderson, gcc, java

Mark Mitchell writes:
 > 
 > 
 > > I believe the right thing to do in the short term is extend the C/C++
 > > inliner to understand the Java trees.  Almost all of the tree codes
 > > encountered will be generic tree codes defined in tree.def.
 > 
 > If that is true -- and if languages other than Java are actually using
 > these tree codes -- that is fine.
 > 
 > The current inliner already has mechanisms for language-specific
 > extensions.  If those can be used, or it can be easily extended so that
 > they can be used, great.

Okay.

 > The contention was that the current inliner could *not* be used, and that
 > an entirely new one had to be written.

Not exactly, although some of the structures used in the inliner
(e.g. statement expressions) aren't going to make my life very easy.

Andrew.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-12  8:45           ` Andrew Haley
@ 2002-06-12  9:13             ` Daniel Berlin
  2002-06-12  9:28               ` Daniel Berlin
  0 siblings, 1 reply; 29+ messages in thread
From: Daniel Berlin @ 2002-06-12  9:13 UTC (permalink / raw)
  To: Andrew Haley; +Cc: Mark Mitchell, Per Bothner, Fergus Henderson, gcc, java

On Wed, 12 Jun 2002, Andrew Haley wrote:

> Mark Mitchell writes:
>  > 
>  > 
>  > > I believe the right thing to do in the short term is extend the C/C++
>  > > inliner to understand the Java trees.  Almost all of the tree codes
>  > > encountered will be generic tree codes defined in tree.def.
>  > 
>  > If that is true -- and if languages other than Java are actually using
>  > these tree codes -- that is fine.
>  > 
>  > The current inliner already has mechanisms for language-specific
>  > extensions.  If those can be used, or it can be easily extended so that
>  > they can be used, great.
> 
> Okay.
> 
>  > The contention was that the current inliner could *not* be used, and that
>  > an entirely new one had to be written.
> 
> Not exactly, although some of the structures used in the inliner
> (e.g. statement expressions) aren't going to make my life very easy.

It shouldn't be all that difficult to get rid of the statement 
expressions.

In fact, it might be the case that we can just remove the statement 
expression wrapper right now, and it'll still just work.
i'll check.
> 
> Andrew.
> 
> 

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-12  9:13             ` Daniel Berlin
@ 2002-06-12  9:28               ` Daniel Berlin
  0 siblings, 0 replies; 29+ messages in thread
From: Daniel Berlin @ 2002-06-12  9:28 UTC (permalink / raw)
  To: Andrew Haley; +Cc: Mark Mitchell, Per Bothner, Fergus Henderson, gcc, java

On Wed, 12 Jun 2002, Daniel Berlin wrote:

> On Wed, 12 Jun 2002, Andrew Haley wrote:
> 
> > Mark Mitchell writes:
> >  > 
> >  > 
> >  > > I believe the right thing to do in the short term is extend the C/C++
> >  > > inliner to understand the Java trees.  Almost all of the tree codes
> >  > > encountered will be generic tree codes defined in tree.def.
> >  > 
> >  > If that is true -- and if languages other than Java are actually using
> >  > these tree codes -- that is fine.
> >  > 
> >  > The current inliner already has mechanisms for language-specific
> >  > extensions.  If those can be used, or it can be easily extended so that
> >  > they can be used, great.
> > 
> > Okay.
> > 
> >  > The contention was that the current inliner could *not* be used, and that
> >  > an entirely new one had to be written.
> > 
> > Not exactly, although some of the structures used in the inliner
> > (e.g. statement expressions) aren't going to make my life very easy.
> 
> It shouldn't be all that difficult to get rid of the statement 
> expressions.
> 
> In fact, it might be the case that we can just remove the statement 
> expression wrapper right now, and it'll still just work.
> i'll check.

By this, i meant doing it the way we are doing simplification of them, 
which is to pre-insert the body of the statement expression, store the 
return value to a temporary, replace the call_expr with the temporary.

Obviously, you can't just remove the statement expression wrapper 
literally.

> > 
> > Andrew. > > 
> > 
> 
> 
> 

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-06-12  6:38         ` Mark Mitchell
  2002-06-12  8:45           ` Andrew Haley
@ 2002-07-01 11:21           ` Andrew Haley
  2002-07-01 11:29             ` Andrew Haley
  2002-07-01 11:56             ` RFC: " Daniel Berlin
  1 sibling, 2 replies; 29+ messages in thread
From: Andrew Haley @ 2002-07-01 11:21 UTC (permalink / raw)
  To: Mark Mitchell; +Cc: Per Bothner, Fergus Henderson, gcc, java

Mark Mitchell writes:
 > 
 > The current inliner already has mechanisms for language-specific
 > extensions.  If those can be used, or it can be easily extended so that
 > they can be used, great.

Well I tried, I really did.  But the inliner we have at the moment
uses C-private tree nodes to such an extent that I think it isn't
possible without totally messing up the code.  I could replace every
occurrence of these nodes with macros or function pointers, but the
result would not be pretty.  The real answer in the long term is, of
course, SIMPLE.

Andrew.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Java inliner
  2002-07-01 11:21           ` Andrew Haley
@ 2002-07-01 11:29             ` Andrew Haley
  2002-07-01 11:56             ` RFC: " Daniel Berlin
  1 sibling, 0 replies; 29+ messages in thread
From: Andrew Haley @ 2002-07-01 11:29 UTC (permalink / raw)
  To: gcc-patches@gcc.gnu.org, java

[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 568 bytes --]

Tree inlining, tested with no regressions, builds working libgcj on
i686-linux-gnu.

It's not yet perfectly integrated into the compiler in that it's still
sensitive to the order in which methods are compiled.  However, even
with that limitation it's still useful.  This can be fixed at some
later date by reorganizing the way that gcj does things and deferring
code generation until we have trees for everything.

Also, it's only hooked into the source compiler.

This patch fixes a performance regression that was caused by the RTL
inliner being disabled.

Andrew.


[-- Attachment #2: java-tree-inline --]
[-- Type: text/plain, Size: 55730 bytes --]

2002-06-28  Andrew Haley  <aph@redhat.com>

	* java-tree-inline.c: New file.
	* parse.y (source_end_java_method): Call java_optimize_inline.
	(java_expand_method_bodies): Save method's tree in
	DECL_SAVED_TREE.
	(add_stmt_to_compound): Keep track of the number of statments.
	* lang.c (java_init): Enable flag_inline_trees.
	(java_post_options): If flag_inline_functions is on, enable
	flag_inline_trees instread.
	(decl_constant_value): New.
	(java_tree_inlining_walk_subtrees): New.
	* java-tree.h (DECL_NUM_STMTS): New macro.
	(java_optimize_inline): Declare.
	* expr.c (java_expand_expr): Allow a BLOCK to return a value.
	Handle a LABEL_EXPR>
	* decl.c (build_result_decl): If we already have a DECL_RESULT
	don't make another.
	(dump_function): New.
	(java_optimize_inline): New.
	(dump_function): New.
	* Make-lang.in: Add java/java-tree-inline.o.

  2002-06-26  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
  
Index: java/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Make-lang.in,v
retrieving revision 1.88
diff -p -2 -c -r1.88 Make-lang.in
*** java/Make-lang.in	11 Jun 2002 14:58:09 -0000	1.88
--- java/Make-lang.in	1 Jul 2002 18:12:19 -0000
*************** JAVA_OBJS = java/parse.o java/class.o ja
*** 110,114 ****
    java/mangle_name.o java/builtins.o \
    java/jcf-write.o java/buffer.o java/check-init.o java/jcf-depend.o \
!   java/jcf-path.o java/xref.o java/boehm.o mkdeps.o
  
  GCJH_OBJS = java/gjavah.o java/jcf-io.o java/jcf-depend.o java/jcf-path.o \
--- 110,114 ----
    java/mangle_name.o java/builtins.o \
    java/jcf-write.o java/buffer.o java/check-init.o java/jcf-depend.o \
!   java/jcf-path.o java/xref.o java/boehm.o java/java-tree-inline.o mkdeps.o
  
  GCJH_OBJS = java/gjavah.o java/jcf-io.o java/jcf-depend.o java/jcf-path.o \
*************** java/expr.o: java/expr.c $(CONFIG_H) $(J
*** 289,292 ****
--- 289,296 ----
    java/java-except.h java/java-except.h java/parse.h toplev.h \
    $(SYSTEM_H) $(GGC_H) gt-java-expr.h
+ java/java-tree-inline.o: $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) \
+    expr.h flags.h params.h input.h insn-config.h $(INTEGRATE_H) \
+    $(VARRAY_H) $(HASHTAB_H) $(SPLAY_TREE_H) toplev.h langhooks.h \
+    $(C_COMMON_H) tree-inline.h
  java/jcf-depend.o: java/jcf-depend.c $(CONFIG_H) $(SYSTEM_H) java/jcf.h
  java/jcf-parse.o: java/jcf-parse.c $(CONFIG_H) $(JAVA_TREE_H) flags.h \
Index: java/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/decl.c,v
retrieving revision 1.129
diff -p -2 -c -r1.129 decl.c
*** java/decl.c	21 Jun 2002 20:18:21 -0000	1.129
--- java/decl.c	1 Jul 2002 18:12:20 -0000
*************** The Free Software Foundation is independ
*** 42,48 ****
  #include "java-except.h"
  #include "ggc.h"
  
  #if defined (DEBUG_JAVA_BINDING_LEVELS)
! extern void indent PROTO((void));
  #endif
  
--- 42,50 ----
  #include "java-except.h"
  #include "ggc.h"
+ #include "timevar.h"
+ #include "tree-inline.h"
  
  #if defined (DEBUG_JAVA_BINDING_LEVELS)
! extern void indent PARAMS ((void));
  #endif
  
*************** static tree create_primitive_vtable PARA
*** 54,57 ****
--- 56,60 ----
  static tree check_local_named_variable PARAMS ((tree, tree, int, int *));
  static tree check_local_unnamed_variable PARAMS ((tree, tree, tree));
+ static void dump_function PARAMS ((enum tree_dump_index, tree));
  
  /* Set to non-zero value in order to emit class initilization code
*************** build_result_decl (fndecl)
*** 1659,1667 ****
  {
    tree restype = TREE_TYPE (TREE_TYPE (fndecl));
!   /* To be compatible with C_PROMOTING_INTEGER_TYPE_P in cc1/cc1plus. */
!   if (INTEGRAL_TYPE_P (restype)
!       && TYPE_PRECISION (restype) < TYPE_PRECISION (integer_type_node))
!     restype = integer_type_node;
!   return (DECL_RESULT (fndecl) = build_decl (RESULT_DECL, NULL_TREE, restype));
  }
  
--- 1662,1677 ----
  {
    tree restype = TREE_TYPE (TREE_TYPE (fndecl));
!   tree result = DECL_RESULT (fndecl);
!   if (! result)
!     {
!       /* To be compatible with C_PROMOTING_INTEGER_TYPE_P in cc1/cc1plus. */
!       if (INTEGRAL_TYPE_P (restype)
! 	  && TYPE_PRECISION (restype) < TYPE_PRECISION (integer_type_node))
! 	restype = integer_type_node;
!       result = build_decl (RESULT_DECL, NULL_TREE, restype);
!       DECL_CONTEXT (result) = fndecl;
!       DECL_RESULT (fndecl) = result;
!     }
!   return result;
  }
  
*************** end_java_method ()
*** 1820,1823 ****
--- 1830,1884 ----
  
    current_function_decl = NULL_TREE;
+ }
+ 
+ /* Dump FUNCTION_DECL FN as tree dump PHASE. */
+ 
+ static void
+ dump_function (phase, fn)
+      enum tree_dump_index phase;
+      tree fn;
+ {
+   FILE *stream;
+   int flags;
+ 
+   stream = dump_begin (phase, &flags);
+   if (stream)
+     {
+       dump_node (fn, TDF_SLIM | flags, stream);
+       dump_end (phase, stream);
+     }
+ }
+  
+ void java_optimize_inline (fndecl)
+      tree fndecl;
+ {
+   if (flag_inline_trees)
+     {
+       int uninlinable;
+       /* First, cache whether the current function is inlinable.  Some
+          predicates depend on cfun and current_function_decl to
+          function completely.  */
+       timevar_push (TV_INTEGRATION);
+       uninlinable = ! tree_inlinable_function_p (fndecl);
+       
+ #if 0
+       if (! uninlinable
+ 	  /* Save function tree for inlining.  Should return 0 if the
+              language does not support function deferring or the
+              function could not be deferred.  */
+ 	  && defer_fn (fndecl))
+ 	{
+ 	  /* Let the back-end know that this function exists.  */
+ 	  (*debug_hooks->deferred_inline_function) (fndecl);
+           timevar_pop (TV_INTEGRATION);
+ 	  return;
+ 	}
+ #endif
+       
+       /* Then, inline any functions called in it.  */
+       optimize_inline_calls (fndecl);
+       timevar_pop (TV_INTEGRATION);
+       dump_function (TDI_inlined, fndecl);
+     }
  }
  
Index: java/expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.148
diff -p -2 -c -r1.148 expr.c
*** java/expr.c	25 Jun 2002 13:27:19 -0000	1.148
--- java/expr.c	1 Jul 2002 18:12:22 -0000
*************** java_expand_expr (exp, target, tmode, mo
*** 2536,2539 ****
--- 2536,2540 ----
  	{
  	  tree local;
+ 	  rtx last;
  	  tree body = BLOCK_EXPR_BODY (exp);
  	  /* Set to 1 or more when we found a static class
*************** java_expand_expr (exp, target, tmode, mo
*** 2569,2577 ****
  	      body = TREE_OPERAND (body, 1);
  	    }
! 	  expand_expr (body, const0_rtx, VOIDmode, 0);
  	  emit_queue ();
  	  expand_end_bindings (getdecls (), 1, 0);
  	  poplevel (1, 1, 0);
! 	  return const0_rtx;
  	}
        return const0_rtx;
--- 2570,2578 ----
  	      body = TREE_OPERAND (body, 1);
  	    }
!   	  last = expand_expr (body, NULL_RTX, VOIDmode, 0);
  	  emit_queue ();
  	  expand_end_bindings (getdecls (), 1, 0);
  	  poplevel (1, 1, 0);
! 	  return last;
  	}
        return const0_rtx;
*************** java_expand_expr (exp, target, tmode, mo
*** 2629,2632 ****
--- 2630,2638 ----
        return expand_expr (build_exception_object_ref (TREE_TYPE (exp)),
  			  target, tmode, modifier);
+ 
+     case LABEL_EXPR:
+       /* Used only by expanded inline functions.  */
+       expand_label (TREE_OPERAND (exp, 0));
+       return const0_rtx;
  
      default:
Index: java/java-tree-inline.c
===================================================================
RCS file: java/java-tree-inline.c
diff -N java/java-tree-inline.c
*** java/java-tree-inline.c	1 Jan 1970 00:00:00 -0000
--- java/java-tree-inline.c	1 Jul 2002 18:12:24 -0000
***************
*** 0 ****
--- 1,1275 ----
+ /* Inliner for Java trees.
+    Copyright 2001, 2002 Free Software Foundation, Inc.
+    Contributed by Andrew Haley <aph@redhat.com>
+    Based on work by by Alexandre Oliva <aoliva@redhat.com>
+ 
+ This file is part of GNU CC.
+ 
+ GNU CC is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+ 
+ GNU CC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with GNU CC; see the file COPYING.  If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.  */
+ 
+ #include "config.h"
+ #include "system.h"
+ #include "toplev.h"
+ #include "tree.h"
+ #include "tree-inline.h"
+ #include "rtl.h"
+ #include "expr.h"
+ #include "flags.h"
+ #include "params.h"
+ #include "input.h"
+ #include "insn-config.h"
+ #include "integrate.h"
+ #include "varray.h"
+ #include "hashtab.h"
+ #include "splay-tree.h"
+ #include "langhooks.h"
+ #include "parse.h"
+ 
+ /* This will be be generalized to other languages, but the shared
+    function-as-trees infrastructure doesn't yet exist.  */
+ #include "java-tree.h"
+ 
+ /* 0 if we should not perform inlining.
+    1 if we should expand functions calls inline at the tree level.
+    2 if we should consider *all* functions to be inline
+    candidates.  */
+ 
+ int flag_inline_trees = 0;
+ 
+ /* Data required for function inlining.  */
+ 
+ typedef struct inline_data
+ {
+   /* A stack of the functions we are inlining.  For example, if we are
+      compiling `f', which calls `g', which calls `h', and we are
+      inlining the body of `h', the stack will contain, `h', followed
+      by `g', followed by `f'.  The first few elements of the stack may
+      contain other functions that we know we should not recurse into,
+      even though they are not directly being inlined.  */
+   varray_type fns;
+   /* The index of the first element of FNS that really represents an
+      inlined function.  */
+   unsigned first_inlined_fn;
+   /* The label to jump to when a return statement is encountered.  If
+      this value is NULL, then return statements will simply be
+      remapped as return statements, rather than as jumps.  */
+   tree ret_label;
+   /* The map from local declarations in the inlined function to
+      equivalents in the function into which it is being inlined.  */
+   splay_tree decl_map;
+   /* A list of the functions current function has inlined.  */
+   varray_type inlined_fns;
+   /* The approximate number of statements we have inlined in the
+      current call stack.  */
+   int inlined_stmts;
+   /* We use the same mechanism to build clones that we do to perform
+      inlining.  However, there are a few places where we need to
+      distinguish between those two situations.  This flag is true if
+      we are cloning, rather than inlining.  */
+   bool cloning_p;
+   /* Hash table used to prevent walk_tree from visiting the same node
+      umpteen million times.  */
+   htab_t tree_pruner;
+ } inline_data;
+ 
+ /* Prototypes.  */
+ 
+ static tree initialize_inlined_parameters PARAMS ((inline_data *, tree, tree, tree));
+ static tree declare_return_variable PARAMS ((inline_data *, tree *));
+ static tree copy_body_r PARAMS ((tree *, int *, void *));
+ static tree copy_body PARAMS ((inline_data *));
+ static tree expand_call_inline PARAMS ((tree *, int *, void *));
+ static void expand_calls_inline PARAMS ((tree *, inline_data *));
+ static int inlinable_function_p PARAMS ((tree, inline_data *));
+ static tree remap_decl PARAMS ((tree, inline_data *));
+ static void remap_block PARAMS ((tree *, tree, inline_data *));
+ static tree add_stmt_to_compound PARAMS ((tree, tree, tree));
+ 
+ /* The approximate number of instructions per statement.  This number
+    need not be particularly accurate; it is used only to make
+    decisions about when a function is too big to inline.  */
+ #define INSNS_PER_STMT (10)
+ 
+ /* Remap DECL during the copying of the BLOCK tree for the function.  */
+ 
+ static tree
+ remap_decl (decl, id)
+      tree decl;
+      inline_data *id;
+ {
+   splay_tree_node n;
+   tree fn;
+ 
+   /* We only remap local variables in the current function.  */
+   fn = VARRAY_TOP_TREE (id->fns);
+   if (! (*lang_hooks.tree_inlining.auto_var_in_fn_p) (decl, fn))
+     return NULL_TREE;
+ 
+   /* See if we have remapped this declaration.  */
+   n = splay_tree_lookup (id->decl_map, (splay_tree_key) decl);
+   /* If we didn't already have an equivalent for this declaration,
+      create one now.  */
+   if (!n)
+     {
+       tree t;
+ 
+       /* Make a copy of the variable or label.  */
+       t = copy_decl_for_inlining (decl, fn,
+ 				  VARRAY_TREE (id->fns, 0));
+ 
+       /* The decl T could be a dynamic array or other variable size type,
+ 	 in which case some fields need to be remapped because they may
+ 	 contain SAVE_EXPRs.  */
+       if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE
+ 	  && TYPE_DOMAIN (TREE_TYPE (t)))
+ 	{
+ 	  TREE_TYPE (t) = copy_node (TREE_TYPE (t));
+ 	  TYPE_DOMAIN (TREE_TYPE (t))
+ 	    = copy_node (TYPE_DOMAIN (TREE_TYPE (t)));
+ 	  walk_tree (&TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (t))),
+ 		     copy_body_r, id, NULL);
+ 	}
+ 
+       /* Remember it, so that if we encounter this local entity
+ 	 again we can reuse this copy.  */
+       n = splay_tree_insert (id->decl_map,
+ 			     (splay_tree_key) decl,
+ 			     (splay_tree_value) t);
+     }
+ 
+   return (tree) n->value;
+ }
+ 
+ /* Copy the BLOCK to contain remapped versions of the variables
+    therein.  And hook the new block into the block-tree.  */
+ 
+ static void
+ remap_block (block, decls, id)
+      tree *block;
+      tree decls;
+      inline_data *id;
+ {
+   tree old_block;
+   tree new_block;
+   tree old_var;
+   tree fn;
+ 
+   /* Make the new block.  */
+   old_block = *block;
+   new_block = make_node (BLOCK);
+   TREE_USED (new_block) = TREE_USED (old_block);
+   BLOCK_ABSTRACT_ORIGIN (new_block) = old_block;
+   BLOCK_SUBBLOCKS (new_block) = BLOCK_SUBBLOCKS (old_block);
+   TREE_SIDE_EFFECTS (new_block) = TREE_SIDE_EFFECTS (old_block);
+   TREE_TYPE (new_block) = TREE_TYPE (old_block);
+   *block = new_block;
+ 
+   /* Remap its variables.  */
+   for (old_var = decls ? decls : BLOCK_VARS (old_block);
+        old_var;
+        old_var = TREE_CHAIN (old_var))
+     {
+       tree new_var;
+ 
+       /* Remap the variable.  */
+       new_var = remap_decl (old_var, id);
+       /* If we didn't remap this variable, so we can't mess with
+ 	 its TREE_CHAIN.  If we remapped this variable to
+ 	 something other than a declaration (say, if we mapped it
+ 	 to a constant), then we must similarly omit any mention
+ 	 of it here.  */
+       if (!new_var || !DECL_P (new_var))
+ 	;
+       else
+ 	{
+ 	  TREE_CHAIN (new_var) = BLOCK_VARS (new_block);
+ 	  BLOCK_VARS (new_block) = new_var;
+ 	}
+     }
+   /* We put the BLOCK_VARS in reverse order; fix that now.  */
+   BLOCK_VARS (new_block) = nreverse (BLOCK_VARS (new_block));
+   fn = VARRAY_TREE (id->fns, 0);
+   /* Remember the remapped block.  */
+   splay_tree_insert (id->decl_map,
+ 		     (splay_tree_key) old_block,
+ 		     (splay_tree_value) new_block);
+ }
+ 
+ static tree
+ copy_body_r (tp, walk_subtrees, data)
+      tree *tp;
+      int *walk_subtrees;
+      void *data;
+ {
+   inline_data* id;
+   tree fn;
+ 
+   /* Set up.  */
+   id = (inline_data *) data;
+   fn = VARRAY_TOP_TREE (id->fns);
+ 
+ #if 0
+   /* All automatic variables should have a DECL_CONTEXT indicating
+      what function they come from.  */
+   if ((TREE_CODE (*tp) == VAR_DECL || TREE_CODE (*tp) == LABEL_DECL)
+       && DECL_NAMESPACE_SCOPE_P (*tp))
+     if (! DECL_EXTERNAL (*tp) && ! TREE_STATIC (*tp))
+       abort ();
+ #endif
+ 
+   if (TREE_CODE (*tp) == BLOCK)
+     remap_block (tp, NULL_TREE, id);
+   /* If this is a RETURN_EXPR, change it into an assignment and a
+      GOTO_EXPR with the RET_LABEL as its target.  */
+   if (TREE_CODE (*tp) == RETURN_EXPR && id->ret_label)
+     {
+       tree return_stmt = *tp;
+       tree goto_stmt;
+ 
+       goto_stmt = build1 (GOTO_EXPR, void_type_node, id->ret_label);
+       TREE_SIDE_EFFECTS (goto_stmt) = 1;
+ 
+       {
+ 	/* If we're returning something, just turn that into an
+ 	 assignment into the equivalent of the original
+ 	 RESULT_DECL.  */
+ 
+ 	tree assignment = TREE_OPERAND (return_stmt, 0);
+ 	if (assignment)
+ 	  {
+ 	    copy_body_r (&assignment, walk_subtrees, data);
+ 	    *tp = build (COMPOUND_EXPR, void_type_node, assignment, goto_stmt);
+ 	    TREE_SIDE_EFFECTS (*tp) = 1;	    
+ 	  }
+ 	else
+ 	  {
+ 	    /* If we're not returning anything just do the jump.  */
+ 	    *tp = goto_stmt;
+ 	  }
+       }
+     }
+   /* Local variables and labels need to be replaced by equivalent
+      variables.  We don't want to copy static variables; there's only
+      one of those, no matter how many times we inline the containing
+      function.  */
+   else if ((*lang_hooks.tree_inlining.auto_var_in_fn_p) (*tp, fn))
+     {
+       tree new_decl;
+ 
+       /* Remap the declaration.  */
+       new_decl = remap_decl (*tp, id);
+       if (! new_decl)
+ 	abort ();
+       /* Replace this variable with the copy.  */
+       STRIP_TYPE_NOPS (new_decl);
+       *tp = new_decl;
+     }
+ #if 0
+   else if (nonstatic_local_decl_p (*tp)
+ 	   && DECL_CONTEXT (*tp) != VARRAY_TREE (id->fns, 0))
+     abort ();
+ #endif
+   else if (TREE_CODE (*tp) == SAVE_EXPR)
+     remap_save_expr (tp, id->decl_map, VARRAY_TREE (id->fns, 0),
+ 		     walk_subtrees);
+   else if (TREE_CODE (*tp) == UNSAVE_EXPR)
+     /* UNSAVE_EXPRs should not be generated until expansion time.  */
+     abort ();
+   else if (TREE_CODE (*tp) == LABELED_BLOCK_EXPR)
+     {
+       /* We need a new copy of this labeled block; the EXIT_BLOCK_EXPR
+          will refer to it, so save a copy ready for remapping.  We
+          save it in the decl_map, although it isn't a decl.  */
+       tree new_block = copy_node (*tp);
+       splay_tree_insert (id->decl_map,
+ 			 (splay_tree_key) *tp,
+ 			 (splay_tree_value) new_block);
+       *tp = new_block;
+     }
+   else if (TREE_CODE (*tp) == EXIT_BLOCK_EXPR)
+     {
+       splay_tree_node n 
+ 	= splay_tree_lookup (id->decl_map, 
+ 			     (splay_tree_key) TREE_OPERAND (*tp, 0));
+       /* We _must_ have seen the enclosing LABELED_BLOCK_EXPR.  */
+       if (! n)
+ 	abort ();
+       *tp = copy_node (*tp);
+       TREE_OPERAND (*tp, 0) = (tree) n->value;
+     }
+   /* Otherwise, just copy the node.  Note that copy_tree_r already
+      knows not to copy VAR_DECLs, etc., so this is safe.  */
+   else
+     {
+       copy_tree_r (tp, walk_subtrees, NULL);
+ 
+       /* The copied TARGET_EXPR has never been expanded, even if the
+ 	 original node was expanded already.  */
+       if (TREE_CODE (*tp) == TARGET_EXPR && TREE_OPERAND (*tp, 3))
+ 	{
+ 	  TREE_OPERAND (*tp, 1) = TREE_OPERAND (*tp, 3);
+ 	  TREE_OPERAND (*tp, 3) = NULL_TREE;
+ 	}
+       else if (TREE_CODE (*tp) == MODIFY_EXPR
+ 	       && TREE_OPERAND (*tp, 0) == TREE_OPERAND (*tp, 1)
+ 	       && ((*lang_hooks.tree_inlining.auto_var_in_fn_p)
+ 		   (TREE_OPERAND (*tp, 0), fn)))
+ 	{
+ 	  /* Some assignments VAR = VAR; don't generate any rtl code
+ 	     and thus don't count as variable modification.  Avoid
+ 	     keeping bogosities like 0 = 0.  */
+ 	  tree decl = TREE_OPERAND (*tp, 0), value;
+ 	  splay_tree_node n;
+ 
+ 	  n = splay_tree_lookup (id->decl_map, (splay_tree_key) decl);
+ 	  if (n)
+ 	    {
+ 	      value = (tree) n->value;
+ 	      STRIP_TYPE_NOPS (value);
+ 	      if (TREE_CONSTANT (value) || TREE_READONLY_DECL_P (value))
+ 		*tp = value;
+ 	    }
+ 	}
+     }
+ 
+   /* Keep iterating.  */
+   return NULL_TREE;
+ }
+ 
+ /* Make a copy of the body of FN so that it can be inserted inline in
+    another function.  */
+ 
+ static tree
+ copy_body (id)
+      inline_data *id;
+ {
+   tree body;
+ 
+   body = DECL_SAVED_TREE (VARRAY_TOP_TREE (id->fns));
+   walk_tree (&body, copy_body_r, id, NULL);
+ 
+   return body;
+ }
+ 
+ /* Generate code to initialize the parameters of the function at the
+    top of the stack in ID from the ARGS (presented as a TREE_LIST).  */
+ 
+ static tree
+ initialize_inlined_parameters (id, args, fn, block)
+      inline_data *id;
+      tree args;
+      tree fn;
+      tree block;
+ {
+   tree init_stmts;
+   tree vars;
+   tree parms;
+   tree a;
+   tree p;
+ 
+   /* Figure out what the parameters are.  */
+   parms = DECL_ARGUMENTS (fn);
+ 
+   /* Start with no initializations whatsoever.  */
+   init_stmts = NULL_TREE;
+   vars = NULL_TREE;
+ 
+   /* Loop through the parameter declarations, replacing each with an
+      equivalent VAR_DECL, appropriately initialized.  */
+   for (p = parms, a = args; p;
+        a = a ? TREE_CHAIN (a) : a, p = TREE_CHAIN (p))
+     {
+       tree var;
+       tree value;
+       tree cleanup;
+ 
+       /* Find the initializer.  */
+       value = (*lang_hooks.tree_inlining.convert_parm_for_inlining)
+ 	      (p, a ? TREE_VALUE (a) : NULL_TREE, fn);
+ 
+       /* If the parameter is never assigned to, we may not need to
+ 	 create a new variable here at all.  Instead, we may be able
+ 	 to just use the argument value.  */
+       if (TREE_READONLY (p)
+ 	  && !TREE_ADDRESSABLE (p)
+ 	  && value && !TREE_SIDE_EFFECTS (value))
+ 	{
+ 	  /* Simplify the value, if possible.  */
+ 	  value = fold (DECL_P (value) ? decl_constant_value (value) : value);
+ 
+ 	  /* We can't risk substituting complex expressions.  They
+ 	     might contain variables that will be assigned to later.
+ 	     Theoretically, we could check the expression to see if
+ 	     all of the variables that determine its value are
+ 	     read-only, but we don't bother.  */
+ 	  if (TREE_CONSTANT (value) || TREE_READONLY_DECL_P (value))
+ 	    {
+ 	      /* If this is a declaration, wrap it a NOP_EXPR so that
+ 		 we don't try to put the VALUE on the list of
+ 		 BLOCK_VARS.  */
+ 	      if (DECL_P (value))
+ 		value = build1 (NOP_EXPR, TREE_TYPE (value), value);
+ 
+ 	      splay_tree_insert (id->decl_map,
+ 				 (splay_tree_key) p,
+ 				 (splay_tree_value) value);
+ 	      continue;
+ 	    }
+ 	}
+ 
+       /* Make an equivalent VAR_DECL.  */
+       var = copy_decl_for_inlining (p, fn, VARRAY_TREE (id->fns, 0));
+       /* Register the VAR_DECL as the equivalent for the PARM_DECL;
+ 	 that way, when the PARM_DECL is encountered, it will be
+ 	 automatically replaced by the VAR_DECL.  */
+       splay_tree_insert (id->decl_map,
+ 			 (splay_tree_key) p,
+ 			 (splay_tree_value) var);
+ 
+       /* Declare this new variable.  */
+       TREE_CHAIN (var) = vars;
+       vars = var;
+ 
+       /* Initialize this VAR_DECL from the equivalent argument.  If
+ 	 the argument is an object, created via a constructor or copy,
+ 	 this will not result in an extra copy: the TARGET_EXPR
+ 	 representing the argument will be bound to VAR, and the
+ 	 object will be constructed in VAR.  */
+       if (! TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (p)))
+ 	{
+ 	  tree assignment = build (MODIFY_EXPR, TREE_TYPE (p), var, value);
+ 	  init_stmts = add_stmt_to_compound (init_stmts, TREE_TYPE (p), 
+ 					     assignment);
+ 	}
+       else
+ 	{
+ 	  /* Java objects don't ever need constructing when being
+              passed as arguments because only call by reference is
+              supported.  */
+ 	  abort ();
+ 	}
+ 
+       /* See if we need to clean up the declaration.  */
+       cleanup = (*lang_hooks.maybe_build_cleanup) (var);
+       if (cleanup)
+ 	{
+ 	  abort ();
+ 	}
+     }
+ 
+   BLOCK_VARS (block) = nreverse (vars);
+   return init_stmts;
+ }
+ 
+ /* Declare a return variable to replace the RESULT_DECL for the
+    function we are calling.  An appropriate decl is returned.  */
+ 
+ static tree
+ declare_return_variable (id, var)
+      struct inline_data *id;
+      tree *var;
+ {
+   tree fn = VARRAY_TOP_TREE (id->fns);
+   tree result = DECL_RESULT (fn);
+   int need_return_decl = 1;
+ 
+   /* We don't need to do anything for functions that don't return
+      anything.  */
+   if (!result || VOID_TYPE_P (TREE_TYPE (result)))
+     {
+       *var = NULL_TREE;
+       return NULL_TREE;
+     }
+ 
+   *var = ((*lang_hooks.tree_inlining.copy_res_decl_for_inlining)
+ 	 (result, fn, VARRAY_TREE (id->fns, 0), id->decl_map,
+ 	  &need_return_decl, NULL_TREE));
+ 
+   /* Register the VAR_DECL as the equivalent for the RESULT_DECL; that
+      way, when the RESULT_DECL is encountered, it will be
+      automatically replaced by the VAR_DECL.  */
+   splay_tree_insert (id->decl_map,
+ 		     (splay_tree_key) result,
+ 		     (splay_tree_value) *var);
+ 
+   DECL_IGNORED_P (*var) = 1;
+ 
+   /* Build the declaration statement if FN does not return an
+      aggregate.  */
+   if (need_return_decl)
+     return *var;
+   /* If FN does return an aggregate, there's no need to declare the
+      return variable; we're using a variable in our caller's frame.  */
+   else
+     return NULL_TREE;
+ }
+ 
+ /* Returns non-zero if a function can be inlined as a tree.  */
+ 
+ int
+ tree_inlinable_function_p (fn)
+      tree fn;
+ {
+   return inlinable_function_p (fn, NULL);
+ }
+ 
+ /* Returns non-zero if FN is a function that can be inlined into the
+    inlining context ID_.  If ID_ is NULL, check whether the function
+    can be inlined at all.  */
+ 
+ static int
+ inlinable_function_p (fn, id)
+      tree fn;
+      inline_data *id;
+ {
+   int inlinable;
+   int currfn_insns;
+ 
+   /* If we've already decided this function shouldn't be inlined,
+      there's no need to check again.  */
+   if (DECL_UNINLINABLE (fn))
+     return 0;
+ 
+   /* Assume it is not inlinable.  */
+   inlinable = 0;
+ 
+   /* The number of instructions (estimated) of current function.  */
+   currfn_insns = DECL_NUM_STMTS (fn) * INSNS_PER_STMT;
+ 
+   /* If we're not inlining things, then nothing is inlinable.  */
+   if (! flag_inline_trees)
+     ;
+   /* If we're not inlining all functions and the function was not
+      declared `inline', we don't inline it.  Don't think of
+      disregarding DECL_INLINE when flag_inline_trees == 2; it's the
+      front-end that must set DECL_INLINE in this case, because
+      dwarf2out loses if a function is inlined that doesn't have
+      DECL_INLINE set.  */
+   else if (! DECL_INLINE (fn))
+     ;
+   /* We can't inline functions that are too big.  Only allow a single
+      function to be of MAX_INLINE_INSNS_SINGLE size.  Make special
+      allowance for extern inline functions, though.  */
+   else if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn)
+ 	   && currfn_insns > MAX_INLINE_INSNS_SINGLE)
+     ;
+   /* All is well.  We can inline this function.  Traditionally, GCC
+      has refused to inline functions using alloca, or functions whose
+      values are returned in a PARALLEL, and a few other such obscure
+      conditions.  We are not equally constrained at the tree level.  */
+   else
+     inlinable = 1;
+ 
+   /* Squirrel away the result so that we don't have to check again.  */
+   DECL_UNINLINABLE (fn) = ! inlinable;
+ 
+   /* In case we don't disregard the inlining limits and we basically
+      can inline this function, investigate further.  */
+   if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn)
+       && inlinable)
+     {
+       int sum_insns = (id ? id->inlined_stmts : 0) * INSNS_PER_STMT
+ 		     + currfn_insns;
+       /* In the extreme case that we have exceeded the recursive inlining
+          limit by a huge factor (128), we just say no. Should not happen
+          in real life.  */
+       if (sum_insns > MAX_INLINE_INSNS * 128)
+ 	 inlinable = 0;
+       /* If we did not hit the extreme limit, we use a linear function
+          with slope -1/MAX_INLINE_SLOPE to exceedingly decrease the
+          allowable size. We always allow a size of MIN_INLINE_INSNS
+          though.  */
+       else if ((sum_insns > MAX_INLINE_INSNS)
+ 	       && (currfn_insns > MIN_INLINE_INSNS))
+ 	{
+ 	  int max_curr = MAX_INLINE_INSNS_SINGLE
+ 			- (sum_insns - MAX_INLINE_INSNS) / MAX_INLINE_SLOPE;
+ 	  if (currfn_insns > max_curr)
+ 	    inlinable = 0;
+ 	}
+     }
+ 
+   if (inlinable && (*lang_hooks.tree_inlining.cannot_inline_tree_fn) (&fn))
+     inlinable = 0;
+ 
+   /* If we don't have the function body available, we can't inline
+      it.  */
+   if (! DECL_SAVED_TREE (fn))
+     inlinable = 0;
+ 
+   /* Check again, language hooks may have modified it.  */
+   if (! inlinable || DECL_UNINLINABLE (fn))
+     return 0;
+ 
+   /* Don't do recursive inlining, either.  We don't record this in
+      DECL_UNINLINABLE; we may be able to inline this function later.  */
+   if (id)
+     {
+       size_t i;
+ 
+       for (i = 0; i < VARRAY_ACTIVE_SIZE (id->fns); ++i)
+ 	if (VARRAY_TREE (id->fns, i) == fn)
+ 	  return 0;
+ 
+       if (DECL_INLINED_FNS (fn))
+ 	{
+ 	  int j;
+ 	  tree inlined_fns = DECL_INLINED_FNS (fn);
+ 
+ 	  for (j = 0; j < TREE_VEC_LENGTH (inlined_fns); ++j)
+ 	    if (TREE_VEC_ELT (inlined_fns, j) == VARRAY_TREE (id->fns, 0))
+ 	      return 0;
+ 	}
+     }
+ 
+   /* Return the result.  */
+   return inlinable;
+ }
+ 
+ /* If *TP is a CALL_EXPR, replace it with its inline expansion.  */
+ 
+ static tree
+ expand_call_inline (tp, walk_subtrees, data)
+      tree *tp;
+      int *walk_subtrees;
+      void *data;
+ {
+   inline_data *id;
+   tree t;
+   tree expr;
+   tree stmt;
+   tree fn;
+   tree retvar;
+   tree arg_inits;
+   tree *inlined_body;
+   splay_tree st;
+ 
+   /* See what we've got.  */
+   id = (inline_data *) data;
+   t = *tp;
+ 
+   if (TREE_CODE (*tp) == TARGET_EXPR)
+     {
+       abort ();
+     }
+ 
+   if (TYPE_P (t))
+     /* Because types were not copied in copy_body, CALL_EXPRs beneath
+        them should not be expanded.  This can happen if the type is a
+        dynamic array type, for example.  */
+     *walk_subtrees = 0;
+ 
+   /* From here on, we're only interested in CALL_EXPRs.  */
+   if (TREE_CODE (t) != CALL_EXPR)
+     return NULL_TREE;
+ 
+   /* First, see if we can figure out what function is being called.
+      If we cannot, then there is no hope of inlining the function.  */
+   fn = get_callee_fndecl (t);
+   if (!fn)
+     return NULL_TREE;
+ 
+   /* If fn is a declaration of a function in a nested scope that was
+      globally declared inline, we don't set its DECL_INITIAL.
+      However, we can't blindly follow DECL_ABSTRACT_ORIGIN because the
+      C++ front-end uses it for cdtors to refer to their internal
+      declarations, that are not real functions.  Fortunately those
+      don't have trees to be saved, so we can tell by checking their
+      DECL_SAVED_TREE.  */
+   if (! DECL_INITIAL (fn)
+       && DECL_ABSTRACT_ORIGIN (fn)
+       && DECL_SAVED_TREE (DECL_ABSTRACT_ORIGIN (fn)))
+     fn = DECL_ABSTRACT_ORIGIN (fn);
+ 
+   /* Don't try to inline functions that are not well-suited to
+      inlining.  */
+   if (!inlinable_function_p (fn, id))
+     return NULL_TREE;
+ 
+   if (! (*lang_hooks.tree_inlining.start_inlining) (fn))
+     return NULL_TREE;
+ 
+ #if 0
+   /* Useful if you want to know eactly what is being inlined.  */
+   {
+     const char *name = IDENTIFIER_POINTER (DECL_NAME (fn));
+     FILE *f = fopen ("/tmp/foo", "a");
+     fprintf (f, "inlining %s in %s\n", name,
+ 	   IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
+     fclose (f);	   
+   }
+ #endif
+ 
+   /* Set the current filename and line number to the function we are
+      inlining so that when we create new _EXPR nodes here they get
+      line numbers corresponding to the function we are calling.  We
+      wrap the whole inlined body in an EXPR_WITH_FILE_AND_LINE as well
+      because individual statements don't record the filename.  */
+   push_srcloc (DECL_SOURCE_FILE (fn), DECL_SOURCE_LINE (fn));
+ 
+   /* Build a block containing code to initialize the arguments, the
+      actual inline expansion of the body, and a label for the return
+      statements within the function to jump to.  The type of the
+      statement expression is the return type of the function call.  */
+   stmt = NULL;
+   expr = build (BLOCK, TREE_TYPE (TREE_TYPE (fn)), stmt);
+ 
+   /* Local declarations will be replaced by their equivalents in this
+      map.  */
+   st = id->decl_map;
+   id->decl_map = splay_tree_new (splay_tree_compare_pointers,
+ 				 NULL, NULL);
+ 
+   /* Initialize the parameters.  */
+   arg_inits = initialize_inlined_parameters (id, TREE_OPERAND (t, 1), fn, expr);
+ 
+   if (arg_inits)
+     {
+       /* Expand any inlined calls in the initializers.  Do this before we
+ 	 push FN on the stack of functions we are inlining; we want to
+ 	 inline calls to FN that appear in the initializers for the
+ 	 parameters.  */
+       expand_calls_inline (&arg_inits, id);
+       
+       /* And add them to the tree.  */
+       BLOCK_EXPR_BODY (expr) = add_stmt_to_compound (BLOCK_EXPR_BODY (expr), 
+ 						     TREE_TYPE (arg_inits), 
+ 						     arg_inits);
+     }
+ 
+   /* Record the function we are about to inline so that we can avoid
+      recursing into it.  */
+   VARRAY_PUSH_TREE (id->fns, fn);
+ 
+   /* Record the function we are about to inline if optimize_function
+      has not been called on it yet and we don't have it in the list.  */
+   if (! DECL_INLINED_FNS (fn))
+     {
+       int i;
+ 
+       for (i = VARRAY_ACTIVE_SIZE (id->inlined_fns) - 1; i >= 0; i--)
+ 	if (VARRAY_TREE (id->inlined_fns, i) == fn)
+ 	  break;
+       if (i < 0)
+ 	VARRAY_PUSH_TREE (id->inlined_fns, fn);
+     }
+ 
+   /* Return statements in the function body will be replaced by jumps
+      to the RET_LABEL.  */
+   id->ret_label =  build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+   DECL_CONTEXT (id->ret_label) = VARRAY_TREE (id->fns, 0);
+ 
+   if (! DECL_INITIAL (fn)
+       || TREE_CODE (DECL_INITIAL (fn)) != BLOCK)
+     abort ();
+ 
+   {
+     /* Declare the return variable for the function.  */
+     tree decl = declare_return_variable (id, &retvar);
+     if (retvar)
+       {
+ 	tree *next = &BLOCK_VARS (expr);
+ 	while (*next)
+ 	  next = &TREE_CHAIN (*next);	
+ 	*next = decl;
+       }
+   }
+ 
+   /* After we've initialized the parameters, we insert the body of the
+      function itself.  */
+   {
+     tree new_body = copy_body (id);
+     TREE_TYPE (new_body) = TREE_TYPE (TREE_TYPE (fn));
+     BLOCK_EXPR_BODY (expr)
+       = add_stmt_to_compound (BLOCK_EXPR_BODY (expr), 
+ 			      TREE_TYPE (new_body), new_body);
+     inlined_body = &BLOCK_EXPR_BODY (expr);
+   }
+ 
+   /* After the body of the function comes the RET_LABEL.  This must come
+      before we evaluate the returned value below, because that evalulation
+      may cause RTL to be generated.  */
+   {
+     tree label = build1 (LABEL_EXPR, void_type_node, id->ret_label);
+     BLOCK_EXPR_BODY (expr)
+       = add_stmt_to_compound (BLOCK_EXPR_BODY (expr), void_type_node, label);
+     TREE_SIDE_EFFECTS (label) = TREE_SIDE_EFFECTS (t);
+   }
+ 
+   /* Finally, mention the returned value so that the value of the
+      statement-expression is the returned value of the function.  */
+   if (retvar)
+     BLOCK_EXPR_BODY (expr) 
+       = add_stmt_to_compound (BLOCK_EXPR_BODY (expr), 
+ 			      TREE_TYPE (retvar), retvar);
+ 
+   /* Clean up.  */
+   splay_tree_delete (id->decl_map);
+   id->decl_map = st;
+ 
+   /* The new expression has side-effects if the old one did.  */
+   TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (t);
+ 
+   /* Replace the call by the inlined body.  Wrap it in an
+      EXPR_WITH_FILE_LOCATION so that we'll get debugging line notes
+      pointing to the right place.  */
+   *tp = build_expr_wfl (expr, DECL_SOURCE_FILE (fn), 
+ 			DECL_SOURCE_LINE_FIRST(fn),
+ 			/*col=*/0);
+   EXPR_WFL_EMIT_LINE_NOTE (*tp) = 1;
+   pop_srcloc ();
+ 
+   /* If the value of the new expression is ignored, that's OK.  We
+      don't warn about this for CALL_EXPRs, so we shouldn't warn about
+      the equivalent inlined version either.  */
+   TREE_USED (*tp) = 1;
+ 
+   /* Our function now has more statements than it did before.  */
+   DECL_NUM_STMTS (VARRAY_TREE (id->fns, 0)) += DECL_NUM_STMTS (fn);
+   /* For accounting, subtract one for the saved call/ret.  */
+   id->inlined_stmts += DECL_NUM_STMTS (fn) - 1;
+ 
+   /* Recurse into the body of the just inlined function.  */
+   expand_calls_inline (inlined_body, id);
+   VARRAY_POP (id->fns);
+ 
+   /* If we've returned to the top level, clear out the record of how
+      much inlining has been done.  */
+   if (VARRAY_ACTIVE_SIZE (id->fns) == id->first_inlined_fn)
+     id->inlined_stmts = 0;
+ 
+   /* Don't walk into subtrees.  We've already handled them above.  */
+   *walk_subtrees = 0;
+ 
+   (*lang_hooks.tree_inlining.end_inlining) (fn);
+ 
+   /* Keep iterating.  */
+   return NULL_TREE;
+ }
+ 
+ /* Walk over the entire tree *TP, replacing CALL_EXPRs with inline
+    expansions as appropriate.  */
+ 
+ static void
+ expand_calls_inline (tp, id)
+      tree *tp;
+      inline_data *id;
+ {
+   /* Search through *TP, replacing all calls to inline functions by
+      appropriate equivalents.  Use walk_tree in no-duplicates mode
+      to avoid exponential time complexity.  (We can't just use
+      walk_tree_without_duplicates, because of the special TARGET_EXPR
+      handling in expand_calls.  The hash table is set up in
+      optimize_function.  */
+   walk_tree (tp, expand_call_inline, id, id->tree_pruner);
+ }
+ 
+ /* Expand calls to inline functions in the body of FN.  */
+ 
+ void
+ optimize_inline_calls (fn)
+      tree fn;
+ {
+   inline_data id;
+   tree prev_fn;
+ 
+   /* Clear out ID.  */
+   memset (&id, 0, sizeof (id));
+ 
+   /* Don't allow recursion into FN.  */
+   VARRAY_TREE_INIT (id.fns, 32, "fns");
+   VARRAY_PUSH_TREE (id.fns, fn);
+   /* Or any functions that aren't finished yet.  */
+   prev_fn = NULL_TREE;
+   if (current_function_decl)
+     {
+       VARRAY_PUSH_TREE (id.fns, current_function_decl);
+       prev_fn = current_function_decl;
+     }
+ 
+   prev_fn = ((*lang_hooks.tree_inlining.add_pending_fn_decls)
+ 	     (&id.fns, prev_fn));
+ 
+   /* Create the list of functions this call will inline.  */
+   VARRAY_TREE_INIT (id.inlined_fns, 32, "inlined_fns");
+ 
+   /* Keep track of the low-water mark, i.e., the point where the first
+      real inlining is represented in ID.FNS.  */
+   id.first_inlined_fn = VARRAY_ACTIVE_SIZE (id.fns);
+ 
+   /* Replace all calls to inline functions with the bodies of those
+      functions.  */
+   id.tree_pruner = htab_create (37, htab_hash_pointer,
+ 				htab_eq_pointer, NULL);
+   expand_calls_inline (&DECL_SAVED_TREE (fn), &id);
+ 
+   /* Clean up.  */
+   htab_delete (id.tree_pruner);
+   if (DECL_LANG_SPECIFIC (fn))
+     {
+       tree ifn = make_tree_vec (VARRAY_ACTIVE_SIZE (id.inlined_fns));
+ 
+       memcpy (&TREE_VEC_ELT (ifn, 0), &VARRAY_TREE (id.inlined_fns, 0),
+ 	      VARRAY_ACTIVE_SIZE (id.inlined_fns) * sizeof (tree));
+       DECL_INLINED_FNS (fn) = ifn;
+     }
+ }
+ 
+ /* FN is a function that has a complete body, and CLONE is a function
+    whose body is to be set to a copy of FN, mapping argument
+    declarations according to the ARG_MAP splay_tree.  */
+ 
+ void
+ clone_body (clone, fn, arg_map)
+      tree clone, fn;
+      void *arg_map;
+ {
+   inline_data id;
+ 
+   /* Clone the body, as if we were making an inline call.  But, remap
+      the parameters in the callee to the parameters of caller.  If
+      there's an in-charge parameter, map it to an appropriate
+      constant.  */
+   memset (&id, 0, sizeof (id));
+   VARRAY_TREE_INIT (id.fns, 2, "fns");
+   VARRAY_PUSH_TREE (id.fns, clone);
+   VARRAY_PUSH_TREE (id.fns, fn);
+   id.decl_map = (splay_tree)arg_map;
+ 
+   /* Cloning is treated slightly differently from inlining.  Set
+      CLONING_P so that it's clear which operation we're performing.  */
+   id.cloning_p = true;
+ 
+   /* Actually copy the body.  */
+   TREE_CHAIN (DECL_SAVED_TREE (clone)) = copy_body (&id);
+ }
+ 
+ /* Apply FUNC to all the sub-trees of TP in a pre-order traversal.
+    FUNC is called with the DATA and the address of each sub-tree.  If
+    FUNC returns a non-NULL value, the traversal is aborted, and the
+    value returned by FUNC is returned.  If HTAB is non-NULL it is used
+    to record the nodes visited, and to avoid visiting a node more than
+    once.  */
+ 
+ tree
+ walk_tree (tp, func, data, htab_)
+      tree *tp;
+      walk_tree_fn func;
+      void *data;
+      void *htab_;
+ {
+   htab_t htab = (htab_t) htab_;
+   enum tree_code code;
+   int walk_subtrees;
+   tree result;
+ 
+ #define WALK_SUBTREE(NODE)				\
+   do							\
+     {							\
+       result = walk_tree (&(NODE), func, data, htab);	\
+       if (result)					\
+ 	return result;					\
+     }							\
+   while (0)
+ 
+ #define WALK_SUBTREE_TAIL(NODE)				\
+   do							\
+     {							\
+        tp = & (NODE);					\
+        goto tail_recurse;				\
+     }							\
+   while (0)
+ 
+  tail_recurse:
+   /* Skip empty subtrees.  */
+   if (!*tp)
+     return NULL_TREE;
+ 
+   if (htab)
+     {
+       void **slot;
+ 
+       /* Don't walk the same tree twice, if the user has requested
+          that we avoid doing so.  */
+       if (htab_find (htab, *tp))
+ 	return NULL_TREE;
+       /* If we haven't already seen this node, add it to the table.  */
+       slot = htab_find_slot (htab, *tp, INSERT);
+       *slot = *tp;
+     }
+ 
+   /* Call the function.  */
+   walk_subtrees = 1;
+   result = (*func) (tp, &walk_subtrees, data);
+ 
+   /* If we found something, return it.  */
+   if (result)
+     return result;
+ 
+   code = TREE_CODE (*tp);
+ 
+   /* Handle common cases up front.  */
+   if (code != EXIT_BLOCK_EXPR
+       && code != SAVE_EXPR
+       && (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
+ 	  || TREE_CODE_CLASS (code) == 'r'
+ 	  || TREE_CODE_CLASS (code) == 's'))
+     {
+       int i, len;
+ 
+       /* Walk over all the sub-trees of this operand.  */
+       len = first_rtl_op (code);
+       /* TARGET_EXPRs are peculiar: operands 1 and 3 can be the same.
+ 	 But, we only want to walk once.  */
+       if (code == TARGET_EXPR
+ 	  && TREE_OPERAND (*tp, 3) == TREE_OPERAND (*tp, 1))
+ 	--len;
+       /* Go through the subtrees.  We need to do this in forward order so
+          that the scope of a FOR_EXPR is handled properly.  */
+       for (i = 0; i < len; ++i)
+ 	WALK_SUBTREE (TREE_OPERAND (*tp, i));
+ 
+       /* We didn't find what we were looking for.  */
+       return NULL_TREE;
+     }
+   else if (TREE_CODE_CLASS (code) == 'd')
+     {
+       WALK_SUBTREE_TAIL (TREE_TYPE (*tp));
+     }
+ 
+   result = (*lang_hooks.tree_inlining.walk_subtrees) (tp, &walk_subtrees, func,
+ 						      data, htab);
+   if (result || ! walk_subtrees)
+     return result;
+ 
+   /* Not one of the easy cases.  We must explicitly go through the
+      children.  */
+   switch (code)
+     {
+     case ERROR_MARK:
+     case IDENTIFIER_NODE:
+     case INTEGER_CST:
+     case REAL_CST:
+     case VECTOR_CST:
+     case STRING_CST:
+     case REAL_TYPE:
+     case COMPLEX_TYPE:
+     case VECTOR_TYPE:
+     case VOID_TYPE:
+     case BOOLEAN_TYPE:
+     case UNION_TYPE:
+     case ENUMERAL_TYPE:
+     case BLOCK:
+     case RECORD_TYPE:
+       /* None of thse have subtrees other than those already walked
+          above.  */
+       break;
+ 
+     case POINTER_TYPE:
+     case REFERENCE_TYPE:
+       WALK_SUBTREE_TAIL (TREE_TYPE (*tp));
+       break;
+ 
+     case TREE_LIST:
+       WALK_SUBTREE (TREE_VALUE (*tp));
+       WALK_SUBTREE_TAIL (TREE_CHAIN (*tp));
+       break;
+ 
+     case TREE_VEC:
+       {
+ 	int len = TREE_VEC_LENGTH (*tp);
+ 
+ 	if (len == 0)
+ 	  break;
+ 
+ 	/* Walk all elements but the first.  */
+ 	while (--len)
+ 	  WALK_SUBTREE (TREE_VEC_ELT (*tp, len));
+ 
+ 	/* Now walk the first one as a tail call.  */
+ 	WALK_SUBTREE_TAIL (TREE_VEC_ELT (*tp, 0));
+       }
+ 
+     case COMPLEX_CST:
+       WALK_SUBTREE (TREE_REALPART (*tp));
+       WALK_SUBTREE_TAIL (TREE_IMAGPART (*tp));
+ 
+     case CONSTRUCTOR:
+       WALK_SUBTREE_TAIL (CONSTRUCTOR_ELTS (*tp));
+ 
+     case METHOD_TYPE:
+       WALK_SUBTREE (TYPE_METHOD_BASETYPE (*tp));
+       /* Fall through.  */
+ 
+     case FUNCTION_TYPE:
+       WALK_SUBTREE (TREE_TYPE (*tp));
+       {
+ 	tree arg = TYPE_ARG_TYPES (*tp);
+ 
+ 	/* We never want to walk into default arguments.  */
+ 	for (; arg; arg = TREE_CHAIN (arg))
+ 	  WALK_SUBTREE (TREE_VALUE (arg));
+       }
+       break;
+ 
+     case ARRAY_TYPE:
+       WALK_SUBTREE (TREE_TYPE (*tp));
+       WALK_SUBTREE_TAIL (TYPE_DOMAIN (*tp));
+ 
+     case INTEGER_TYPE:
+       WALK_SUBTREE (TYPE_MIN_VALUE (*tp));
+       WALK_SUBTREE_TAIL (TYPE_MAX_VALUE (*tp));
+ 
+     case OFFSET_TYPE:
+       WALK_SUBTREE (TREE_TYPE (*tp));
+       WALK_SUBTREE_TAIL (TYPE_OFFSET_BASETYPE (*tp));
+ 
+     case EXIT_BLOCK_EXPR:
+       WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, 1));
+ 
+     case SAVE_EXPR:
+       WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, 0));
+ 
+     default:
+       abort ();
+     }
+ 
+   /* We didn't find what we were looking for.  */
+   return NULL_TREE;
+ 
+ #undef WALK_SUBTREE
+ }
+ 
+ /* Like walk_tree, but does not walk duplicate nodes more than
+    once.  */
+ 
+ tree
+ walk_tree_without_duplicates (tp, func, data)
+      tree *tp;
+      walk_tree_fn func;
+      void *data;
+ {
+   tree result;
+   htab_t htab;
+ 
+   htab = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);
+   result = walk_tree (tp, func, data, htab);
+   htab_delete (htab);
+   return result;
+ }
+ 
+ /* Passed to walk_tree.  Copies the node pointed to, if appropriate.  */
+ 
+ tree
+ copy_tree_r (tp, walk_subtrees, data)
+      tree *tp;
+      int *walk_subtrees;
+      void *data ATTRIBUTE_UNUSED;
+ {
+   enum tree_code code = TREE_CODE (*tp);
+ 
+   /* We make copies of most nodes.  */
+   if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
+       || TREE_CODE_CLASS (code) == 'r'
+       || TREE_CODE_CLASS (code) == 'c'
+       || TREE_CODE_CLASS (code) == 's'
+       || code == TREE_LIST
+       || code == TREE_VEC
+       || (*lang_hooks.tree_inlining.tree_chain_matters_p) (*tp))
+     {
+       /* Because the chain gets clobbered when we make a copy, we save it
+ 	 here.  */
+       tree chain = TREE_CHAIN (*tp);
+ 
+       /* Copy the node.  */
+       *tp = copy_node (*tp);
+ 
+       /* Now, restore the chain, if appropriate.  That will cause
+ 	 walk_tree to walk into the chain as well.  */
+       if (code == PARM_DECL || code == TREE_LIST
+ 	  || (*lang_hooks.tree_inlining.tree_chain_matters_p) (*tp))
+ 	TREE_CHAIN (*tp) = chain;
+     }
+   else if (TREE_CODE_CLASS (code) == 't')
+     /* There's no need to copy types, or anything beneath them.  */
+     *walk_subtrees = 0;
+ 
+   return NULL_TREE;
+ }
+ 
+ /* The SAVE_EXPR pointed to by TP is being copied.  If ST contains
+    information indicating to what new SAVE_EXPR this one should be
+    mapped, use that one.  Otherwise, create a new node and enter it in
+    ST.  FN is the function into which the copy will be placed.  */
+ 
+ void
+ remap_save_expr (tp, st_, fn, walk_subtrees)
+      tree *tp;
+      void *st_;
+      tree fn;
+      int *walk_subtrees;
+ {
+   splay_tree st = (splay_tree) st_;
+   splay_tree_node n;
+ 
+   /* See if we already encountered this SAVE_EXPR.  */
+   n = splay_tree_lookup (st, (splay_tree_key) *tp);
+ 
+   if (n && (tree)n->value == error_mark_node)
+     abort ();
+ 
+   /* If we didn't already remap this SAVE_EXPR, do so now.  */
+   if (!n)
+     {
+       tree t = copy_node (*tp);
+ 
+       /* The SAVE_EXPR is now part of the function into which we
+ 	 are inlining this body.  */
+       SAVE_EXPR_CONTEXT (t) = fn;
+       /* And we haven't evaluated it yet.  */
+       SAVE_EXPR_RTL (t) = NULL_RTX;
+       /* Remember this SAVE_EXPR.  */
+       n = splay_tree_insert (st,
+ 			     (splay_tree_key) *tp,
+ 			     (splay_tree_value) t);
+       /* Make sure we don't remap an already-remapped SAVE_EXPR.  */
+       splay_tree_insert (st, (splay_tree_key) t,
+ 			 (splay_tree_value) error_mark_node);
+     }
+   else
+     /* We've already walked into this SAVE_EXPR, so we needn't do it
+        again.  */
+     *walk_subtrees = 0;
+ 
+   /* Replace this SAVE_EXPR with the copy.  */
+   *tp = (tree) n->value;
+ }
+ 
+ /* Add STMT to EXISTING if possible, otherwise create a new
+    COMPOUND_EXPR and add STMT to it. */
+ 
+ static tree
+ add_stmt_to_compound (existing, type, stmt)
+      tree existing, type, stmt;
+ {
+   if (!stmt)
+     return existing;
+   else if (existing)
+     return build (COMPOUND_EXPR, type, existing, stmt);
+   else
+     return stmt;
+ }
+ 
Index: java/java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.153
diff -p -2 -c -r1.153 java-tree.h
*** java/java-tree.h	11 Jun 2002 17:31:10 -0000	1.153
--- java/java-tree.h	1 Jul 2002 18:12:24 -0000
*************** union lang_tree_node 
*** 903,906 ****
--- 903,912 ----
  #define DECL_FIELD_FINAL_WFL(NODE) \
    (DECL_LANG_SPECIFIC(NODE)->u.v.wfl)
+ /* In a FUNCTION_DECL for which DECL_BUILT_IN does not hold, this is
+      the approximate number of statements in this function.  There is
+      no need for this number to be exact; it is only used in various
+      heuristics regarding optimization.  */
+ #define DECL_NUM_STMTS(NODE) \
+   (FUNCTION_DECL_CHECK (NODE)->decl.u1.i)
  /* True if NODE is a local variable final. */
  #define LOCAL_FINAL_P(NODE) (DECL_LANG_SPECIFIC (NODE) && DECL_FINAL (NODE))
*************** extern void append_gpp_mangled_name PARA
*** 1274,1277 ****
--- 1280,1286 ----
  extern void add_predefined_file PARAMS ((tree));
  extern int predefined_filename_p PARAMS ((tree));
+ 
+ extern void java_optimize_inline PARAMS ((tree));
+ extern tree decl_constant_value PARAMS ((tree));
  
  #if defined(RTX_CODE) && defined (HAVE_MACHINE_MODES)
Index: java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.103
diff -p -2 -c -r1.103 lang.c
*** java/lang.c	10 Jun 2002 05:11:42 -0000	1.103
--- java/lang.c	1 Jul 2002 18:12:25 -0000
*************** The Free Software Foundation is independ
*** 41,44 ****
--- 41,45 ----
  #include "ggc.h"
  #include "diagnostic.h"
+ #include "tree-inline.h"
  
  struct string_option
*************** static int process_option_with_no PARAMS
*** 62,65 ****
--- 63,71 ----
  					   const struct string_option *,
  					   int));
+ static tree java_tree_inlining_walk_subtrees  PARAMS ((tree *,
+ 						       int *,
+ 						       walk_tree_fn,
+ 						       void *,
+ 						       void *));
  
  #ifndef TARGET_OBJECT_SUFFIX
*************** struct language_function GTY(())
*** 263,266 ****
--- 269,275 ----
  #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE java_signed_or_unsigned_type
  
+ #undef LANG_HOOKS_TREE_INLINING_WALK_SUBTREES
+ #define LANG_HOOKS_TREE_INLINING_WALK_SUBTREES java_tree_inlining_walk_subtrees
+ 
  /* Each front end provides its own.  */
  const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
*************** java_init (filename)
*** 494,497 ****
--- 503,509 ----
  #endif
  
+   if (flag_inline_functions)
+     flag_inline_trees = 1;
+ 
    /* Open input file.  */
  
*************** static void
*** 784,792 ****
  java_post_options ()
  {
!   /* Turn off RTL inliner unless -finline-functions was really specified.  */
!   if (flag_really_inline == 0)
      {
!       flag_no_inline = 1;
!       flag_inline_functions = 0;
      }
  }
--- 796,881 ----
  java_post_options ()
  {
!  /* Use tree inlining if possible.  Function instrumentation is only
!      done in the RTL level, so we disable tree inlining.  */
!   if (! flag_instrument_function_entry_exit)
!     {
!       if (!flag_no_inline)
! 	flag_no_inline = 1;
!       if (flag_inline_functions)
! 	{
! 	  flag_inline_trees = 2;
! 	  flag_inline_functions = 0;
! 	}
!     }
! 
! }
! 
! /* Return either DECL or its known constant value (if it has one).  */
! 
! tree
! decl_constant_value (decl)
!      tree decl;
! {
!   if (/* Don't change a variable array bound or initial value to a constant
! 	 in a place where a variable is invalid.  */
!       current_function_decl != 0
!       && ! TREE_THIS_VOLATILE (decl)
!       && TREE_READONLY (decl)
!       && DECL_INITIAL (decl) != 0
!       && TREE_CODE (DECL_INITIAL (decl)) != ERROR_MARK
!       /* This is invalid if initial value is not constant.
! 	 If it has either a function call, a memory reference,
! 	 or a variable, then re-evaluating it could give different results.  */
!       && TREE_CONSTANT (DECL_INITIAL (decl))
!       /* Check for cases where this is sub-optimal, even though valid.  */
!       && TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR)
!     return DECL_INITIAL (decl);
!   return decl;
! }
! 
! /* Walk the language specific tree nodes during inlining.  */
! 
! static tree
! java_tree_inlining_walk_subtrees (tp,subtrees,func,data,htab)
!      tree *tp ATTRIBUTE_UNUSED;
!      int *subtrees ATTRIBUTE_UNUSED;
!      walk_tree_fn func ATTRIBUTE_UNUSED;
!      void *data ATTRIBUTE_UNUSED;
!      void *htab ATTRIBUTE_UNUSED;
! {
!   enum tree_code code;
!   tree result;
! 
! #define WALK_SUBTREE(NODE)				\
!   do							\
!     {							\
!       result = walk_tree (&(NODE), func, data, htab);	\
!       if (result)					\
! 	return result;					\
!     }							\
!   while (0)
! 
!   tree t = *tp;
!   if (!t)
!     return NULL_TREE;
! 
!   code = TREE_CODE (t);
!   switch (code)
      {
!     case BLOCK:
!       if (BLOCK_EXPR_BODY (t))
! 	{
! 	  tree *prev = &BLOCK_EXPR_BODY (*tp);
! 	  while (*prev)
! 	    {
! 	      WALK_SUBTREE (*prev);
! 	      prev = &TREE_CHAIN (*prev);
! 	    }	    
! 	}
!       return NULL_TREE;
!       break;
! 
!     default:
!       return NULL_TREE;
      }
  }
Index: java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.389
diff -p -2 -c -r1.389 parse.y
*** java/parse.y	27 Jun 2002 01:53:42 -0000	1.389
--- java/parse.y	1 Jul 2002 18:12:33 -0000
*************** definitions and other extensions.  */
*** 68,71 ****
--- 68,72 ----
  #include "ggc.h"
  #include "debug.h"
+ #include "tree-inline.h"
  
  #ifndef DIR_SEPARATOR
*************** source_end_java_method ()
*** 7479,7482 ****
--- 7480,7485 ----
    dump_java_tree (TDI_original, fndecl);
  
+   java_optimize_inline (fndecl); 
+ 
    /* Generate function's code */
    if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
*************** add_stmt_to_compound (existing, type, st
*** 7540,7543 ****
--- 7543,7550 ----
       tree existing, type, stmt;
  {
+   /* Keep track of this for inlining.  */
+   if (current_function_decl)
+     ++DECL_NUM_STMTS (current_function_decl);
+ 
    if (existing)
      return build (COMPOUND_EXPR, type, existing, stmt);
*************** java_expand_method_bodies (class)
*** 8129,8132 ****
--- 8136,8144 ----
        current_function_decl = decl;
  
+       /* Save the function for inlining.  */
+       if (flag_inline_trees)
+ 	DECL_SAVED_TREE (decl) = 
+ 	  BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (decl));
+       
        /* It's time to assign the variable flagging static class
  	 initialization based on which classes invoked static methods

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-07-01 11:21           ` Andrew Haley
  2002-07-01 11:29             ` Andrew Haley
@ 2002-07-01 11:56             ` Daniel Berlin
  2002-07-01 11:58               ` Andrew Haley
  1 sibling, 1 reply; 29+ messages in thread
From: Daniel Berlin @ 2002-07-01 11:56 UTC (permalink / raw)
  To: Andrew Haley; +Cc: Mark Mitchell, Per Bothner, Fergus Henderson, gcc, java

On Mon, 1 Jul 2002, Andrew Haley wrote:

> Mark Mitchell writes:
>  > 
>  > The current inliner already has mechanisms for language-specific
>  > extensions.  If those can be used, or it can be easily extended so that
>  > they can be used, great.
> 
> Well I tried, I really did.  But the inliner we have at the moment
> uses C-private tree nodes to such an extent that I think it isn't
> possible without totally messing up the code.  I could replace every
> occurrence of these nodes with macros or function pointers, but the
> result would not be pretty.  The real answer in the long term is, of
> course, SIMPLE.

Is the java inliner usable in languages other than java (IE could we 
replace the current c-inliner with your java inliner)?
Or did you do the same thing, and create java specific nodes?

> 
> Andrew.
> 
> 

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-07-01 11:56             ` RFC: " Daniel Berlin
@ 2002-07-01 11:58               ` Andrew Haley
  2002-07-10  5:16                 ` Alexandre Oliva
  0 siblings, 1 reply; 29+ messages in thread
From: Andrew Haley @ 2002-07-01 11:58 UTC (permalink / raw)
  To: Daniel Berlin; +Cc: Mark Mitchell, Per Bothner, Fergus Henderson, gcc, java

Daniel Berlin writes:
 > On Mon, 1 Jul 2002, Andrew Haley wrote:
 > 
 > > Mark Mitchell writes:
 > >  > 
 > >  > The current inliner already has mechanisms for language-specific
 > >  > extensions.  If those can be used, or it can be easily extended so that
 > >  > they can be used, great.
 > > 
 > > Well I tried, I really did.  But the inliner we have at the moment
 > > uses C-private tree nodes to such an extent that I think it isn't
 > > possible without totally messing up the code.  I could replace every
 > > occurrence of these nodes with macros or function pointers, but the
 > > result would not be pretty.  The real answer in the long term is, of
 > > course, SIMPLE.
 > 
 > Is the java inliner usable in languages other than java (IE could we 
 > replace the current c-inliner with your java inliner)?

No, because C needs the special C tree nodes.

 > Or did you do the same thing, and create java specific nodes?

We use only the standard nodes.  However, the way we interpret a
couple of these nodes, such as BLOCK, is Java specific.

Andrew.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-07-01 11:58               ` Andrew Haley
@ 2002-07-10  5:16                 ` Alexandre Oliva
  2002-07-10  7:08                   ` Andrew Haley
  2002-07-10  9:00                   ` Tom Tromey
  0 siblings, 2 replies; 29+ messages in thread
From: Alexandre Oliva @ 2002-07-10  5:16 UTC (permalink / raw)
  To: Andrew Haley
  Cc: Daniel Berlin, Mark Mitchell, Per Bothner, Fergus Henderson, gcc, java

On Jul  1, 2002, Andrew Haley <aph@cambridge.redhat.com> wrote:

> Daniel Berlin writes:

>> Is the java inliner usable in languages other than java (IE could we 
>> replace the current c-inliner with your java inliner)?

> No, because C needs the special C tree nodes.

I wonder if, instead of duplicating the code from tree-inline.c and
then modifying it to suit Java, we wouldn't be better off with an
#if/#else/#endif (hopefully temporary) mess, so as to avoid divergence
between these files...  Then we'd just compile tree-inline.c with a
different macro defined to produce the Java inliner object file.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-07-10  5:16                 ` Alexandre Oliva
@ 2002-07-10  7:08                   ` Andrew Haley
  2002-07-10  7:10                     ` Alexandre Oliva
  2002-07-10  9:00                   ` Tom Tromey
  1 sibling, 1 reply; 29+ messages in thread
From: Andrew Haley @ 2002-07-10  7:08 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: gcc, java

Alexandre Oliva writes:
 > On Jul  1, 2002, Andrew Haley <aph@cambridge.redhat.com> wrote:
 > 
 > > Daniel Berlin writes:
 > 
 > >> Is the java inliner usable in languages other than java (IE could we 
 > >> replace the current c-inliner with your java inliner)?
 > 
 > > No, because C needs the special C tree nodes.
 > 
 > I wonder if, instead of duplicating the code from tree-inline.c and
 > then modifying it to suit Java, we wouldn't be better off with an
 > #if/#else/#endif (hopefully temporary) mess, so as to avoid divergence
 > between these files...  Then we'd just compile tree-inline.c with a
 > different macro defined to produce the Java inliner object file.

As I said, I did try but halfway through I abandoned it because it was
too untidy.  I certainly could try again, though.  If that's what it
takes to get a Java inliner...

Andrew.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-07-10  7:08                   ` Andrew Haley
@ 2002-07-10  7:10                     ` Alexandre Oliva
  2002-07-10  7:32                       ` Andrew Haley
  0 siblings, 1 reply; 29+ messages in thread
From: Alexandre Oliva @ 2002-07-10  7:10 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc, java

On Jul 10, 2002, Andrew Haley <aph@redhat.com> wrote:

>> I wonder if, instead of duplicating the code from tree-inline.c and
>> then modifying it to suit Java, we wouldn't be better off with an
>> #if/#else/#endif (hopefully temporary) mess, so as to avoid divergence
>> between these files...  

> As I said, I did try but halfway through I abandoned it because it was
> too untidy.

Hmm, I hadn't got the impression you had relied on the preprocessor to
separate the C/C++-specific bits from the generic/Java ones.  If you
did, and it looked awful, oh well... :-(

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-07-10  7:10                     ` Alexandre Oliva
@ 2002-07-10  7:32                       ` Andrew Haley
  2002-07-10 13:41                         ` Alexandre Oliva
  0 siblings, 1 reply; 29+ messages in thread
From: Andrew Haley @ 2002-07-10  7:32 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: gcc, java

Alexandre Oliva writes:
 > On Jul 10, 2002, Andrew Haley <aph@redhat.com> wrote:
 > 
 > >> I wonder if, instead of duplicating the code from tree-inline.c and
 > >> then modifying it to suit Java, we wouldn't be better off with an
 > >> #if/#else/#endif (hopefully temporary) mess, so as to avoid divergence
 > >> between these files...  
 > 
 > > As I said, I did try but halfway through I abandoned it because it was
 > > too untidy.
 > 
 > Hmm, I hadn't got the impression you had relied on the preprocessor to
 > separate the C/C++-specific bits from the generic/Java ones. 

I had a try, but it was getting rather complex.

 > If you did, and it looked awful, oh well... :-(

Tell you what, I'll diff the two and see if I can come up with a
sensible way to abstract the differences.

Andrew.


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-07-10  5:16                 ` Alexandre Oliva
  2002-07-10  7:08                   ` Andrew Haley
@ 2002-07-10  9:00                   ` Tom Tromey
  1 sibling, 0 replies; 29+ messages in thread
From: Tom Tromey @ 2002-07-10  9:00 UTC (permalink / raw)
  To: Alexandre Oliva
  Cc: Andrew Haley, Daniel Berlin, Mark Mitchell, Per Bothner,
	Fergus Henderson, gcc, java

>>>>> "Alexandre" == Alexandre Oliva <aoliva@redhat.com> writes:

Alexandre> I wonder if, instead of duplicating the code from
Alexandre> tree-inline.c and then modifying it to suit Java, we
Alexandre> wouldn't be better off with an #if/#else/#endif (hopefully
Alexandre> temporary) mess, so as to avoid divergence between these
Alexandre> files...

I'd rather see Andrew just check in his existing inliner.  My
reasoning is that eventually we'll be using the SIMPLE inliner.  I
think the potential divergences between now and that point won't
matter much.

Tom

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-07-10  7:32                       ` Andrew Haley
@ 2002-07-10 13:41                         ` Alexandre Oliva
  2002-07-30  9:43                           ` Andrew Haley
  0 siblings, 1 reply; 29+ messages in thread
From: Alexandre Oliva @ 2002-07-10 13:41 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc, java

On Jul 10, 2002, Andrew Haley <aph@redhat.com> wrote:

>> Hmm, I hadn't got the impression you had relied on the preprocessor to
>> separate the C/C++-specific bits from the generic/Java ones. 

> I had a try, but it was getting rather complex.

I was just thinking of running something like

diff --ifdef=INLINER_FOR_JAVA tree-inline.c java/java-inline.c

and then using the result as the new tree-inline.c

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-07-10 13:41                         ` Alexandre Oliva
@ 2002-07-30  9:43                           ` Andrew Haley
  2002-08-12 10:37                             ` Tom Tromey
  0 siblings, 1 reply; 29+ messages in thread
From: Andrew Haley @ 2002-07-30  9:43 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: gcc, java

[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 525 bytes --]

Alexandre Oliva writes:
 > On Jul 10, 2002, Andrew Haley <aph@redhat.com> wrote:
 > 
 > >> Hmm, I hadn't got the impression you had relied on the preprocessor to
 > >> separate the C/C++-specific bits from the generic/Java ones. 
 > 
 > > I had a try, but it was getting rather complex.
 > 
 > I was just thinking of running something like
 > 
 > diff --ifdef=INLINER_FOR_JAVA tree-inline.c java/java-inline.c
 > 
 > and then using the result as the new tree-inline.c

Okay, here it is.  Looks like you were right.

Andrew.


[-- Attachment #2: java-inline-support.new --]
[-- Type: text/plain, Size: 38367 bytes --]

2002-07-30  Andrew Haley  <aph@redhat.com>

	* tree-inline.c: Add includes for Java inliner.
	(remap_decl): Don't handle anonymous types for Java.
	(remap_block): Add handling for Java trees.
	(copy_scope_stmt): Conditionalize for non-Java use only.
	(copy_body_r): Handle Java trees.  Add handling for
	LABELED_BLOCK_EXPR, EXIT_BLOCK_EXPR, Java blocks.
	(initialize_inlined_parameters):  Handle Java trees.
	(declare_return_variable): Likewise.
	(expand_call_inline): Handle Java trees.
	(walk_tree): Likewise.
	(copy_tree_r): Don't handle SCOPE_STMTs for Java.
	(add_stmt_to_compound): New function.

2002-07-30  Andrew Haley  <aph@redhat.com>

	* Make-lang.in (java-tree-inline.o): New.
	(JAVA_OBJS): Add java-tree-inline.o.
	* parse.y (source_end_java_method): Call java_optimize_inline.
	(java_expand_method_bodies): Save method's tree in
	DECL_SAVED_TREE.
	(add_stmt_to_compound): Keep track of the number of statments.
	* lang.c (java_init): Enable flag_inline_trees.
	(java_post_options): If flag_inline_functions is on, enable
	flag_inline_trees instread.
	(decl_constant_value): New.
	(java_tree_inlining_walk_subtrees): New.
	* java-tree.h (DECL_NUM_STMTS): New macro.
	(java_optimize_inline): Declare.
	* expr.c (java_expand_expr): Allow a BLOCK to return a value.
	Handle a LABEL_EXPR>
	* decl.c (build_result_decl): If we already have a DECL_RESULT
	don't make another.
	(dump_function): New.
	(java_optimize_inline): New.
	(dump_function): New.

Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.26
diff -p -2 -c -r1.26 tree-inline.c
*** tree-inline.c	13 Jun 2002 15:32:40 -0000	1.26
--- tree-inline.c	30 Jul 2002 12:46:00 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 39,43 ****
--- 39,48 ----
  /* This should be eventually be generalized to other languages, but
     this would require a shared function-as-trees infrastructure.  */
+ #ifndef INLINER_FOR_JAVA
  #include "c-common.h"
+ #else /* INLINER_FOR_JAVA */
+ #include "parse.h"
+ #include "java-tree.h"
+ #endif /* INLINER_FOR_JAVA */
  
  /* 0 if we should not perform inlining.
*************** typedef struct inline_data
*** 103,107 ****
  /* Prototypes.  */
  
- static tree initialize_inlined_parameters PARAMS ((inline_data *, tree, tree));
  static tree declare_return_variable PARAMS ((inline_data *, tree *));
  static tree copy_body_r PARAMS ((tree *, int *, void *));
--- 108,111 ----
*************** static void expand_calls_inline PARAMS (
*** 111,116 ****
--- 115,127 ----
  static int inlinable_function_p PARAMS ((tree, inline_data *));
  static tree remap_decl PARAMS ((tree, inline_data *));
+ #ifndef INLINER_FOR_JAVA
+ static tree initialize_inlined_parameters PARAMS ((inline_data *, tree, tree));
  static void remap_block PARAMS ((tree, tree, inline_data *));
  static void copy_scope_stmt PARAMS ((tree *, int *, inline_data *));
+ #else /* INLINER_FOR_JAVA */
+ static tree initialize_inlined_parameters PARAMS ((inline_data *, tree, tree, tree));
+ static void remap_block PARAMS ((tree *, tree, inline_data *));
+ static tree add_stmt_to_compound PARAMS ((tree, tree, tree));
+ #endif /* INLINER_FOR_JAVA */
  
  /* The approximate number of instructions per statement.  This number
*************** remap_decl (decl, id)
*** 159,162 ****
--- 170,174 ----
  	}
  
+ #ifndef INLINER_FOR_JAVA
        if (! DECL_NAME (t) && TREE_TYPE (t)
  	  && (*lang_hooks.tree_inlining.anon_aggr_type_p) (TREE_TYPE (t)))
*************** remap_decl (decl, id)
*** 179,182 ****
--- 191,195 ----
  	  DECL_ANON_UNION_ELEMS (t) = nreverse (members);
  	}
+ #endif /* not INLINER_FOR_JAVA */
  
        /* Remember it, so that if we encounter this local entity
*************** remap_decl (decl, id)
*** 190,204 ****
--- 203,228 ----
  }
  
+ #ifndef INLINER_FOR_JAVA
  /* Copy the SCOPE_STMT_BLOCK associated with SCOPE_STMT to contain
     remapped versions of the variables therein.  And hook the new block
     into the block-tree.  If non-NULL, the DECLS are declarations to
     add to use instead of the BLOCK_VARS in the old block.  */
+ #else /* INLINER_FOR_JAVA */
+ /* Copy the BLOCK to contain remapped versions of the variables
+    therein.  And hook the new block into the block-tree.  */
+ #endif /* INLINER_FOR_JAVA */
  
  static void
+ #ifndef INLINER_FOR_JAVA
  remap_block (scope_stmt, decls, id)
       tree scope_stmt;
+ #else /* INLINER_FOR_JAVA */
+ remap_block (block, decls, id)
+      tree *block;
+ #endif /* INLINER_FOR_JAVA */
       tree decls;
       inline_data *id;
  {
+ #ifndef INLINER_FOR_JAVA
    /* We cannot do this in the cleanup for a TARGET_EXPR since we do
       not know whether or not expand_expr will actually write out the
*************** remap_block (scope_stmt, decls, id)
*** 290,295 ****
--- 314,366 ----
        SCOPE_STMT_BLOCK (scope_stmt) = (tree) n->value;
      }
+ #else /* INLINER_FOR_JAVA */
+   tree old_block;
+   tree new_block;
+   tree old_var;
+   tree fn;
+ 
+   /* Make the new block.  */
+   old_block = *block;
+   new_block = make_node (BLOCK);
+   TREE_USED (new_block) = TREE_USED (old_block);
+   BLOCK_ABSTRACT_ORIGIN (new_block) = old_block;
+   BLOCK_SUBBLOCKS (new_block) = BLOCK_SUBBLOCKS (old_block);
+   TREE_SIDE_EFFECTS (new_block) = TREE_SIDE_EFFECTS (old_block);
+   TREE_TYPE (new_block) = TREE_TYPE (old_block);
+   *block = new_block;
+ 
+   /* Remap its variables.  */
+   for (old_var = decls ? decls : BLOCK_VARS (old_block);
+        old_var;
+        old_var = TREE_CHAIN (old_var))
+     {
+       tree new_var;
+ 
+       /* Remap the variable.  */
+       new_var = remap_decl (old_var, id);
+       /* If we didn't remap this variable, so we can't mess with
+ 	 its TREE_CHAIN.  If we remapped this variable to
+ 	 something other than a declaration (say, if we mapped it
+ 	 to a constant), then we must similarly omit any mention
+ 	 of it here.  */
+       if (!new_var || !DECL_P (new_var))
+ 	;
+       else
+ 	{
+ 	  TREE_CHAIN (new_var) = BLOCK_VARS (new_block);
+ 	  BLOCK_VARS (new_block) = new_var;
+ 	}
+     }
+   /* We put the BLOCK_VARS in reverse order; fix that now.  */
+   BLOCK_VARS (new_block) = nreverse (BLOCK_VARS (new_block));
+   fn = VARRAY_TREE (id->fns, 0);
+   /* Remember the remapped block.  */
+   splay_tree_insert (id->decl_map,
+ 		     (splay_tree_key) old_block,
+ 		     (splay_tree_value) new_block);
+ #endif /* INLINER_FOR_JAVA */
  }
  
+ #ifndef INLINER_FOR_JAVA
  /* Copy the SCOPE_STMT pointed to by TP.  */
  
*************** copy_scope_stmt (tp, walk_subtrees, id)
*** 315,322 ****
    remap_block (*tp, NULL_TREE, id);
  }
  
  /* Called from copy_body via walk_tree.  DATA is really an
     `inline_data *'.  */
- 
  static tree
  copy_body_r (tp, walk_subtrees, data)
--- 386,393 ----
    remap_block (*tp, NULL_TREE, id);
  }
+ #endif /* not INLINER_FOR_JAVA */
  
  /* Called from copy_body via walk_tree.  DATA is really an
     `inline_data *'.  */
  static tree
  copy_body_r (tp, walk_subtrees, data)
*************** copy_body_r (tp, walk_subtrees, data)
*** 341,347 ****
--- 412,427 ----
  #endif
  
+ #ifdef INLINER_FOR_JAVA
+   if (TREE_CODE (*tp) == BLOCK)
+     remap_block (tp, NULL_TREE, id);
+ #endif
+ 
    /* If this is a RETURN_STMT, change it into an EXPR_STMT and a
       GOTO_STMT with the RET_LABEL as its target.  */
+ #ifndef INLINER_FOR_JAVA
    if (TREE_CODE (*tp) == RETURN_STMT && id->ret_label)
+ #else /* INLINER_FOR_JAVA */
+   if (TREE_CODE (*tp) == RETURN_EXPR && id->ret_label)
+ #endif /* INLINER_FOR_JAVA */
      {
        tree return_stmt = *tp;
*************** copy_body_r (tp, walk_subtrees, data)
*** 349,359 ****
--- 429,445 ----
  
        /* Build the GOTO_STMT.  */
+ #ifndef INLINER_FOR_JAVA
        goto_stmt = build_stmt (GOTO_STMT, id->ret_label);
        TREE_CHAIN (goto_stmt) = TREE_CHAIN (return_stmt);
        GOTO_FAKE_P (goto_stmt) = 1;
+ #else /* INLINER_FOR_JAVA */
+       goto_stmt = build1 (GOTO_EXPR, void_type_node, id->ret_label);
+       TREE_SIDE_EFFECTS (goto_stmt) = 1;
+ #endif /* INLINER_FOR_JAVA */
  
        /* If we're returning something, just turn that into an
  	 assignment into the equivalent of the original
  	 RESULT_DECL.  */
+ #ifndef INLINER_FOR_JAVA
        if (RETURN_EXPR (return_stmt))
  	{
*************** copy_body_r (tp, walk_subtrees, data)
*** 364,367 ****
--- 450,462 ----
  	  TREE_CHAIN (*tp) = goto_stmt;
  	}
+ #else /* INLINER_FOR_JAVA */
+       tree assignment = TREE_OPERAND (return_stmt, 0);
+       if (assignment)
+ 	{
+ 	  copy_body_r (&assignment, walk_subtrees, data);
+ 	  *tp = build (COMPOUND_EXPR, void_type_node, assignment, goto_stmt);
+ 	  TREE_SIDE_EFFECTS (*tp) = 1;	    
+ 	}
+ #endif /* INLINER_FOR_JAVA */
        /* If we're not returning anything just do the jump.  */
        else
*************** copy_body_r (tp, walk_subtrees, data)
*** 395,402 ****
--- 490,522 ----
      /* UNSAVE_EXPRs should not be generated until expansion time.  */
      abort ();
+ #ifndef INLINER_FOR_JAVA
    /* For a SCOPE_STMT, we must copy the associated block so that we
       can write out debugging information for the inlined variables.  */
    else if (TREE_CODE (*tp) == SCOPE_STMT && !id->in_target_cleanup_p)
      copy_scope_stmt (tp, walk_subtrees, id);
+ #else /* INLINER_FOR_JAVA */
+   else if (TREE_CODE (*tp) == LABELED_BLOCK_EXPR)
+     {
+       /* We need a new copy of this labeled block; the EXIT_BLOCK_EXPR
+          will refer to it, so save a copy ready for remapping.  We
+          save it in the decl_map, although it isn't a decl.  */
+       tree new_block = copy_node (*tp);
+       splay_tree_insert (id->decl_map,
+ 			 (splay_tree_key) *tp,
+ 			 (splay_tree_value) new_block);
+       *tp = new_block;
+     }
+   else if (TREE_CODE (*tp) == EXIT_BLOCK_EXPR)
+     {
+       splay_tree_node n 
+ 	= splay_tree_lookup (id->decl_map, 
+ 			     (splay_tree_key) TREE_OPERAND (*tp, 0));
+       /* We _must_ have seen the enclosing LABELED_BLOCK_EXPR.  */
+       if (! n)
+ 	abort ();
+       *tp = copy_node (*tp);
+       TREE_OPERAND (*tp, 0) = (tree) n->value;
+     }
+ #endif /* INLINER_FOR_JAVA */
    /* Otherwise, just copy the node.  Note that copy_tree_r already
       knows not to copy VAR_DECLs, etc., so this is safe.  */
*************** copy_body (id)
*** 457,464 ****
--- 577,591 ----
  
  static tree
+ #ifndef INLINER_FOR_JAVA
  initialize_inlined_parameters (id, args, fn)
+ #else /* INLINER_FOR_JAVA */
+ initialize_inlined_parameters (id, args, fn, block)
+ #endif /* INLINER_FOR_JAVA */
       inline_data *id;
       tree args;
       tree fn;
+ #ifdef INLINER_FOR_JAVA
+      tree block;
+ #endif /* INLINER_FOR_JAVA */
  {
    tree init_stmts;
*************** initialize_inlined_parameters (id, args,
*** 466,469 ****
--- 593,599 ----
    tree a;
    tree p;
+ #ifdef INLINER_FOR_JAVA
+   tree vars = NULL_TREE;
+ #endif /* INLINER_FOR_JAVA */
  
    /* Figure out what the parameters are.  */
*************** initialize_inlined_parameters (id, args,
*** 478,482 ****
--- 608,614 ----
         a = a ? TREE_CHAIN (a) : a, p = TREE_CHAIN (p))
      {
+ #ifndef INLINER_FOR_JAVA
        tree init_stmt;
+ #endif /* not INLINER_FOR_JAVA */
        tree var;
        tree value;
*************** initialize_inlined_parameters (id, args,
*** 527,533 ****
--- 659,670 ----
  
        /* Declare this new variable.  */
+ #ifndef INLINER_FOR_JAVA
        init_stmt = build_stmt (DECL_STMT, var);
        TREE_CHAIN (init_stmt) = init_stmts;
        init_stmts = init_stmt;
+ #else /* INLINER_FOR_JAVA */
+       TREE_CHAIN (var) = vars;
+       vars = var;
+ #endif /* INLINER_FOR_JAVA */
  
        /* Initialize this VAR_DECL from the equivalent argument.  If
*************** initialize_inlined_parameters (id, args,
*** 537,540 ****
--- 674,678 ----
  	 object will be constructed in VAR.  */
        if (! TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (p)))
+ #ifndef INLINER_FOR_JAVA
  	DECL_INITIAL (var) = value;
        else
*************** initialize_inlined_parameters (id, args,
*** 574,579 ****
--- 712,732 ----
  	  init_stmts = cleanup_stmt;
  	}
+ #else /* INLINER_FOR_JAVA */
+ 	{
+ 	  tree assignment = build (MODIFY_EXPR, TREE_TYPE (p), var, value);
+ 	  init_stmts = add_stmt_to_compound (init_stmts, TREE_TYPE (p), 
+ 					     assignment);
+ 	}
+       else
+ 	{
+ 	  /* Java objects don't ever need constructing when being
+              passed as arguments because only call by reference is
+              supported.  */
+ 	  abort ();
+ 	}
+ #endif /* INLINER_FOR_JAVA */
      }
  
+ #ifndef INLINER_FOR_JAVA
    /* Evaluate trailing arguments.  */
    for (; a; a = TREE_CHAIN (a))
*************** initialize_inlined_parameters (id, args,
*** 593,596 ****
--- 746,753 ----
       order.  Straighten them out now.  */
    return nreverse (init_stmts);
+ #else /* INLINER_FOR_JAVA */
+   BLOCK_VARS (block) = nreverse (vars);
+   return init_stmts;
+ #endif /* INLINER_FOR_JAVA */
  }
  
*************** initialize_inlined_parameters (id, args,
*** 601,611 ****
--- 758,778 ----
  
  static tree
+ #ifndef INLINER_FOR_JAVA
  declare_return_variable (id, use_stmt)
+ #else /* INLINER_FOR_JAVA */
+ declare_return_variable (id, var)
+ #endif /* INLINER_FOR_JAVA */
       struct inline_data *id;
+ #ifndef INLINER_FOR_JAVA
       tree *use_stmt;
+ #else /* INLINER_FOR_JAVA */
+      tree *var;
+ #endif /* INLINER_FOR_JAVA */
  {
    tree fn = VARRAY_TOP_TREE (id->fns);
    tree result = DECL_RESULT (fn);
+ #ifndef INLINER_FOR_JAVA
    tree var;
+ #endif /* not INLINER_FOR_JAVA */
    int need_return_decl = 1;
  
*************** declare_return_variable (id, use_stmt)
*** 614,621 ****
--- 781,793 ----
    if (!result || VOID_TYPE_P (TREE_TYPE (result)))
      {
+ #ifndef INLINER_FOR_JAVA
        *use_stmt = NULL_TREE;
+ #else /* INLINER_FOR_JAVA */
+       *var = NULL_TREE;
+ #endif /* INLINER_FOR_JAVA */
        return NULL_TREE;
      }
  
+ #ifndef INLINER_FOR_JAVA
    var = ((*lang_hooks.tree_inlining.copy_res_decl_for_inlining)
  	 (result, fn, VARRAY_TREE (id->fns, 0), id->decl_map,
*************** declare_return_variable (id, use_stmt)
*** 637,641 ****
  			    build1 (NOP_EXPR, TREE_TYPE (TREE_TYPE (fn)),
  				    var));
- 
    TREE_ADDRESSABLE (*use_stmt) = 1;
  
--- 809,812 ----
*************** declare_return_variable (id, use_stmt)
*** 644,647 ****
--- 815,830 ----
    if (need_return_decl)
      return build_stmt (DECL_STMT, var);
+ #else /* INLINER_FOR_JAVA */
+   *var = ((*lang_hooks.tree_inlining.copy_res_decl_for_inlining)
+ 	 (result, fn, VARRAY_TREE (id->fns, 0), id->decl_map,
+ 	  &need_return_decl, NULL_TREE));
+ 
+   splay_tree_insert (id->decl_map,
+ 		     (splay_tree_key) result,
+ 		     (splay_tree_value) *var);
+   DECL_IGNORED_P (*var) = 1;
+   if (need_return_decl)
+     return *var;
+ #endif /* INLINER_FOR_JAVA */
    /* If FN does return an aggregate, there's no need to declare the
       return variable; we're using a variable in our caller's frame.  */
*************** expand_call_inline (tp, walk_subtrees, d
*** 784,791 ****
    tree expr;
    tree stmt;
    tree chain;
-   tree fn;
    tree scope_stmt;
    tree use_stmt;
    tree arg_inits;
    tree *inlined_body;
--- 967,978 ----
    tree expr;
    tree stmt;
+ #ifndef INLINER_FOR_JAVA
    tree chain;
    tree scope_stmt;
    tree use_stmt;
+ #else /* INLINER_FOR_JAVA */
+   tree retvar;
+ #endif /* INLINER_FOR_JAVA */
+   tree fn;
    tree arg_inits;
    tree *inlined_body;
*************** expand_call_inline (tp, walk_subtrees, d
*** 800,803 ****
--- 987,991 ----
    if (TREE_CODE (*tp) == TARGET_EXPR)
      {
+ #ifndef INLINER_FOR_JAVA
        int i, len = first_rtl_op (TARGET_EXPR);
  
*************** expand_call_inline (tp, walk_subtrees, d
*** 825,828 ****
--- 1013,1019 ----
  
        return NULL_TREE;
+ #else /* INLINER_FOR_JAVA */
+       abort ();
+ #endif /* INLINER_FOR_JAVA */
      }
  
*************** expand_call_inline (tp, walk_subtrees, d
*** 870,873 ****
--- 1061,1065 ----
    push_srcloc (DECL_SOURCE_FILE (fn), DECL_SOURCE_LINE (fn));
  
+ #ifndef INLINER_FOR_JAVA
    /* Build a statement-expression containing code to initialize the
       arguments, the actual inline expansion of the body, and a label
*************** expand_call_inline (tp, walk_subtrees, d
*** 879,882 ****
--- 1071,1083 ----
    STMT_EXPR_NO_SCOPE (expr) = 1;
    stmt = STMT_EXPR_STMT (expr);
+ #else /* INLINER_FOR_JAVA */
+   /* Build a block containing code to initialize the arguments, the
+      actual inline expansion of the body, and a label for the return
+      statements within the function to jump to.  The type of the
+      statement expression is the return type of the function call.  */
+   stmt = NULL;
+   expr = build (BLOCK, TREE_TYPE (TREE_TYPE (fn)), stmt);
+ #endif /* INLINER_FOR_JAVA */
+ 
    /* Local declarations will be replaced by their equivalents in this
       map.  */
*************** expand_call_inline (tp, walk_subtrees, d
*** 886,889 ****
--- 1087,1091 ----
  
    /* Initialize the parameters.  */
+ #ifndef INLINER_FOR_JAVA
    arg_inits = initialize_inlined_parameters (id, TREE_OPERAND (t, 1), fn);
    /* Expand any inlined calls in the initializers.  Do this before we
*************** expand_call_inline (tp, walk_subtrees, d
*** 894,897 ****
--- 1096,1115 ----
    /* And add them to the tree.  */
    COMPOUND_BODY (stmt) = chainon (COMPOUND_BODY (stmt), arg_inits);
+ #else /* INLINER_FOR_JAVA */
+   arg_inits = initialize_inlined_parameters (id, TREE_OPERAND (t, 1), fn, expr);
+   if (arg_inits)
+     {
+       /* Expand any inlined calls in the initializers.  Do this before we
+ 	 push FN on the stack of functions we are inlining; we want to
+ 	 inline calls to FN that appear in the initializers for the
+ 	 parameters.  */
+       expand_calls_inline (&arg_inits, id);
+       
+       /* And add them to the tree.  */
+       BLOCK_EXPR_BODY (expr) = add_stmt_to_compound (BLOCK_EXPR_BODY (expr), 
+ 						     TREE_TYPE (arg_inits), 
+ 						     arg_inits);
+     }
+ #endif /* INLINER_FOR_JAVA */
  
    /* Record the function we are about to inline so that we can avoid
*************** expand_call_inline (tp, walk_subtrees, d
*** 921,924 ****
--- 1139,1143 ----
      abort ();
  
+ #ifndef INLINER_FOR_JAVA
    /* Create a block to put the parameters in.  We have to do this
       after the parameters have been remapped because remapping
*************** expand_call_inline (tp, walk_subtrees, d
*** 940,960 ****
--- 1159,1213 ----
      = chainon (COMPOUND_BODY (stmt),
  	       declare_return_variable (id, &use_stmt));
+ #else /* INLINER_FOR_JAVA */
+   {
+     /* Declare the return variable for the function.  */
+     tree decl = declare_return_variable (id, &retvar);
+     if (retvar)
+       {
+ 	tree *next = &BLOCK_VARS (expr);
+ 	while (*next)
+ 	  next = &TREE_CHAIN (*next);	
+ 	*next = decl;
+       }
+   }
+ #endif /* INLINER_FOR_JAVA */
  
    /* After we've initialized the parameters, we insert the body of the
       function itself.  */
+ #ifndef INLINER_FOR_JAVA
    inlined_body = &COMPOUND_BODY (stmt);
    while (*inlined_body)
      inlined_body = &TREE_CHAIN (*inlined_body);
    *inlined_body = copy_body (id);
+ #else /* INLINER_FOR_JAVA */
+   {
+     tree new_body = copy_body (id);
+     TREE_TYPE (new_body) = TREE_TYPE (TREE_TYPE (fn));
+     BLOCK_EXPR_BODY (expr)
+       = add_stmt_to_compound (BLOCK_EXPR_BODY (expr), 
+ 			      TREE_TYPE (new_body), new_body);
+     inlined_body = &BLOCK_EXPR_BODY (expr);
+   }
+ #endif /* INLINER_FOR_JAVA */
  
    /* After the body of the function comes the RET_LABEL.  This must come
       before we evaluate the returned value below, because that evalulation
       may cause RTL to be generated.  */
+ #ifndef INLINER_FOR_JAVA
    COMPOUND_BODY (stmt)
      = chainon (COMPOUND_BODY (stmt),
  	       build_stmt (LABEL_STMT, id->ret_label));
+ #else /* INLINER_FOR_JAVA */
+   {
+     tree label = build1 (LABEL_EXPR, void_type_node, id->ret_label);
+     BLOCK_EXPR_BODY (expr)
+       = add_stmt_to_compound (BLOCK_EXPR_BODY (expr), void_type_node, label);
+     TREE_SIDE_EFFECTS (label) = TREE_SIDE_EFFECTS (t);
+   }
+ #endif /* INLINER_FOR_JAVA */
  
    /* Finally, mention the returned value so that the value of the
       statement-expression is the returned value of the function.  */
+ #ifndef INLINER_FOR_JAVA
    COMPOUND_BODY (stmt) = chainon (COMPOUND_BODY (stmt), use_stmt);
    
*************** expand_call_inline (tp, walk_subtrees, d
*** 965,968 ****
--- 1218,1227 ----
    COMPOUND_BODY (stmt)
      = chainon (COMPOUND_BODY (stmt), scope_stmt);
+ #else /* INLINER_FOR_JAVA */
+   if (retvar)
+     BLOCK_EXPR_BODY (expr) 
+       = add_stmt_to_compound (BLOCK_EXPR_BODY (expr), 
+ 			      TREE_TYPE (retvar), retvar);
+ #endif /* INLINER_FOR_JAVA */
  
    /* Clean up.  */
*************** expand_call_inline (tp, walk_subtrees, d
*** 976,984 ****
--- 1235,1251 ----
       EXPR_WITH_FILE_LOCATION so that we'll get debugging line notes
       pointing to the right place.  */
+ #ifndef INLINER_FOR_JAVA
    chain = TREE_CHAIN (*tp);
    *tp = build_expr_wfl (expr, DECL_SOURCE_FILE (fn), DECL_SOURCE_LINE (fn),
  			/*col=*/0);
+ #else /* INLINER_FOR_JAVA */
+   *tp = build_expr_wfl (expr, DECL_SOURCE_FILE (fn), 
+ 			DECL_SOURCE_LINE_FIRST(fn),
+ 			/*col=*/0);
+ #endif /* INLINER_FOR_JAVA */
    EXPR_WFL_EMIT_LINE_NOTE (*tp) = 1;
+ #ifndef INLINER_FOR_JAVA
    TREE_CHAIN (*tp) = chain;
+ #endif /* not INLINER_FOR_JAVA */
    pop_srcloc ();
  
*************** expand_call_inline (tp, walk_subtrees, d
*** 1010,1014 ****
    return NULL_TREE;
  }
- 
  /* Walk over the entire tree *TP, replacing CALL_EXPRs with inline
     expansions as appropriate.  */
--- 1277,1280 ----
*************** walk_tree (tp, func, data, htab_)
*** 1175,1178 ****
--- 1441,1445 ----
    code = TREE_CODE (*tp);
  
+ #ifndef INLINER_FOR_JAVA
    /* Even if we didn't, FUNC may have decided that there was nothing
       interesting below this point in the tree.  */
*************** walk_tree (tp, func, data, htab_)
*** 1191,1201 ****
--- 1458,1477 ----
        || TREE_CODE_CLASS (code) == 'r'
        || TREE_CODE_CLASS (code) == 's')
+ #else /* INLINER_FOR_JAVA */
+   if (code != EXIT_BLOCK_EXPR
+       && code != SAVE_EXPR
+       && (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
+ 	  || TREE_CODE_CLASS (code) == 'r'
+ 	  || TREE_CODE_CLASS (code) == 's'))
+ #endif /* INLINER_FOR_JAVA */
      {
        int i, len;
  
+ #ifndef INLINER_FOR_JAVA
        /* Set lineno here so we get the right instantiation context
  	 if we call instantiate_decl from inlinable_function_p.  */
        if (statement_code_p (code) && !STMT_LINENO_FOR_FN_P (*tp))
  	lineno = STMT_LINENO (*tp);
+ #endif /* not INLINER_FOR_JAVA */
  
        /* Walk over all the sub-trees of this operand.  */
*************** walk_tree (tp, func, data, htab_)
*** 1211,1214 ****
--- 1487,1491 ----
  	WALK_SUBTREE (TREE_OPERAND (*tp, i));
  
+ #ifndef INLINER_FOR_JAVA
        /* For statements, we also walk the chain so that we cover the
  	 entire statement tree.  */
*************** walk_tree (tp, func, data, htab_)
*** 1233,1236 ****
--- 1510,1514 ----
  	}
  
+ #endif /* not INLINER_FOR_JAVA */
        /* We didn't find what we were looking for.  */
        return NULL_TREE;
*************** walk_tree (tp, func, data, htab_)
*** 1328,1331 ****
--- 1606,1617 ----
        WALK_SUBTREE_TAIL (TYPE_OFFSET_BASETYPE (*tp));
  
+ #ifdef INLINER_FOR_JAVA
+     case EXIT_BLOCK_EXPR:
+       WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, 1));
+ 
+     case SAVE_EXPR:
+       WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, 0));
+ #endif /* INLINER_FOR_JAVA */
+ 
      default:
        abort ();
*************** copy_tree_r (tp, walk_subtrees, data)
*** 1385,1388 ****
--- 1671,1675 ----
  	 walk_tree to walk into the chain as well.  */
        if (code == PARM_DECL || code == TREE_LIST
+ #ifndef INLINER_FOR_JAVA
  	  || (*lang_hooks.tree_inlining.tree_chain_matters_p) (*tp)
  	  || statement_code_p (code))
*************** copy_tree_r (tp, walk_subtrees, data)
*** 1393,1396 ****
--- 1680,1687 ----
        if (TREE_CODE (*tp) == SCOPE_STMT)
  	SCOPE_STMT_BLOCK (*tp) = NULL_TREE;
+ #else /* INLINER_FOR_JAVA */
+ 	  || (*lang_hooks.tree_inlining.tree_chain_matters_p) (*tp))
+ 	TREE_CHAIN (*tp) = chain;
+ #endif /* INLINER_FOR_JAVA */
      }
    else if (TREE_CODE_CLASS (code) == 't')
*************** remap_save_expr (tp, st_, fn, walk_subtr
*** 1445,1446 ****
--- 1736,1755 ----
    *tp = (tree) n->value;
  }
+ 
+ #ifdef INLINER_FOR_JAVA
+ /* Add STMT to EXISTING if possible, otherwise create a new
+    COMPOUND_EXPR and add STMT to it. */
+ 
+ static tree
+ add_stmt_to_compound (existing, type, stmt)
+      tree existing, type, stmt;
+ {
+   if (!stmt)
+     return existing;
+   else if (existing)
+     return build (COMPOUND_EXPR, type, existing, stmt);
+   else
+     return stmt;
+ }
+ 
+ #endif /* INLINER_FOR_JAVA */
Index: java/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Make-lang.in,v
retrieving revision 1.88
diff -p -2 -c -r1.88 Make-lang.in
*** java/Make-lang.in	11 Jun 2002 14:58:09 -0000	1.88
--- java/Make-lang.in	30 Jul 2002 12:46:12 -0000
*************** JAVA_OBJS = java/parse.o java/class.o ja
*** 110,114 ****
    java/mangle_name.o java/builtins.o \
    java/jcf-write.o java/buffer.o java/check-init.o java/jcf-depend.o \
!   java/jcf-path.o java/xref.o java/boehm.o mkdeps.o
  
  GCJH_OBJS = java/gjavah.o java/jcf-io.o java/jcf-depend.o java/jcf-path.o \
--- 110,114 ----
    java/mangle_name.o java/builtins.o \
    java/jcf-write.o java/buffer.o java/check-init.o java/jcf-depend.o \
!   java/jcf-path.o java/xref.o java/boehm.o java/java-tree-inline.o mkdeps.o
  
  GCJH_OBJS = java/gjavah.o java/jcf-io.o java/jcf-depend.o java/jcf-path.o \
*************** java/expr.o: java/expr.c $(CONFIG_H) $(J
*** 289,292 ****
--- 289,299 ----
    java/java-except.h java/java-except.h java/parse.h toplev.h \
    $(SYSTEM_H) $(GGC_H) gt-java-expr.h
+ java/java-tree-inline.o: tree-inline.c $(CONFIG_H) $(SYSTEM_H) \
+    $(TREE_H) $(RTL_H) expr.h flags.h params.h input.h insn-config.h \
+    $(INTEGRATE_H) $(VARRAY_H) $(HASHTAB_H) $(SPLAY_TREE_H) toplev.h \
+    langhooks.h $(C_COMMON_H) $(srcdir)/tree-inline.h
+ 	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
+ 	-DINLINER_FOR_JAVA=1 \
+ 	$(srcdir)/tree-inline.c -o $@
  java/jcf-depend.o: java/jcf-depend.c $(CONFIG_H) $(SYSTEM_H) java/jcf.h
  java/jcf-parse.o: java/jcf-parse.c $(CONFIG_H) $(JAVA_TREE_H) flags.h \
Index: java/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/decl.c,v
retrieving revision 1.130
diff -p -2 -c -r1.130 decl.c
*** java/decl.c	1 Jul 2002 23:07:18 -0000	1.130
--- java/decl.c	30 Jul 2002 12:46:13 -0000
*************** The Free Software Foundation is independ
*** 42,48 ****
  #include "java-except.h"
  #include "ggc.h"
  
  #if defined (DEBUG_JAVA_BINDING_LEVELS)
! extern void indent PROTO((void));
  #endif
  
--- 42,50 ----
  #include "java-except.h"
  #include "ggc.h"
+ #include "timevar.h"
+ #include "tree-inline.h"
  
  #if defined (DEBUG_JAVA_BINDING_LEVELS)
! extern void indent PARAMS ((void));
  #endif
  
*************** static tree create_primitive_vtable PARA
*** 54,57 ****
--- 56,60 ----
  static tree check_local_named_variable PARAMS ((tree, tree, int, int *));
  static tree check_local_unnamed_variable PARAMS ((tree, tree, tree));
+ static void dump_function PARAMS ((enum tree_dump_index, tree));
  
  /* Set to non-zero value in order to emit class initilization code
*************** build_result_decl (fndecl)
*** 1663,1671 ****
  {
    tree restype = TREE_TYPE (TREE_TYPE (fndecl));
!   /* To be compatible with C_PROMOTING_INTEGER_TYPE_P in cc1/cc1plus. */
!   if (INTEGRAL_TYPE_P (restype)
!       && TYPE_PRECISION (restype) < TYPE_PRECISION (integer_type_node))
!     restype = integer_type_node;
!   return (DECL_RESULT (fndecl) = build_decl (RESULT_DECL, NULL_TREE, restype));
  }
  
--- 1666,1681 ----
  {
    tree restype = TREE_TYPE (TREE_TYPE (fndecl));
!   tree result = DECL_RESULT (fndecl);
!   if (! result)
!     {
!       /* To be compatible with C_PROMOTING_INTEGER_TYPE_P in cc1/cc1plus. */
!       if (INTEGRAL_TYPE_P (restype)
! 	  && TYPE_PRECISION (restype) < TYPE_PRECISION (integer_type_node))
! 	restype = integer_type_node;
!       result = build_decl (RESULT_DECL, NULL_TREE, restype);
!       DECL_CONTEXT (result) = fndecl;
!       DECL_RESULT (fndecl) = result;
!     }
!   return result;
  }
  
*************** end_java_method ()
*** 1824,1827 ****
--- 1834,1888 ----
  
    current_function_decl = NULL_TREE;
+ }
+ 
+ /* Dump FUNCTION_DECL FN as tree dump PHASE. */
+ 
+ static void
+ dump_function (phase, fn)
+      enum tree_dump_index phase;
+      tree fn;
+ {
+   FILE *stream;
+   int flags;
+ 
+   stream = dump_begin (phase, &flags);
+   if (stream)
+     {
+       dump_node (fn, TDF_SLIM | flags, stream);
+       dump_end (phase, stream);
+     }
+ }
+  
+ void java_optimize_inline (fndecl)
+      tree fndecl;
+ {
+   if (flag_inline_trees)
+     {
+       int uninlinable;
+       /* First, cache whether the current function is inlinable.  Some
+          predicates depend on cfun and current_function_decl to
+          function completely.  */
+       timevar_push (TV_INTEGRATION);
+       uninlinable = ! tree_inlinable_function_p (fndecl);
+       
+ #if 0
+       if (! uninlinable
+ 	  /* Save function tree for inlining.  Should return 0 if the
+              language does not support function deferring or the
+              function could not be deferred.  */
+ 	  && defer_fn (fndecl))
+ 	{
+ 	  /* Let the back-end know that this function exists.  */
+ 	  (*debug_hooks->deferred_inline_function) (fndecl);
+           timevar_pop (TV_INTEGRATION);
+ 	  return;
+ 	}
+ #endif
+       
+       /* Then, inline any functions called in it.  */
+       optimize_inline_calls (fndecl);
+       timevar_pop (TV_INTEGRATION);
+       dump_function (TDI_inlined, fndecl);
+     }
  }
  
Index: java/expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.148
diff -p -2 -c -r1.148 expr.c
*** java/expr.c	25 Jun 2002 13:27:19 -0000	1.148
--- java/expr.c	30 Jul 2002 12:46:15 -0000
*************** java_expand_expr (exp, target, tmode, mo
*** 2536,2539 ****
--- 2536,2540 ----
  	{
  	  tree local;
+ 	  rtx last;
  	  tree body = BLOCK_EXPR_BODY (exp);
  	  /* Set to 1 or more when we found a static class
*************** java_expand_expr (exp, target, tmode, mo
*** 2569,2577 ****
  	      body = TREE_OPERAND (body, 1);
  	    }
! 	  expand_expr (body, const0_rtx, VOIDmode, 0);
  	  emit_queue ();
  	  expand_end_bindings (getdecls (), 1, 0);
  	  poplevel (1, 1, 0);
! 	  return const0_rtx;
  	}
        return const0_rtx;
--- 2570,2578 ----
  	      body = TREE_OPERAND (body, 1);
  	    }
!   	  last = expand_expr (body, NULL_RTX, VOIDmode, 0);
  	  emit_queue ();
  	  expand_end_bindings (getdecls (), 1, 0);
  	  poplevel (1, 1, 0);
! 	  return last;
  	}
        return const0_rtx;
*************** java_expand_expr (exp, target, tmode, mo
*** 2629,2632 ****
--- 2630,2638 ----
        return expand_expr (build_exception_object_ref (TREE_TYPE (exp)),
  			  target, tmode, modifier);
+ 
+     case LABEL_EXPR:
+       /* Used only by expanded inline functions.  */
+       expand_label (TREE_OPERAND (exp, 0));
+       return const0_rtx;
  
      default:
Index: java/java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.153
diff -p -2 -c -r1.153 java-tree.h
*** java/java-tree.h	11 Jun 2002 17:31:10 -0000	1.153
--- java/java-tree.h	30 Jul 2002 12:46:16 -0000
*************** union lang_tree_node 
*** 903,906 ****
--- 903,912 ----
  #define DECL_FIELD_FINAL_WFL(NODE) \
    (DECL_LANG_SPECIFIC(NODE)->u.v.wfl)
+ /* In a FUNCTION_DECL for which DECL_BUILT_IN does not hold, this is
+      the approximate number of statements in this function.  There is
+      no need for this number to be exact; it is only used in various
+      heuristics regarding optimization.  */
+ #define DECL_NUM_STMTS(NODE) \
+   (FUNCTION_DECL_CHECK (NODE)->decl.u1.i)
  /* True if NODE is a local variable final. */
  #define LOCAL_FINAL_P(NODE) (DECL_LANG_SPECIFIC (NODE) && DECL_FINAL (NODE))
*************** extern void append_gpp_mangled_name PARA
*** 1274,1277 ****
--- 1280,1286 ----
  extern void add_predefined_file PARAMS ((tree));
  extern int predefined_filename_p PARAMS ((tree));
+ 
+ extern void java_optimize_inline PARAMS ((tree));
+ extern tree decl_constant_value PARAMS ((tree));
  
  #if defined(RTX_CODE) && defined (HAVE_MACHINE_MODES)
Index: java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.105
diff -p -2 -c -r1.105 lang.c
*** java/lang.c	22 Jul 2002 00:42:54 -0000	1.105
--- java/lang.c	30 Jul 2002 12:46:16 -0000
*************** The Free Software Foundation is independ
*** 41,44 ****
--- 41,45 ----
  #include "ggc.h"
  #include "diagnostic.h"
+ #include "tree-inline.h"
  
  struct string_option
*************** static int process_option_with_no PARAMS
*** 62,65 ****
--- 63,71 ----
  					   const struct string_option *,
  					   int));
+ static tree java_tree_inlining_walk_subtrees  PARAMS ((tree *,
+ 						       int *,
+ 						       walk_tree_fn,
+ 						       void *,
+ 						       void *));
  static int java_unsafe_for_reeval PARAMS ((tree));
  
*************** struct language_function GTY(())
*** 266,269 ****
--- 272,278 ----
  #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE java_signed_or_unsigned_type
  
+ #undef LANG_HOOKS_TREE_INLINING_WALK_SUBTREES
+ #define LANG_HOOKS_TREE_INLINING_WALK_SUBTREES java_tree_inlining_walk_subtrees
+ 
  /* Each front end provides its own.  */
  const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
*************** java_init (filename)
*** 497,500 ****
--- 506,512 ----
  #endif
  
+   if (flag_inline_functions)
+     flag_inline_trees = 1;
+ 
    /* Open input file.  */
  
*************** static bool
*** 787,795 ****
  java_post_options ()
  {
!   /* Turn off RTL inliner unless -finline-functions was really specified.  */
!   if (flag_really_inline == 0)
      {
!       flag_no_inline = 1;
!       flag_inline_functions = 0;
      }
  
--- 799,884 ----
  java_post_options ()
  {
!  /* Use tree inlining if possible.  Function instrumentation is only
!      done in the RTL level, so we disable tree inlining.  */
!   if (! flag_instrument_function_entry_exit)
!     {
!       if (!flag_no_inline)
! 	flag_no_inline = 1;
!       if (flag_inline_functions)
! 	{
! 	  flag_inline_trees = 2;
! 	  flag_inline_functions = 0;
! 	}
!     }
! 
! }
! 
! /* Return either DECL or its known constant value (if it has one).  */
! 
! tree
! decl_constant_value (decl)
!      tree decl;
! {
!   if (/* Don't change a variable array bound or initial value to a constant
! 	 in a place where a variable is invalid.  */
!       current_function_decl != 0
!       && ! TREE_THIS_VOLATILE (decl)
!       && TREE_READONLY (decl)
!       && DECL_INITIAL (decl) != 0
!       && TREE_CODE (DECL_INITIAL (decl)) != ERROR_MARK
!       /* This is invalid if initial value is not constant.
! 	 If it has either a function call, a memory reference,
! 	 or a variable, then re-evaluating it could give different results.  */
!       && TREE_CONSTANT (DECL_INITIAL (decl))
!       /* Check for cases where this is sub-optimal, even though valid.  */
!       && TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR)
!     return DECL_INITIAL (decl);
!   return decl;
! }
! 
! /* Walk the language specific tree nodes during inlining.  */
! 
! static tree
! java_tree_inlining_walk_subtrees (tp,subtrees,func,data,htab)
!      tree *tp ATTRIBUTE_UNUSED;
!      int *subtrees ATTRIBUTE_UNUSED;
!      walk_tree_fn func ATTRIBUTE_UNUSED;
!      void *data ATTRIBUTE_UNUSED;
!      void *htab ATTRIBUTE_UNUSED;
! {
!   enum tree_code code;
!   tree result;
! 
! #define WALK_SUBTREE(NODE)				\
!   do							\
!     {							\
!       result = walk_tree (&(NODE), func, data, htab);	\
!       if (result)					\
! 	return result;					\
!     }							\
!   while (0)
! 
!   tree t = *tp;
!   if (!t)
!     return NULL_TREE;
! 
!   code = TREE_CODE (t);
!   switch (code)
      {
!     case BLOCK:
!       if (BLOCK_EXPR_BODY (t))
! 	{
! 	  tree *prev = &BLOCK_EXPR_BODY (*tp);
! 	  while (*prev)
! 	    {
! 	      WALK_SUBTREE (*prev);
! 	      prev = &TREE_CHAIN (*prev);
! 	    }	    
! 	}
!       return NULL_TREE;
!       break;
! 
!     default:
!       return NULL_TREE;
      }
  
Index: java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.390
diff -p -2 -c -r1.390 parse.y
*** java/parse.y	2 Jul 2002 02:56:11 -0000	1.390
--- java/parse.y	30 Jul 2002 12:46:24 -0000
*************** definitions and other extensions.  */
*** 68,71 ****
--- 68,72 ----
  #include "ggc.h"
  #include "debug.h"
+ #include "tree-inline.h"
  
  #ifndef DIR_SEPARATOR
*************** source_end_java_method ()
*** 7479,7482 ****
--- 7480,7485 ----
    dump_java_tree (TDI_original, fndecl);
  
+   java_optimize_inline (fndecl); 
+ 
    /* Generate function's code */
    if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
*************** add_stmt_to_compound (existing, type, st
*** 7540,7543 ****
--- 7543,7550 ----
       tree existing, type, stmt;
  {
+   /* Keep track of this for inlining.  */
+   if (current_function_decl)
+     ++DECL_NUM_STMTS (current_function_decl);
+ 
    if (existing)
      return build (COMPOUND_EXPR, type, existing, stmt);
*************** java_expand_method_bodies (class)
*** 8129,8132 ****
--- 8136,8144 ----
        current_function_decl = decl;
  
+       /* Save the function for inlining.  */
+       if (flag_inline_trees)
+ 	DECL_SAVED_TREE (decl) = 
+ 	  BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (decl));
+       
        /* It's time to assign the variable flagging static class
  	 initialization based on which classes invoked static methods

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-07-30  9:43                           ` Andrew Haley
@ 2002-08-12 10:37                             ` Tom Tromey
  2002-08-12 10:42                               ` Andrew Haley
  0 siblings, 1 reply; 29+ messages in thread
From: Tom Tromey @ 2002-08-12 10:37 UTC (permalink / raw)
  To: Andrew Haley; +Cc: Alexandre Oliva, gcc, java

>>>>> "Andrew" == Andrew Haley <aph@cambridge.redhat.com> writes:

Andrew> Okay, here it is.  Looks like you were right.
Andrew> [ new tree inliner that works with gcj ]

I just got back from vacation, and I haven't seen any reply to
Andrew's post.

I'd like to see this, or Andrew's earlier inlining patch, go in.  Can
someone review it?

Tom

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: RFC: Java inliner
  2002-08-12 10:37                             ` Tom Tromey
@ 2002-08-12 10:42                               ` Andrew Haley
  0 siblings, 0 replies; 29+ messages in thread
From: Andrew Haley @ 2002-08-12 10:42 UTC (permalink / raw)
  To: gcc, java

Tom Tromey writes:
 > >>>>> "Andrew" == Andrew Haley <aph@cambridge.redhat.com> writes:
 > 
 > Andrew> Okay, here it is.  Looks like you were right.
 > Andrew> [ new tree inliner that works with gcj ]
 > 
 > I just got back from vacation, and I haven't seen any reply to
 > Andrew's post.
 > 
 > I'd like to see this, or Andrew's earlier inlining patch, go in.  Can
 > someone review it?

BTW, Jeff Sturm submitted a minor bug fix and a couple of additions to
my patch.  I could re-submit incorporating his changes, but I don't
think it's necessary to do so for my patch to be reviewed.

Andrew.

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2002-08-12 10:42 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-11  7:00 RFC: Java inliner Andrew Haley
2002-06-11  7:25 ` Daniel Berlin
2002-06-11  7:26   ` Andrew Haley
2002-06-11  7:56 ` Fergus Henderson
2002-06-11  9:18   ` Andrew Haley
2002-06-11  9:49     ` Joe Buck
2002-06-11 10:59       ` Andrew Haley
2002-06-11 11:29         ` Diego Novillo
2002-06-11 22:36     ` Mark Mitchell
2002-06-12  2:24       ` Per Bothner
2002-06-12  4:47         ` Andrew Haley
2002-06-12  6:38         ` Mark Mitchell
2002-06-12  8:45           ` Andrew Haley
2002-06-12  9:13             ` Daniel Berlin
2002-06-12  9:28               ` Daniel Berlin
2002-07-01 11:21           ` Andrew Haley
2002-07-01 11:29             ` Andrew Haley
2002-07-01 11:56             ` RFC: " Daniel Berlin
2002-07-01 11:58               ` Andrew Haley
2002-07-10  5:16                 ` Alexandre Oliva
2002-07-10  7:08                   ` Andrew Haley
2002-07-10  7:10                     ` Alexandre Oliva
2002-07-10  7:32                       ` Andrew Haley
2002-07-10 13:41                         ` Alexandre Oliva
2002-07-30  9:43                           ` Andrew Haley
2002-08-12 10:37                             ` Tom Tromey
2002-08-12 10:42                               ` Andrew Haley
2002-07-10  9:00                   ` Tom Tromey
2002-06-11  8:39 ` profiling shared libraries Taha Mannan Jiruwala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).