2003-05-21 Andrew Haley <aph@redhat.com>
authoraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Jun 2003 16:43:39 +0000 (16:43 +0000)
committeraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Jun 2003 16:43:39 +0000 (16:43 +0000)
* langhooks-def.h (LANG_HOOKS_DECL_OK_FOR_SIBCALL): New.
(LANG_HOOKS_DECLS): Add LANG_HOOKS_DECL_OK_FOR_SIBCALL.
(lhd_decl_ok_for_sibcall): New.
* langhooks.c (lhd_decl_ok_for_sibcall): New.
* langhooks.h (lang_hooks_for_decls.ok_for_sibcall): New field.
* calls.c (expand_call): Check lang_hook before generating a
sibcall.

2003-05-21  Andrew Haley  <aph@redhat.com>

* lang.c (LANG_HOOKS_DECL_OK_FOR_SIBCALL): New.
(java_decl_ok_for_sibcall): New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@67713 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/calls.c
gcc/java/ChangeLog
gcc/java/lang.c
gcc/langhooks-def.h
gcc/langhooks.c
gcc/langhooks.h

index ab74761..5c68a99 100644 (file)
@@ -1,3 +1,13 @@
+2003-06-10  Andrew Haley  <aph@redhat.com>
+
+       * langhooks-def.h (LANG_HOOKS_DECL_OK_FOR_SIBCALL): New.
+       (LANG_HOOKS_DECLS): Add LANG_HOOKS_DECL_OK_FOR_SIBCALL.
+       (lhd_decl_ok_for_sibcall): New.
+       * langhooks.c (lhd_decl_ok_for_sibcall): New.
+       * langhooks.h (lang_hooks_for_decls.ok_for_sibcall): New field.
+       * calls.c (expand_call): Check lang_hook before generating a
+       sibcall.
+
 2003-06-10  DJ Delorie  <dj@redhat.com>
 
        * config/stormy16/stormy16.c (xstormy16_extra_constraint_p): Add Z,
index db6b884..a72bba6 100644 (file)
@@ -2508,10 +2508,11 @@ expand_call (exp, target, ignore)
       || args_size.constant > current_function_args_size
       /* If the callee pops its own arguments, then it must pop exactly
         the same number of arguments as the current function.  */
-      || RETURN_POPS_ARGS (fndecl, funtype, args_size.constant)
-        != RETURN_POPS_ARGS (current_function_decl,
-                             TREE_TYPE (current_function_decl),
-                             current_function_args_size))
+      || (RETURN_POPS_ARGS (fndecl, funtype, args_size.constant)
+         != RETURN_POPS_ARGS (current_function_decl,
+                              TREE_TYPE (current_function_decl),
+                              current_function_args_size))
+      || !(*lang_hooks.decls.ok_for_sibcall) (fndecl))
     try_tail_call = 0;
 
   if (try_tail_call || try_tail_recursion)
index 875fc53..c9d623e 100644 (file)
@@ -1,3 +1,8 @@
+2003-06-10  Andrew Haley  <aph@redhat.com>
+
+       * lang.c (LANG_HOOKS_DECL_OK_FOR_SIBCALL): New.
+       (java_decl_ok_for_sibcall): New.
+
 2003-06-09  Neil Booth  <neil@daikokuya.co.uk>
 
        * Make-lang.in (JAVA_OBJS, java/lang.o): Update.
index f870a57..64283d4 100644 (file)
@@ -65,6 +65,7 @@ static int inline_init_test_initialization (void * *, void *);
 static bool java_can_use_bit_fields_p (void);
 static bool java_dump_tree (void *, tree);
 static void dump_compound_expr (dump_info_p, tree);
+static bool java_decl_ok_for_sibcall (tree);
 
 #ifndef TARGET_OBJECT_SUFFIX
 # define TARGET_OBJECT_SUFFIX ".o"
@@ -251,6 +252,9 @@ struct language_function GTY(())
 #undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN
 #define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN java_dump_tree
 
+#undef LANG_HOOKS_DECL_OK_FOR_SIBCALL
+#define LANG_HOOKS_DECL_OK_FOR_SIBCALL java_decl_ok_for_sibcall
+
 /* Each front end provides its own.  */
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
@@ -1077,4 +1081,16 @@ java_dump_tree (void *dump_info, tree t)
     }
   return false;
 }
+
+/* Java calls can't, in general, be sibcalls because we need an
+   accurate stack trace in order to guarantee correct operation of
+   methods such as Class.forName(String) and
+   SecurityManager.getClassContext().  */
+
+static bool
+java_decl_ok_for_sibcall (tree decl)
+{
+  return decl != NULL && DECL_CONTEXT (decl) == current_class;
+}
+
 #include "gt-java-lang.h"
index 5a752be..8e6f842 100644 (file)
@@ -64,6 +64,7 @@ extern bool lhd_can_use_bit_fields_p PARAMS ((void));
 extern bool lhd_warn_unused_global_decl PARAMS ((tree));
 extern void lhd_incomplete_type_error PARAMS ((tree, tree));
 extern tree lhd_type_promotes_to PARAMS ((tree));
+extern bool lhd_decl_ok_for_sibcall PARAMS ((tree));
 extern tree lhd_expr_size PARAMS ((tree));
 extern size_t lhd_tree_size PARAMS ((enum tree_code));
 
@@ -224,6 +225,7 @@ int lhd_tree_dump_type_quals                        PARAMS ((tree));
 #define LANG_HOOKS_GETDECLS    getdecls
 #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl
 #define LANG_HOOKS_WRITE_GLOBALS write_global_declarations
+#define LANG_HOOKS_DECL_OK_FOR_SIBCALL lhd_decl_ok_for_sibcall
 
 #define LANG_HOOKS_DECLS { \
   LANG_HOOKS_PUSHLEVEL, \
@@ -234,7 +236,8 @@ int lhd_tree_dump_type_quals                        PARAMS ((tree));
   LANG_HOOKS_PUSHDECL, \
   LANG_HOOKS_GETDECLS, \
   LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \
-  LANG_HOOKS_WRITE_GLOBALS \
+  LANG_HOOKS_WRITE_GLOBALS, \
+  LANG_HOOKS_DECL_OK_FOR_SIBCALL, \
 }
 
 /* The whole thing.  The structure is defined in langhooks.h.  */
index d4f3e35..2bc9148 100644 (file)
@@ -469,6 +469,16 @@ lhd_tree_size (c)
   return 0;
 }
 
+/* Return true if decl, which is a function decl, may be called by a
+   sibcall.  */
+
+bool
+lhd_decl_ok_for_sibcall (decl)
+     tree decl ATTRIBUTE_UNUSED;
+{
+  return true;
+}
+
 /* lang_hooks.decls.final_write_globals: perform final processing on
    global variables.  */
 void
index c3ec11d..fb648bf 100644 (file)
@@ -180,6 +180,9 @@ struct lang_hooks_for_decls
   /* Obtain a list of globals and do final output on them at end
      of compilation */
   void (*final_write_globals) PARAMS ((void));
+
+  /* True if this decl may be called via a sibcall.  */
+  bool (*ok_for_sibcall) PARAMS ((tree));
 };
 
 /* Language-specific hooks.  See langhooks-def.h for defaults.  */