langhooks-def.h (LANG_HOOKS_DECL_OK_FOR_SIBCALL): New.
authorAndrew Haley <aph@redhat.com>
Tue, 10 Jun 2003 16:43:39 +0000 (16:43 +0000)
committerAndrew Haley <aph@gcc.gnu.org>
Tue, 10 Jun 2003 16:43:39 +0000 (16:43 +0000)
2003-05-21  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-05-21  Andrew Haley  <aph@redhat.com>

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

From-SVN: r67713

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

index ab74761c900624a59b0594368c28787f7dd1e170..5c68a993de49efd5035483fa693b5635d42702b5 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 db6b884be1ea6896d82bf421bbea965cedf10f9b..a72bba6e33f6d93a0408d81f5a413c8a3c1cde5a 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 875fc5388ba7a9068ffbee06506902b17563af45..c9d623eaf9182011800663f2f1563026ae7e4586 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 f870a574dcf994bf6eaca80233192da726341770..64283d4c10235f27859b2b92c74036c40e2c7daa 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 5a752bed119d9efae7a82e0abbd44241fa20483d..8e6f8424c8afd19904c58629522d0b6a811e919d 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 d4f3e3584d6fd969898e7f2f42e0796b761b7fd2..2bc91481eee5fa764769b628959947014abda780 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 c3ec11ddbb32f993be5a95889dcea1b0f1ef2547..fb648bf51ae79d767c1d38fe93c2200df36f790a 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.  */