aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2003-06-10 16:43:39 +0000
committerAndrew Haley <aph@gcc.gnu.org>2003-06-10 16:43:39 +0000
commite076f71a38f9945415a6dd2b037b20c1de9b6d3b (patch)
tree7ccc0967b6f9a3aa999e7661ed16ff9f1bebe3cc /gcc
parente7e09ad8f27d4a239b2109f719e69753e4f3abc7 (diff)
downloadgcc-e076f71a38f9945415a6dd2b037b20c1de9b6d3b.zip
gcc-e076f71a38f9945415a6dd2b037b20c1de9b6d3b.tar.gz
gcc-e076f71a38f9945415a6dd2b037b20c1de9b6d3b.tar.bz2
langhooks-def.h (LANG_HOOKS_DECL_OK_FOR_SIBCALL): New.
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/calls.c9
-rw-r--r--gcc/java/ChangeLog5
-rw-r--r--gcc/java/lang.c16
-rw-r--r--gcc/langhooks-def.h5
-rw-r--r--gcc/langhooks.c10
-rw-r--r--gcc/langhooks.h3
7 files changed, 53 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ab74761..5c68a99 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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,
diff --git a/gcc/calls.c b/gcc/calls.c
index db6b884..a72bba6 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -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)
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 875fc53..c9d623e 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -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.
diff --git a/gcc/java/lang.c b/gcc/java/lang.c
index f870a57..64283d4 100644
--- a/gcc/java/lang.c
+++ b/gcc/java/lang.c
@@ -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"
diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h
index 5a752be..8e6f842 100644
--- a/gcc/langhooks-def.h
+++ b/gcc/langhooks-def.h
@@ -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. */
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index d4f3e35..2bc9148 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -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
diff --git a/gcc/langhooks.h b/gcc/langhooks.h
index c3ec11d..fb648bf 100644
--- a/gcc/langhooks.h
+++ b/gcc/langhooks.h
@@ -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. */