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]

[PATCH] GC for objective C


Hi!

gcc fails to bootstrap on sparc64-linux, because cc1obj does not register
some tree roots for garbage collection.
This patch tries to fix that as well as shut it down on sparc64 and ia64.
The only unfortunate thing is that objc uses DECL_RESULT_FLD(t) == (tree) 1
for some its internal stuff and tree type is 'd'. Anyone can think of a
better solution than to write it like this into ggc-common?
Perhaps if lang_mark_tree was returning a value and if it returned non-zero,
gcc_mark_trees would exit immediately, then it could be coded in objc's
lang_mark_tree only (but in that case we'd have to split C and ObjC
lang_mark_tree). Ideas?

2000-04-10  Jakub Jelinek  <jakub@redhat.com>

	* objc/objc-act.c: Include ggc.h.
	(lang_init): Call objc_act_parse_init and c_parse_init.
	(ggc_mark_imp_list): New function.
	(ggc_mark_hash_table): New function.
	(objc_act_parse_init): New function.
	* objc/objc-act.h (objc_act_parse_init): Add prototype.
	* ggc-common.c (ggc_mark_trees): Allow DECL_RESULT_FLD
	to be (tree) 1.

	* Object.m (strlen): Provide prototype on all 64bit platforms,
	not only alpha.
	* sarray.c (memcpy): Likewise.

--- gcc/objc/objc-act.c.jj	Mon Mar 27 12:20:07 2000
+++ gcc/objc/objc-act.c	Mon Apr 10 18:36:14 2000
@@ -51,6 +51,7 @@ Boston, MA 02111-1307, USA.  */
 #include "function.h"
 #include "output.h"
 #include "toplev.h"
+#include "ggc.h"
 
 #if USE_CPPLIB
 #include "cpplib.h"
@@ -661,6 +662,9 @@ lang_init ()
 
   if (print_struct_values)
     generate_struct_by_value_array ();
+
+  objc_act_parse_init ();
+  c_parse_init ();
 }
 
 static void
@@ -8470,4 +8474,105 @@ objc_debug (fp)
 void
 print_lang_statistics ()
 {
+}
+
+static void
+ggc_mark_imp_list (arg)
+    void *arg;
+{
+  struct imp_entry *impent;
+
+  for (impent = *(struct imp_entry **)arg; impent; impent = impent->next)
+    {
+      ggc_mark_tree (impent->imp_context);
+      ggc_mark_tree (impent->imp_template);
+      ggc_mark_tree (impent->class_decl);
+      ggc_mark_tree (impent->meta_decl);
+    }
+}
+
+static void
+ggc_mark_hash_table (arg)
+    void *arg;
+{
+  hash *hash_table = *(hash **)arg;
+  hash hst;
+  attr list;
+  int i;
+
+  if (hash_table == NULL)
+    return;
+  for (i = 0; i < SIZEHASHTABLE; i++)
+    for (hst = hash_table [i]; hst; hst = hst->next)
+      {
+	ggc_mark_tree (hst->key);
+	for (list = hst->list; list; list = list->next)
+	  ggc_mark_tree (list->value);
+      }
+}
+
+/* Add GC roots for variables local to this file.  */
+void
+objc_act_parse_init ()
+{
+  ggc_add_tree_root (&objc_static_instances, 1);
+  ggc_add_tree_root (&static_instances_decl, 1);
+  ggc_add_tree_root (&self_id, 1);
+  ggc_add_tree_root (&ucmd_id, 1);
+  ggc_add_tree_root (&unused_list, 1);
+  ggc_add_tree_root (&self_decl, 1);
+  ggc_add_tree_root (&umsg_decl, 1);
+  ggc_add_tree_root (&umsg_super_decl, 1);
+  ggc_add_tree_root (&objc_get_class_decl, 1);
+  ggc_add_tree_root (&objc_get_meta_class_decl, 1);
+  ggc_add_tree_root (&super_type, 1);
+  ggc_add_tree_root (&selector_type, 1);
+  ggc_add_tree_root (&id_type, 1);
+  ggc_add_tree_root (&objc_class_type, 1);
+  ggc_add_tree_root (&instance_type, 1);
+  ggc_add_tree_root (&protocol_type, 1);
+  ggc_add_tree_root (&class_chain, 1);
+  ggc_add_tree_root (&alias_chain, 1);
+  ggc_add_tree_root (&interface_chain, 1);
+  ggc_add_tree_root (&protocol_chain, 1);
+  ggc_add_tree_root (&cls_ref_chain, 1);
+  ggc_add_tree_root (&sel_ref_chain, 1);
+  ggc_add_tree_root (&class_names_chain, 1);
+  ggc_add_tree_root (&meth_var_names_chain, 1);
+  ggc_add_tree_root (&meth_var_types_chain, 1);
+  ggc_add_tree_root (&UOBJC_SYMBOLS_decl, 1);
+  ggc_add_tree_root (&UOBJC_INSTANCE_VARIABLES_decl, 1);
+  ggc_add_tree_root (&UOBJC_CLASS_VARIABLES_decl, 1);
+  ggc_add_tree_root (&UOBJC_INSTANCE_METHODS_decl, 1);
+  ggc_add_tree_root (&UOBJC_CLASS_METHODS_decl, 1);
+  ggc_add_tree_root (&UOBJC_CLASS_decl, 1);
+  ggc_add_tree_root (&UOBJC_METACLASS_decl, 1);
+  ggc_add_tree_root (&UOBJC_SELECTOR_TABLE_decl, 1);
+  ggc_add_tree_root (&UOBJC_MODULES_decl, 1);
+  ggc_add_tree_root (&UOBJC_STRINGS_decl, 1);
+  ggc_add_tree_root (&implementation_context, 1);
+  ggc_add_tree_root (&implementation_template, 1);
+  ggc_add_tree_root (&objc_class_template, 1);
+  ggc_add_tree_root (&objc_category_template, 1);
+  ggc_add_tree_root (&uprivate_record, 1);
+  ggc_add_tree_root (&objc_protocol_template, 1);
+  ggc_add_tree_root (&objc_selector_template, 1);
+  ggc_add_tree_root (&ucls_super_ref, 1);
+  ggc_add_tree_root (&uucls_super_ref, 1);
+  ggc_add_tree_root (&objc_method_template, 1);
+  ggc_add_tree_root (&objc_ivar_template, 1);
+  ggc_add_tree_root (&objc_symtab_template, 1);
+  ggc_add_tree_root (&objc_module_template, 1);
+  ggc_add_tree_root (&objc_super_template, 1);
+  ggc_add_tree_root (&objc_object_reference, 1);
+  ggc_add_tree_root (&objc_object_id, 1);
+  ggc_add_tree_root (&objc_class_id, 1);
+  ggc_add_tree_root (&objc_id_id, 1);
+  ggc_add_tree_root (&constant_string_id, 1);
+  ggc_add_tree_root (&constant_string_type, 1);
+  ggc_add_tree_root (&UOBJC_SUPER_decl, 1);
+  ggc_add_tree_root (&method_context, 1);
+  ggc_add_root (&imp_list, 1, sizeof imp_list, ggc_mark_imp_list);
+  ggc_add_root (&nst_method_hash_list, 1, sizeof nst_method_hash_list, ggc_mark_hash_table);
+  ggc_add_root (&cls_method_hash_list, 1, sizeof cls_method_hash_list, ggc_mark_hash_table);
 }
--- gcc/objc/objc-act.h.jj	Tue Jan 18 22:33:19 2000
+++ gcc/objc/objc-act.h	Mon Apr 10 12:00:50 2000
@@ -52,6 +52,7 @@ tree build_keyword_decl				PARAMS ((tree
 tree build_method_decl				PARAMS ((enum tree_code, tree, tree, tree));
 tree build_protocol_expr			PARAMS ((tree));
 tree build_objc_string_object			PARAMS ((tree));
+void objc_act_parse_init			PARAMS ((void));
 
 extern tree objc_ivar_chain;
 extern tree objc_method_context;
--- gcc/ggc-common.c.jj	Fri Apr  7 23:02:22 2000
+++ gcc/ggc-common.c	Mon Apr 10 18:35:23 2000
@@ -402,7 +402,8 @@ ggc_mark_trees ()
 	  ggc_mark_tree (DECL_NAME (t));
 	  ggc_mark_tree (DECL_CONTEXT (t));
 	  ggc_mark_tree (DECL_ARGUMENTS (t));
-	  ggc_mark_tree (DECL_RESULT_FLD (t));
+	  if (DECL_RESULT_FLD (t) != (tree) 1)
+	    ggc_mark_tree (DECL_RESULT_FLD (t));
 	  ggc_mark_tree (DECL_INITIAL (t));
 	  ggc_mark_tree (DECL_ABSTRACT_ORIGIN (t));
 	  ggc_mark_tree (DECL_ASSEMBLER_NAME (t));
--- libobjc/Object.m.jj	Sat Sep  4 17:09:19 1999
+++ libobjc/Object.m	Mon Apr 10 16:49:03 2000
@@ -320,7 +320,7 @@ extern int errno;
                      object_get_class_name(self), sel_get_name(aSel)];
 }
 
-#ifdef __alpha__
+#if defined(__alpha__) || (defined(__sparc__) && (defined(__sparcv9) || defined(__arch64__))) || (defined(__ia64__) && defined(__LP64__))
 extern size_t strlen(const char*);
 #endif
 
--- libobjc/sarray.c.jj	Wed Sep 30 04:13:12 1998
+++ libobjc/sarray.c	Mon Apr 10 16:49:36 2000
@@ -44,7 +44,7 @@ const char* __objc_sparse2_id = "2 level
 const char* __objc_sparse3_id = "3 level sparse indices";
 #endif
 
-#ifdef __alpha__
+#if defined(__alpha__) || (defined(__sparc__) && (defined(__sparcv9) || defined(__arch64__))) || (defined(__ia64__) && defined(__LP64__))
 const void *memcpy (void*, const void*, size_t);
 #endif
 

	Jakub

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