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]

ia64 eh, part 20a [java]


Ok, I think I've merged as much as possible without the
actual object of the exercise.  The next five patches,
while presented separately for ease of perusal, are not
independant and will all be committed together.

The following is the Java front end change.  I didn't get
any comments from the Java folks from the last bulk patch;
I guess I should have been more proactive and split this
code out for them then too.  I'm not going to let that stop
me from checking the thing in though -- lack of the patch
would break compilation of the tree as a whole.

Alex, Per et al, one thing to look at is some of the more
curious uses of soft_exceptioninfo_call_node that have been
replaced by EXC_PTR_EXPR.  It's not an exact replacement,
as you can see from build_exception_object_ref.



r~


	IA-64 ABI Exception Handling:
	* Make-lang.in (except.o): Don't depend on eh-common.h.
	* check-init.c (check_init): Handle EXC_PTR_EXPR.
	* decl.c (init_decl_processing) [throw_node]: No _Jv_Sjlj_Throw.
	[soft_exceptioninfo_call_node]: Remove.
	[eh_personality_libfunc, lang_eh_runtime_type]: New.
	(end_java_method): No emit_handlers.
	* except.c (java_set_exception_lang_code): Remove.
	(method_init_exceptions): Don't call it.
	(prepare_eh_table_type): No CATCH_ALL_TYPE.
	(build_exception_object_ref): New.
	(expand_end_java_handler): Update for except.h name changes.
	(emit_handlers, expand_resume_after_catch): Remove.
	* expr.c (java_lang_expand_expr): Update for except.h name changes.
	(process_jvm_instruction): Use build_exception_object_ref.
	* java-tree.h (JTI_SOFT_EXCEPTIONINFO_CALL_NODE): Remove.
	(soft_exceptioninfo_call_node): Remove.
	(build_exception_object_ref): Declare.
	* jcf-write.c (generate_bytecode_insns) [CALL_EXPR]: No
	soft_exceptioninfo_call_node.  Move processing ...
	[EXC_PTR_EXPR]: ... here.
	* parse.h (BUILD_ASSIGN_EXCEPTION_INFO): Remove dead code.
	* parse.y (catch_clause_parameter): Use build_exception_object_ref.
	(source_end_java_method): No java_set_exception_lang_code or
	emit_handlers.
	(build_dot_class_method): Use build_exception_object_ref.
	(try_reference_assignconv): Check EXC_PTR_EXPR not
	soft_exceptioninfo_call_node.

Index: Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Make-lang.in,v
retrieving revision 1.55
diff -c -p -d -r1.55 Make-lang.in
*** Make-lang.in	2001/03/27 22:57:33	1.55
--- Make-lang.in	2001/03/28 09:28:24
*************** java/decl.o: java/decl.c $(CONFIG_H) $(J
*** 254,260 ****
    toplev.h $(SYSTEM_H) function.h gcc.h
  java/except.o: java/except.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h real.h \
    $(RTL_H) java/javaop.h java/java-opcodes.h except.h java/java-except.h \
!   eh-common.h toplev.h $(SYSTEM_H) function.h
  java/expr.o: java/expr.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h real.h \
    $(RTL_H) $(EXPR_H) java/javaop.h java/java-opcodes.h except.h \
    java/java-except.h java/java-except.h java/parse.h toplev.h \
--- 254,260 ----
    toplev.h $(SYSTEM_H) function.h gcc.h
  java/except.o: java/except.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h real.h \
    $(RTL_H) java/javaop.h java/java-opcodes.h except.h java/java-except.h \
!   toplev.h $(SYSTEM_H) function.h
  java/expr.o: java/expr.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h real.h \
    $(RTL_H) $(EXPR_H) java/javaop.h java/java-opcodes.h except.h \
    java/java-except.h java/java-except.h java/parse.h toplev.h \
Index: check-init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/check-init.c,v
retrieving revision 1.28
diff -c -p -d -r1.28 check-init.c
*** check-init.c	2001/03/28 08:59:28	1.28
--- check-init.c	2001/03/28 09:28:24
*************** check_init (exp, before)
*** 681,686 ****
--- 681,687 ----
      case INTEGER_CST:
      case REAL_CST:
      case STRING_CST:
+     case EXC_PTR_EXPR:
        break;
  
      case NEW_CLASS_EXPR:
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/decl.c,v
retrieving revision 1.98
diff -c -p -d -r1.98 decl.c
*** decl.c	2001/03/28 08:59:29	1.98
--- decl.c	2001/03/28 09:28:24
*************** The Free Software Foundation is independ
*** 29,40 ****
--- 29,42 ----
  #include "config.h"
  #include "system.h"
  #include "tree.h"
+ #include "rtl.h"
  #include "toplev.h"
  #include "flags.h"
  #include "java-tree.h"
  #include "jcf.h"
  #include "toplev.h"
  #include "function.h"
+ #include "expr.h"
  #include "except.h"
  #include "java-except.h"
  #include "ggc.h"
*************** init_decl_processing ()
*** 725,737 ****
  							       t),
  					  0, NOT_BUILT_IN,
  					  NULL_PTR);
!   throw_node = builtin_function ((USING_SJLJ_EXCEPTIONS
! 				  ? "_Jv_Throw" : "_Jv_Sjlj_Throw"),
  				 build_function_type (ptr_type_node, t),
  				 0, NOT_BUILT_IN, NULL_PTR);
    /* Mark throw_nodes as `noreturn' functions with side effects.  */
    TREE_THIS_VOLATILE (throw_node) = 1;
    TREE_SIDE_EFFECTS (throw_node) = 1;
    t = build_function_type (int_type_node, endlink);
    soft_monitorenter_node 
      = builtin_function ("_Jv_MonitorEnter", t, 0, NOT_BUILT_IN,
--- 727,740 ----
  							       t),
  					  0, NOT_BUILT_IN,
  					  NULL_PTR);
! 
!   throw_node = builtin_function ("_Jv_Throw",
  				 build_function_type (ptr_type_node, t),
  				 0, NOT_BUILT_IN, NULL_PTR);
    /* Mark throw_nodes as `noreturn' functions with side effects.  */
    TREE_THIS_VOLATILE (throw_node) = 1;
    TREE_SIDE_EFFECTS (throw_node) = 1;
+ 
    t = build_function_type (int_type_node, endlink);
    soft_monitorenter_node 
      = builtin_function ("_Jv_MonitorEnter", t, 0, NOT_BUILT_IN,
*************** init_decl_processing ()
*** 834,848 ****
  			build_function_type (double_type_node, t),
  			BUILT_IN_FMOD, BUILT_IN_NORMAL, "fmod");
  
-   soft_exceptioninfo_call_node
-     = build (CALL_EXPR, 
- 	     ptr_type_node,
- 	     build_address_of 
- 	       (builtin_function ("_Jv_exception_info", 
- 				  build_function_type (ptr_type_node, endlink),
- 				  0, NOT_BUILT_IN, NULL_PTR)),
- 	     NULL_TREE, NULL_TREE);
-   TREE_SIDE_EFFECTS (soft_exceptioninfo_call_node) = 1;
  #if 0
    t = tree_cons (NULL_TREE, float_type_node,
  		 tree_cons (NULL_TREE, float_type_node, endlink));
--- 837,842 ----
*************** init_decl_processing ()
*** 872,877 ****
--- 866,877 ----
  			build_function_type (long_type_node, t),
  			0, NOT_BUILT_IN, NULL_PTR);
  
+   /* Initialize variables for except.c.  */
+   eh_personality_libfunc = init_one_libfunc (USING_SJLJ_EXCEPTIONS
+                                              ? "__gcj_personality_sj0"
+                                              : "__gcj_personality_v0");
+   lang_eh_runtime_type = prepare_eh_table_type;
+ 
    init_jcf_parse ();
  
    /* Register nodes with the garbage collector.  */
*************** end_java_method ()
*** 1827,1834 ****
    poplevel (1, 0, 1);
  
    BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
- 
-   emit_handlers ();
  
    /* Generate rtl for function exit.  */
    expand_function_end (input_filename, lineno, 0);
--- 1827,1832 ----
Index: except.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/except.c,v
retrieving revision 1.25
diff -c -p -d -r1.25 except.c
*** except.c	2000/10/17 22:48:59	1.25
--- except.c	2001/03/28 09:28:24
*************** The Free Software Foundation is independ
*** 34,40 ****
  #include "function.h"
  #include "except.h"
  #include "java-except.h"
- #include "eh-common.h"
  #include "toplev.h"
  
  static void expand_start_java_handler PARAMS ((struct eh_range *));
--- 34,39 ----
*************** method_init_exceptions ()
*** 250,263 ****
    whole_range.first_child = NULL;
    whole_range.next_sibling = NULL;
    cache_range_start = 0xFFFFFF;
-   java_set_exception_lang_code ();
- }
- 
- void
- java_set_exception_lang_code ()
- {
-   set_exception_lang_code (EH_LANG_Java);
-   set_exception_version_code (1);
  }
  
  /* Add an exception range.  If we already have an exception range
--- 249,254 ----
*************** prepare_eh_table_type (type)
*** 339,345 ****
     * (which yields a value with low-order bit 1). */
  
    if (type == NULL_TREE)
!     exp = CATCH_ALL_TYPE;
    else if (is_compiled_class (type))
      exp = build_class_ref (type);
    else
--- 330,336 ----
     * (which yields a value with low-order bit 1). */
  
    if (type == NULL_TREE)
!     exp = NULL_TREE;
    else if (is_compiled_class (type))
      exp = build_class_ref (type);
    else
*************** prepare_eh_table_type (type)
*** 350,356 ****
    return exp;
  }
  
! /* if there are any handlers for this range, isssue end of range,
     and then all handler blocks */
  static void
  expand_end_java_handler (range)
--- 341,367 ----
    return exp;
  }
  
! 
! /* Build a reference to the jthrowable object being carried in the
!    exception header.  */
! 
! tree
! build_exception_object_ref (type)
!      tree type;
! {
!   tree obj;
! 
!   /* Java only passes object via pointer and doesn't require adjusting.
!      The java object is immediately before the generic exception header.  */
!   obj = build (EXC_PTR_EXPR, build_pointer_type (type));
!   obj = build (MINUS_EXPR, TREE_TYPE (obj), obj,
! 	       TYPE_SIZE_UNIT (TREE_TYPE (obj)));
!   obj = build1 (INDIRECT_REF, type, obj);
! 
!   return obj;
! }
! 
! /* If there are any handlers for this range, isssue end of range,
     and then all handler blocks */
  static void
  expand_end_java_handler (range)
*************** expand_end_java_handler (range)
*** 361,371 ****
    expand_start_all_catch ();
    for ( ; handler != NULL_TREE; handler = TREE_CHAIN (handler))
      {
!       start_catch_handler (prepare_eh_table_type (TREE_PURPOSE (handler)));
!       /* Push the thrown object on the top of the stack */
        expand_goto (TREE_VALUE (handler));
!       expand_resume_after_catch ();
!       end_catch_handler ();
      }
    expand_end_all_catch ();
  #if defined(DEBUG_JAVA_BINDING_LEVELS)
--- 372,380 ----
    expand_start_all_catch ();
    for ( ; handler != NULL_TREE; handler = TREE_CHAIN (handler))
      {
!       expand_start_catch (TREE_PURPOSE (handler));
        expand_goto (TREE_VALUE (handler));
!       expand_end_catch ();
      }
    expand_end_all_catch ();
  #if defined(DEBUG_JAVA_BINDING_LEVELS)
*************** maybe_end_try (start_pc, end_pc)
*** 431,461 ****
        expand_end_java_handler (current_range);
        current_range = current_range->outer;
      }
- }
- 
- /* Emit the handler labels and their code */
- 
- void
- emit_handlers ()
- {
-   if (catch_clauses)
-     {
-       rtx funcend = gen_label_rtx ();
-       emit_jump (funcend);
- 
-       emit_insns (catch_clauses);
-       catch_clauses = catch_clauses_last = NULL_RTX;
-       expand_leftover_cleanups ();
- 
-       emit_label (funcend);
-     }
- }
- 
- /* Resume executing at the statement immediately after the end of an
-    exception region. */
- 
- void
- expand_resume_after_catch ()
- {
-   expand_goto (top_label_entry (&caught_return_label_stack));
  }
--- 440,443 ----
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.106
diff -c -p -d -r1.106 expr.c
*** expr.c	2001/03/28 08:59:29	1.106
--- expr.c	2001/03/28 09:28:24
*************** java_lang_expand_expr (exp, target, tmod
*** 2502,2516 ****
        for (current = TREE_OPERAND (exp, 1); current; 
  	   current = TREE_CHAIN (current))
  	{
- 	  tree type;
  	  tree catch = TREE_OPERAND (current, 0);
  	  tree decl = BLOCK_EXPR_DECLS (catch);
! 	  type = (decl ? TREE_TYPE (TREE_TYPE (decl)) : NULL_TREE);
! 	  start_catch_handler (prepare_eh_table_type (type));
! 	  expand_expr_stmt (TREE_OPERAND (current, 0));
  
! 	  expand_resume_after_catch ();
! 	  end_catch_handler ();
  	}
        expand_end_all_catch ();
        return const0_rtx;
--- 2502,2514 ----
        for (current = TREE_OPERAND (exp, 1); current; 
  	   current = TREE_CHAIN (current))
  	{
  	  tree catch = TREE_OPERAND (current, 0);
  	  tree decl = BLOCK_EXPR_DECLS (catch);
! 	  tree type = (decl ? TREE_TYPE (TREE_TYPE (decl)) : NULL_TREE);
  
! 	  expand_start_catch (type);
! 	  expand_expr_stmt (TREE_OPERAND (current, 0));
! 	  expand_end_catch ();
  	}
        expand_end_all_catch ();
        return const0_rtx;
*************** process_jvm_instruction (PC, byte_ops, l
*** 2812,2818 ****
    if (instruction_bits [PC] & BCODE_EXCEPTION_TARGET)
      {
        tree type = pop_type (ptr_type_node);
!       push_value (build1 (NOP_EXPR, type, soft_exceptioninfo_call_node));
      }
  
    switch (byte_ops[PC++])
--- 2810,2816 ----
    if (instruction_bits [PC] & BCODE_EXCEPTION_TARGET)
      {
        tree type = pop_type (ptr_type_node);
!       push_value (build_exception_object_ref (type));
      }
  
    switch (byte_ops[PC++])
Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.107
diff -c -p -d -r1.107 java-tree.h
*** java-tree.h	2001/03/28 08:59:29	1.107
--- java-tree.h	2001/03/28 09:28:24
*************** enum java_tree_index
*** 339,345 ****
    JTI_SOFT_GETJNIENVNEWFRAME_NODE,
    JTI_SOFT_JNIPOPSYSTEMFRAME_NODE,
    JTI_SOFT_FMOD_NODE,
-   JTI_SOFT_EXCEPTIONINFO_CALL_NODE,
    JTI_SOFT_IDIV_NODE,
    JTI_SOFT_IREM_NODE,
    JTI_SOFT_LDIV_NODE,
--- 339,344 ----
*************** extern tree java_global_trees[JTI_MAX];
*** 581,588 ****
    java_global_trees[JTI_SOFT_JNIPOPSYSTEMFRAME_NODE]
  #define soft_fmod_node \
    java_global_trees[JTI_SOFT_FMOD_NODE]
- #define soft_exceptioninfo_call_node \
-   java_global_trees[JTI_SOFT_EXCEPTIONINFO_CALL_NODE]
  #define soft_idiv_node \
    java_global_trees[JTI_SOFT_IDIV_NODE]
  #define soft_irem_node \
--- 580,585 ----
*************** extern tree build_instanceof PARAMS ((tr
*** 1026,1031 ****
--- 1023,1029 ----
  extern tree create_label_decl PARAMS ((tree));
  extern void push_labeled_block PARAMS ((tree));
  extern tree prepare_eh_table_type PARAMS ((tree));
+ extern tree build_exception_object_ref PARAMS ((tree));
  extern void java_set_exception_lang_code PARAMS ((void));
  extern tree generate_name PARAMS ((void));
  extern void pop_labeled_block PARAMS ((void));
Index: jcf-write.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-write.c,v
retrieving revision 1.76
diff -c -p -d -r1.76 jcf-write.c
*** jcf-write.c	2001/03/28 08:59:29	1.76
--- jcf-write.c	2001/03/28 09:28:24
*************** generate_bytecode_insns (exp, target, st
*** 2451,2456 ****
--- 2451,2459 ----
  	  }
        }
        break;
+     case EXC_PTR_EXPR:
+       NOTE_PUSH (1);  /* Pushed by exception system. */
+       break;
      case NEW_CLASS_EXPR:
        {
  	tree class = TREE_TYPE (TREE_TYPE (exp));
*************** generate_bytecode_insns (exp, target, st
*** 2525,2535 ****
  	    RESERVE (1);
  	    OP1 (op);
  	    NOTE_POP (1);
- 	    break;
- 	  }
- 	else if (exp == soft_exceptioninfo_call_node)
- 	  {
- 	    NOTE_PUSH (1);  /* Pushed by exception system. */
  	    break;
  	  }
  	for ( ;  x != NULL_TREE;  x = TREE_CHAIN (x))
--- 2528,2533 ----
Index: parse.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.h,v
retrieving revision 1.70
diff -c -p -d -r1.70 parse.h
*** parse.h	2001/03/28 08:59:30	1.70
--- parse.h	2001/03/28 09:28:24
*************** typedef struct _jdeplist {
*** 661,674 ****
    build_new_invocation (wfl_string_buffer, 				      \
  			(ARG ? build_tree_list (NULL, (ARG)) : NULL_TREE))
  
- /* For exception handling, build diverse function calls */
- #define BUILD_ASSIGN_EXCEPTION_INFO(WHERE, TO)		\
-   {							\
-     (WHERE) = build (MODIFY_EXPR, void_type_node, (TO),	\
- 		     soft_exceptioninfo_call_node);	\
-     TREE_SIDE_EFFECTS (WHERE) = 1;			\
-   }
- 
  #define BUILD_THROW(WHERE, WHAT)				\
    {								\
      (WHERE) = 							\
--- 661,666 ----
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.270
diff -c -p -d -r1.270 parse.y
*** parse.y	2001/03/28 08:38:22	1.270
--- parse.y	2001/03/28 09:28:25
*************** catch_clause_parameter:
*** 1885,1893 ****
  		     declared initialized by the appropriate function
  		     call */
  		  tree ccpb = enter_block ();
! 		  tree init = build_assignment (ASSIGN_TK, $2.location, 
! 						TREE_PURPOSE ($3), 
! 						soft_exceptioninfo_call_node);
  		  declare_local_variables (0, TREE_VALUE ($3),
  					   build_tree_list (TREE_PURPOSE ($3),
  							    init));
--- 1885,1893 ----
  		     declared initialized by the appropriate function
  		     call */
  		  tree ccpb = enter_block ();
! 		  tree init = build_assignment
! 		    (ASSIGN_TK, $2.location, TREE_PURPOSE ($3), 
! 		     build_exception_object_ref (ptr_type_node));
  		  declare_local_variables (0, TREE_VALUE ($3),
  					   build_tree_list (TREE_PURPOSE ($3),
  							    init));
*************** source_end_java_method ()
*** 7124,7132 ****
    java_parser_context_save_global ();
    lineno = ctxp->last_ccb_indent1;
  
-   /* Set EH language codes */
-   java_set_exception_lang_code ();
- 
    /* Turn function bodies with only a NOP expr null, so they don't get
       generated at all and we won't get warnings when using the -W
       -Wall flags. */
--- 7124,7129 ----
*************** source_end_java_method ()
*** 7148,7155 ****
    if (! flag_emit_class_files && ! flag_emit_xref)
      {
        lineno = DECL_SOURCE_LINE_LAST (fndecl);
-       /* Emit catch-finally clauses */
-       emit_handlers ();
        expand_function_end (input_filename, lineno, 0);
  
        /* Run the optimizers and output assembler code for this function. */
--- 7145,7150 ----
*************** build_dot_class_method (class)
*** 8405,8411 ****
    
    /* We initialize the variable with the exception handler. */
    catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
! 		 soft_exceptioninfo_call_node);
    add_stmt_to_block (catch_block, NULL_TREE, catch);
  
    /* We add the statement throwing the new exception */
--- 8400,8406 ----
    
    /* We initialize the variable with the exception handler. */
    catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
! 		 build_exception_object_ref (ptr_type_node));
    add_stmt_to_block (catch_block, NULL_TREE, catch);
  
    /* We add the statement throwing the new exception */
*************** try_reference_assignconv (lhs_type, rhs)
*** 12609,12615 ****
        else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
  	new_rhs = rhs;
        /* This is a magic assignment that we process differently */
!       else if (rhs == soft_exceptioninfo_call_node)
  	new_rhs = rhs;
      }
    return new_rhs;
--- 12604,12610 ----
        else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
  	new_rhs = rhs;
        /* This is a magic assignment that we process differently */
!       else if (TREE_CODE (rhs) == EXC_PTR_EXPR)
  	new_rhs = rhs;
      }
    return new_rhs;


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