jcf-parse.c (ggc_mark_jcf): New function.
authorPer Bothner <per@bothner.com>
Sun, 21 Jan 2001 21:18:04 +0000 (13:18 -0800)
committerPer Bothner <bothner@gcc.gnu.org>
Sun, 21 Jan 2001 21:18:04 +0000 (13:18 -0800)
* jcf-parse.c (ggc_mark_jcf):  New function.
(init_jcf_parse):  Register current_jcf as ggc root.

From-SVN: r39173

gcc/java/ChangeLog
gcc/java/jcf-parse.c

index 27d6864fec7479f3c5c92e74fdc840c592365da7..a01b0b5f1948ee0a657924a7d0012cc66ecebfe7 100644 (file)
@@ -1,3 +1,8 @@
+2001-01-21  Per Bothner  <per@bothner.com>
+
+       * jcf-parse.c (ggc_mark_jcf):  New function.
+       (init_jcf_parse):  Register current_jcf as ggc root.
+
 2001-01-21  Per Bothner  <per@bothner.com>
 
        * lang.c (put_decl_node):  Print method's name.
index e917d1db2e2b59a51995ddc6aebbe7d260178e3a..b1214d456f95bf0fd9745d54a7c25e296751d0ac 100644 (file)
@@ -93,6 +93,29 @@ static int find_in_current_zip PARAMS ((const char *, struct JCF **));
 static void parse_class_file PARAMS ((void));
 static void set_source_filename PARAMS ((JCF *, int));
 static int predefined_filename_p PARAMS ((tree));
+static void ggc_mark_jcf PARAMS ((void**));
+
+/* Mark (for garbage collection) all the tree nodes that are
+   referenced from JCF's constant pool table. */
+
+static void
+ggc_mark_jcf (elt)
+     void **elt;
+{
+  JCF *jcf = *(JCF**) elt;
+  if (jcf != NULL)
+    {
+      CPool *cpool = &jcf->cpool;
+      int size = CPOOL_COUNT(cpool);
+      int index;
+      for (index = 1; index < size;  index++)
+       {
+         int tag = JPOOL_TAG (jcf, index);
+         if ((tag & CONSTANT_ResolvedFlag) || tag == CONSTANT_Utf8)
+           ggc_mark_tree ((tree) cpool->data[index]);
+       }
+    }
+}
 
 /* Handle "SourceFile" attribute. */
 
@@ -1099,4 +1122,6 @@ init_jcf_parse ()
   ggc_add_tree_root (&current_field, 1);
   ggc_add_tree_root (&current_method, 1);
   ggc_add_tree_root (&current_file_list, 1);
+
+  ggc_add_root (&current_jcf, 1, sizeof (JCF), ggc_mark_jcf);
 }