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]

Re: [Patch] Java: PR 13948


Ranjit Mathew wrote:
[...]
> The solution is slightly sub-optimal in that lrealpath() mallocs
> fresh memory on every invocation and *could be* a bit expensive
> not only for that reason, but also when constructed filenames
> represent symbolic links or have lots of "./" or "/../" (say).
> 
> However, I felt that doing this right away would have unnecessarily
> complicated as well as delayed my patch. This can always be
> taken up later and I didn't have any numbers to back it anyway.

I did an informal "time make bootstrap" style test with
today's CVS checkout - once with a clean tree and once with
my patch applied - on the same machine.

The times were "45m 27.523s" v/s "45m 25.200s" respecitvely.
So the patch hardly made any difference - positive or
negative - to compile times. :-/

As an aside, I noticed that while the patch I originally
posted applied cleanly on my Slackware box at home, it failed
to apply cleanly on an RHEL 3 box, though "patch" is ostensibly
at version 2.5.4 on both the boxes. I don't know the reason
for this mysterious behaviour, but if anyone wanted to apply
this patch and it didn't apply cleanly for them, here is a
version that does apply cleanly with the "patch" found in
RHEL3 with the current GCJ CVS sources:


Index: parse.y
===================================================================
--- parse.y     2004-06-15 12:22:07.000000000 +0530
+++ parse.y     2004-06-15 12:24:48.000000000 +0530
@@ -7574,26 +7574,24 @@ add_stmt_to_block (tree b, tree type, tr
   return c;
 }

-void java_layout_seen_class_methods (void)
+/* Lays out the methods for the classes seen so far.  */
+
+void
+java_layout_seen_class_methods (void)
 {
-  tree previous_list = all_class_list;
-  tree end = NULL_TREE;
   tree current;

-  while (1)
-    {
-      for (current = previous_list;
-          current != end; current = TREE_CHAIN (current))
-       layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
+  for (current = all_class_list;
+       current != NULL_TREE;
+       current = TREE_CHAIN (current))
+  {
+    tree cls = TREE_TYPE (TREE_VALUE (current));

-      if (previous_list != all_class_list)
-       {
-         end = previous_list;
-         previous_list = all_class_list;
-       }
-      else
-       break;
-    }
+    if (! CLASS_LOADED_P (cls))
+      load_class (cls, 0);
+
+    layout_class_methods (cls);
+  }
 }

 static GTY(()) tree stop_reordering;
Index: jcf-parse.c
===================================================================
--- jcf-parse.c 2004-06-15 12:22:14.000000000 +0530
+++ jcf-parse.c 2004-06-15 12:29:34.000000000 +0530
@@ -494,25 +494,26 @@ read_class (tree name)
   if (current_jcf->java_source)
     {
       const char *filename = current_jcf->filename;
-      tree file;
+      tree given_file, real_file;
       FILE *finput;
       int generate;

       java_parser_context_save_global ();
       java_push_parser_context ();
-      BUILD_FILENAME_IDENTIFIER_NODE (file, filename);
-      generate = IS_A_COMMAND_LINE_FILENAME_P (file);
+      BUILD_FILENAME_IDENTIFIER_NODE (given_file, filename);
+      real_file = get_identifier (lrealpath (filename));
+      generate = IS_A_COMMAND_LINE_FILENAME_P (given_file);
       if (wfl_operator == NULL_TREE)
        wfl_operator = build_expr_wfl (NULL_TREE, NULL, 0, 0);
-      EXPR_WFL_FILENAME_NODE (wfl_operator) = file;
+      EXPR_WFL_FILENAME_NODE (wfl_operator) = given_file;
       input_filename = ggc_strdup (filename);
       output_class = current_class = NULL_TREE;
       current_function_decl = NULL_TREE;
-      if (!HAS_BEEN_ALREADY_PARSED_P (file))
+      if (!HAS_BEEN_ALREADY_PARSED_P (real_file))
        {
          if (!(finput = fopen (input_filename, "r")))
            fatal_error ("can't reopen %s: %m", input_filename);
-         parse_source_file_1 (file, finput);
+         parse_source_file_1 (real_file, finput);
          parse_source_file_2 ();
          parse_source_file_3 ();
          if (fclose (finput))
@@ -1015,9 +1016,11 @@ java_parse_file (int set_yydebug ATTRIBU
       unsigned char magic_string[4];
       uint32 magic = 0;
       tree name = TREE_VALUE (node);
+      tree real_file;

       /* Skip already parsed files */
-      if (HAS_BEEN_ALREADY_PARSED_P (name))
+      real_file = get_identifier (lrealpath (IDENTIFIER_POINTER (name)));
+      if (HAS_BEEN_ALREADY_PARSED_P (real_file))
        continue;

       /* Close previous descriptor, if any */
@@ -1075,7 +1078,7 @@ java_parse_file (int set_yydebug ATTRIBU
          JAVA_FILE_P (node) = 1;
          java_push_parser_context ();
          java_parser_context_save_global ();
-         parse_source_file_1 (name, finput);
+         parse_source_file_1 (real_file, finput);
          java_parser_context_restore_global ();
          java_pop_parser_context (1);
        }


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