This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Inliner for Java


This is a supplementary patch which allows constructors to be inlined
and removes some restrictions on method order for inlining.

Andrew.

2002-08-10  Jeff Sturm  <jsturm@one-point.com>

	* class.c (add_method_1): Set DECL_INLINE on constructors.
	* parse.y (craft_constructor): Set DECL_INLINE on constructors.
	(finish_method_declaration): Save method body for inlining here...
	(end_artifical_method_body): ...and here...
	(java_expand_method_bodies): ...but not here.

Index: java/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.134
diff -p -2 -c -r1.134 class.c
*** java/class.c        4 Aug 2002 22:45:30 -0000       1.134
--- java/class.c        16 Aug 2002 10:44:14 -0000
*************** add_method_1 (this_class, access_flags, 
*** 640,643 ****
--- 640,647 ----
      HAS_FINALIZER_P (this_class) = 1;
  
+   /* Constructors are inlining candidates. */
+   if (ID_INIT_P (name))
+     DECL_INLINE (fndecl) = 1;
+ 
    if (access_flags & ACC_PUBLIC) METHOD_PUBLIC (fndecl) = 1;
    if (access_flags & ACC_PROTECTED) METHOD_PROTECTED (fndecl) = 1;
Index: java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.392
diff -p -2 -c -r1.392 parse.y
*** java/parse.y        16 Aug 2002 10:32:30 -0000      1.392
--- java/parse.y        16 Aug 2002 10:44:21 -0000
*************** finish_method_declaration (method_body)
*** 4826,4829 ****
--- 4826,4835 ----
  
    BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
+ 
+   /* Save the function for inlining.  */
+   if (DECL_FUNCTION_BODY (current_function_decl) && flag_inline_trees)
+     DECL_SAVED_TREE (current_function_decl) =
+       BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl));
+ 
    maybe_absorb_scoping_blocks ();
    /* Exit function's body */
*************** craft_constructor (class_decl, args)
*** 5494,5498 ****
    /* Now, mark the artificial parameters. */
    DECL_FUNCTION_NAP (decl) = artificial;
!   DECL_FUNCTION_SYNTHETIC_CTOR (decl) = DECL_CONSTRUCTOR_P (decl) = 1;
    return decl;
  }
--- 5500,5507 ----
    /* Now, mark the artificial parameters. */
    DECL_FUNCTION_NAP (decl) = artificial;
!   DECL_INLINE (decl) 
!     = DECL_FUNCTION_SYNTHETIC_CTOR (decl) 
!     = DECL_CONSTRUCTOR_P (decl) 
!     = 1;
    return decl;
  }
*************** end_artificial_method_body (mdecl)
*** 7436,7439 ****
--- 7445,7454 ----
    tree b = exit_block ();
    BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = b;
+ 
+   /* Save the function for inlining.  */
+   if (DECL_FUNCTION_BODY (mdecl) && flag_inline_trees)
+     DECL_SAVED_TREE (mdecl) =
+       BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl));
+ 
    exit_block ();
  }
*************** java_expand_method_bodies (class)
*** 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
--- 8151,8154 ----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]