This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java 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]

Resubmit: New lang hook: ok_for_sibcall


This is a repost of the patch I posted eariler.  This diff is against
mainline rather than branch.

Andrew.


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.

? win32-host.c
Index: calls.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/calls.c,v
retrieving revision 1.274
diff -p -2 -c -r1.274 calls.c
*** calls.c	17 May 2003 22:21:28 -0000	1.274
--- calls.c	21 May 2003 19:09:02 -0000
*************** expand_call (exp, target, ignore)
*** 2473,2480 ****
        /* 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))
      try_tail_call = 0;
  
--- 2473,2481 ----
        /* 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))
!       || !(*lang_hooks.decls.ok_for_sibcall) (fndecl))
      try_tail_call = 0;
  
Index: langhooks-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks-def.h,v
retrieving revision 1.47
diff -p -2 -c -r1.47 langhooks-def.h
*** langhooks-def.h	7 Apr 2003 06:03:09 -0000	1.47
--- langhooks-def.h	21 May 2003 19:09:02 -0000
*************** extern bool lhd_warn_unused_global_decl 
*** 65,68 ****
--- 65,69 ----
  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));
*************** int lhd_tree_dump_type_quals			PARAMS ((
*** 224,227 ****
--- 225,229 ----
  #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 { \
*************** int lhd_tree_dump_type_quals			PARAMS ((
*** 234,238 ****
    LANG_HOOKS_GETDECLS, \
    LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \
!   LANG_HOOKS_WRITE_GLOBALS \
  }
  
--- 236,241 ----
    LANG_HOOKS_GETDECLS, \
    LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \
!   LANG_HOOKS_WRITE_GLOBALS, \
!   LANG_HOOKS_DECL_OK_FOR_SIBCALL, \
  }
  
Index: langhooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.c,v
retrieving revision 1.41
diff -p -2 -c -r1.41 langhooks.c
*** langhooks.c	7 Apr 2003 06:03:10 -0000	1.41
--- langhooks.c	21 May 2003 19:09:02 -0000
*************** lhd_tree_size (c)
*** 470,473 ****
--- 470,483 ----
  }
  
+ /* 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.  */
Index: langhooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.h,v
retrieving revision 1.55
diff -p -2 -c -r1.55 langhooks.h
*** langhooks.h	7 Apr 2003 06:03:10 -0000	1.55
--- langhooks.h	21 May 2003 19:09:02 -0000
*************** struct lang_hooks_for_decls
*** 181,184 ****
--- 181,187 ----
       of compilation */
    void (*final_write_globals) PARAMS ((void));
+ 
+   /* True if this decl may be called via a sibcall.  */
+   bool (*ok_for_sibcall) PARAMS ((tree));
  };
  
Index: java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.123
diff -p -2 -c -r1.123 lang.c
*** java/lang.c	19 Mar 2003 20:34:09 -0000	1.123
--- java/lang.c	21 May 2003 19:09:04 -0000
*************** static bool java_can_use_bit_fields_p (v
*** 72,75 ****
--- 72,76 ----
  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
*************** struct language_function GTY(())
*** 291,294 ****
--- 292,298 ----
  #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;
*************** java_dump_tree (void *dump_info, tree t)
*** 1128,1130 ****
--- 1132,1146 ----
    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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]