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]
Other format: [Raw text]

[java patch]: Reoganize DECL_SOURCE_LINE_FIRST amd DECL_SOURCE_LINE_LAST


Hi,
in my effort to canonicalize location handling I discovered that the
java front end wedges two line numbers into DECL_SOURCE_LINE during
the parsing phase. This patch eliminates that by adding another field
to lang_decl_function. The last-line info is used in two places
-- to issue a missing return error, and to set the location for the
function epilogue. I tried ways of implicitly determining the location
but those failed, and this seemed the most straight forward way.

booted & tested on i686-pc-linux-gnu, ok?

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
         The voices in my head said this was stupid too
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2003-05-09  Nathan Sidwell  <nathan@codesourcery.com>

	* tree-inline.c (expand_call_inline): DECL_SOURCE_LINE_FIRST is
	removed.
	* java/java-tree.h (DECL_FUNCTION_LAST_LINE): New.
	(struct lang_decl_func): Add last_line field.
	* java/parse.h (DECL_SOURCE_LINE_MERGE, DECL_SOURCE_LINE_FIRST,
	DECL_SOURCE_LINE_LAST): Remove.
	* java/parse.y (missing_return_error,
	finish_method_declaration, lookup_cl, start_artificial_method_body,
	source_end_java_method, start_complete_expand_method): Adjust.

Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.58
diff -c -3 -p -r1.58 tree-inline.c
*** tree-inline.c	3 May 2003 13:28:33 -0000	1.58
--- tree-inline.c	9 May 2003 19:41:20 -0000
*************** expand_call_inline (tp, walk_subtrees, d
*** 1395,1407 ****
       pointing to the right place.  */
  #ifndef INLINER_FOR_JAVA
    chain = TREE_CHAIN (*tp);
    *tp = build_expr_wfl (expr, DECL_SOURCE_FILE (fn), DECL_SOURCE_LINE (fn),
  			/*col=*/0);
- #else /* INLINER_FOR_JAVA */
-   *tp = build_expr_wfl (expr, DECL_SOURCE_FILE (fn),
- 			DECL_SOURCE_LINE_FIRST(fn),
- 			/*col=*/0);
- #endif /* INLINER_FOR_JAVA */
    EXPR_WFL_EMIT_LINE_NOTE (*tp) = 1;
  #ifndef INLINER_FOR_JAVA
    TREE_CHAIN (*tp) = chain;
--- 1395,1403 ----
       pointing to the right place.  */
  #ifndef INLINER_FOR_JAVA
    chain = TREE_CHAIN (*tp);
+ #endif /* INLINER_FOR_JAVA */
    *tp = build_expr_wfl (expr, DECL_SOURCE_FILE (fn), DECL_SOURCE_LINE (fn),
  			/*col=*/0);
    EXPR_WFL_EMIT_LINE_NOTE (*tp) = 1;
  #ifndef INLINER_FOR_JAVA
    TREE_CHAIN (*tp) = chain;
Index: java/java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.173
diff -c -3 -p -r1.173 java-tree.h
*** java/java-tree.h	13 Apr 2003 01:45:34 -0000	1.173
--- java/java-tree.h	9 May 2003 19:46:42 -0000
*************** union lang_tree_node 
*** 773,778 ****
--- 773,780 ----
  /* Number of local variable slots needed for the arguments of this function. */
  #define DECL_ARG_SLOT_COUNT(DECL) \
    (DECL_LANG_SPECIFIC(DECL)->u.f.arg_slot_count)
+ /* Line number of end of function. */
+ #define DECL_FUNCTION_LAST_LINE(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.last_line)
  /* Information on declaration location */
  #define DECL_FUNCTION_WFL(DECL)  (DECL_LANG_SPECIFIC(DECL)->u.f.wfl)
  /* List of checked thrown exceptions, as specified with the `throws'
*************** struct lang_decl_func GTY(())
*** 974,979 ****
--- 976,982 ----
    int max_locals;
    int max_stack;
    int arg_slot_count;
+   int last_line; 		/* End line number for a function decl */
    tree wfl;			/* Information on the original location */
    tree throws_list;		/* Exception specified by `throws' */
    tree function_decl_body;	/* Hold all function's statements */
Index: java/parse.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.h,v
retrieving revision 1.90
diff -c -3 -p -r1.90 parse.h
*** java/parse.h	1 May 2003 16:13:36 -0000	1.90
--- java/parse.h	9 May 2003 19:46:44 -0000
*************** typedef struct jdeplist_s jdeplist;
*** 610,623 ****
  #define GET_CURRENT_BLOCK(F) ((F) ? DECL_FUNCTION_BODY ((F)) :	\
  			     current_static_block)
  
- /* Merge an other line to the source line number of a decl. Used to
-    remember function's end. */
- #define DECL_SOURCE_LINE_MERGE(DECL,NO) DECL_SOURCE_LINE(DECL) |= (NO << 16)
- 
- /* Retrieve those two info separately. */
- #define DECL_SOURCE_LINE_FIRST(DECL)    (DECL_SOURCE_LINE(DECL) & 0x0000ffff)
- #define DECL_SOURCE_LINE_LAST(DECL)     (DECL_SOURCE_LINE(DECL) >> 16)
- 
  /* Retrieve line/column from a WFL. */
  #define EXPR_WFL_GET_LINECOL(V,LINE,COL)	\
    {						\
--- 610,615 ----
Index: java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.431
diff -c -3 -p -r1.431 parse.y
*** java/parse.y	3 May 2003 00:35:06 -0000	1.431
--- java/parse.y	9 May 2003 19:47:18 -0000
*************** find_expr_with_wfl (tree node)
*** 3139,3145 ****
  static void
  missing_return_error (tree method)
  {
!   EXPR_WFL_SET_LINECOL (wfl_operator, DECL_SOURCE_LINE_LAST (method), -2);
    parse_error_context (wfl_operator, "Missing return statement");
  }
  
--- 3139,3145 ----
  static void
  missing_return_error (tree method)
  {
!   EXPR_WFL_SET_LINECOL (wfl_operator, DECL_FUNCTION_LAST_LINE (method), -2);
    parse_error_context (wfl_operator, "Missing return statement");
  }
  
*************** finish_method_declaration (tree method_b
*** 4758,4764 ****
    /* Merge last line of the function with first line, directly in the
       function decl. It will be used to emit correct debug info. */
    if (!flag_emit_xref)
!     DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
  
    /* Since function's argument's list are shared, reset the
       ARG_FINAL_P parameter that might have been set on some of this
--- 4758,4764 ----
    /* Merge last line of the function with first line, directly in the
       function decl. It will be used to emit correct debug info. */
    if (!flag_emit_xref)
!     DECL_FUNCTION_LAST_LINE (current_function_decl) = ctxp->last_ccb_indent1;
  
    /* Since function's argument's list are shared, reset the
       ARG_FINAL_P parameter that might have been set on some of this
*************** lookup_cl (tree decl)
*** 6604,6610 ****
      }
  
    EXPR_WFL_FILENAME_NODE (cl_v) = get_identifier (DECL_SOURCE_FILE (decl));
!   EXPR_WFL_SET_LINECOL (cl_v, DECL_SOURCE_LINE_FIRST (decl), -1);
  
    line = java_get_line_col (EXPR_WFL_FILENAME (cl_v),
  			    EXPR_WFL_LINENO (cl_v), EXPR_WFL_COLNO (cl_v));
--- 6604,6610 ----
      }
  
    EXPR_WFL_FILENAME_NODE (cl_v) = get_identifier (DECL_SOURCE_FILE (decl));
!   EXPR_WFL_SET_LINECOL (cl_v, DECL_SOURCE_LINE (decl), -1);
  
    line = java_get_line_col (EXPR_WFL_FILENAME (cl_v),
  			    EXPR_WFL_LINENO (cl_v), EXPR_WFL_COLNO (cl_v));
*************** static void
*** 7313,7319 ****
  start_artificial_method_body (tree mdecl)
  {
    DECL_SOURCE_LINE (mdecl) = 1;
!   DECL_SOURCE_LINE_MERGE (mdecl, 1);
    source_start_java_method (mdecl);
    enter_block ();
  }
--- 7313,7319 ----
  start_artificial_method_body (tree mdecl)
  {
    DECL_SOURCE_LINE (mdecl) = 1;
!   DECL_FUNCTION_LAST_LINE (mdecl) = 1;
    source_start_java_method (mdecl);
    enter_block ();
  }
*************** source_end_java_method (void)
*** 7385,7395 ****
    /* Generate rtl for function exit.  */
    if (! flag_emit_class_files && ! flag_emit_xref)
      {
!       input_line = DECL_SOURCE_LINE_LAST (fndecl);
        expand_function_end (input_filename, input_line, 0);
  
-       DECL_SOURCE_LINE (fndecl) = DECL_SOURCE_LINE_FIRST (fndecl);
- 
        /* Run the optimizers and output assembler code for this function. */
        rest_of_compilation (fndecl);
      }
--- 7385,7393 ----
    /* Generate rtl for function exit.  */
    if (! flag_emit_class_files && ! flag_emit_xref)
      {
!       input_line = DECL_FUNCTION_LAST_LINE (fndecl);
        expand_function_end (input_filename, input_line, 0);
  
        /* Run the optimizers and output assembler code for this function. */
        rest_of_compilation (fndecl);
      }
*************** start_complete_expand_method (tree mdecl
*** 7894,7900 ****
        TREE_CHAIN (tem) = next;
      }
    pushdecl_force_head (DECL_ARGUMENTS (mdecl));
!   input_line = DECL_SOURCE_LINE_FIRST (mdecl);
    build_result_decl (mdecl);
  }
  
--- 7892,7898 ----
        TREE_CHAIN (tem) = next;
      }
    pushdecl_force_head (DECL_ARGUMENTS (mdecl));
!   input_line = DECL_SOURCE_LINE (mdecl);
    build_result_decl (mdecl);
  }
  

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