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]

[PATCH,java] VECify method tables in struct lang_type


As $SUBJECT suggests.  More TREE_LIST removal is a good thing.

Tested on x86_64-unknown-linux-gnu (libjava).  No regressions.  OK to
commit?

-Nathan

	* java-tree.h (method_entry): Declare.  Declare VECs containing it.
	(struct lang_type): Change type of otable_methods, atable_methods, and
	itable_methods to VECs.  Fix comment for atable_methods.
	(emit_symbol_table): Take a VEC instead of a tree.
	(get_symbol_table_index): Take a VEC * instead of a tree *.
	* class.c (add_table_and_syms): Take a VEC instead of a tree.
	(emit_symbol_table): Update for changed parameter type.
	* expr.c (get_symbol_table_index): Likewise.

Index: class.c
===================================================================
--- class.c	(revision 159899)
+++ class.c	(working copy)
@@ -1720,11 +1720,11 @@ supers_all_compiled (tree type)
 
 static void
 add_table_and_syms (VEC(constructor_elt,gc) **v,
-                    tree method_slot,
+                    VEC(method_entry,gc) *methods,
                     const char *table_name, tree table_slot, tree table_type,
                     const char *syms_name, tree syms_slot)
 {
-  if (method_slot == NULL_TREE)
+  if (methods == NULL)
     {
       PUSH_FIELD_VALUE (*v, table_name, null_pointer_node);
       PUSH_FIELD_VALUE (*v, syms_name, null_pointer_node);
@@ -2886,31 +2886,27 @@ build_symbol_entry (tree decl, tree spec
 /* Emit a symbol table: used by -findirect-dispatch.  */
 
 tree
-emit_symbol_table (tree name, tree the_table, tree decl_list,
+emit_symbol_table (tree name, tree the_table,
+		   VEC(method_entry,gc) *decl_table,
                    tree the_syms_decl, tree the_array_element_type,
 		   int element_size)
 {
-  tree method_list, method, table, list, null_symbol;
+  tree table, list, null_symbol;
   tree table_size, the_array_type;
-  int index;
+  unsigned index;
+  method_entry *e;
   
   /* Only emit a table if this translation unit actually made any
      references via it. */
-  if (decl_list == NULL_TREE)
+  if (decl_table == NULL)
     return the_table;
 
   /* Build a list of _Jv_MethodSymbols for each entry in otable_methods. */
-  index = 0;
-  method_list = decl_list;
-  list = NULL_TREE;  
-  while (method_list != NULL_TREE)
-    {
-      tree special = TREE_PURPOSE (method_list);
-      method = TREE_VALUE (method_list);
-      list = tree_cons (NULL_TREE, build_symbol_entry (method, special), list);
-      method_list = TREE_CHAIN (method_list);
-      index++;
-    }
+  list = NULL_TREE;
+  for (index = 0; VEC_iterate (method_entry, decl_table, index, e); index++)
+    list = tree_cons (NULL_TREE,
+		      build_symbol_entry (e->method, e->special),
+		      list);
 
   /* Terminate the list with a "null" entry. */
   null_symbol = build_symbol_table_entry (null_pointer_node,
Index: ChangeLog
===================================================================
Index: expr.c
===================================================================
--- expr.c	(revision 159898)
+++ expr.c	(working copy)
@@ -2289,34 +2289,22 @@ invoke_build_dtable (int is_invoke_inter
    reused.  */
 
 int
-get_symbol_table_index (tree t, tree special, tree *symbol_table)
+get_symbol_table_index (tree t, tree special,
+			VEC(method_entry,gc) **symbol_table)
 {
-  int i = 1;
-  tree method_list;
+  method_entry *e;
+  unsigned i;
 
-  if (*symbol_table == NULL_TREE)
-    {
-      *symbol_table = build_tree_list (special, t);
-      return 1;
-    }
-  
-  method_list = *symbol_table;
-  
-  while (1)
-    {
-      tree value = TREE_VALUE (method_list);
-      tree purpose = TREE_PURPOSE (method_list);
-      if (value == t && purpose == special)
-	return i;
-      i++;
-      if (TREE_CHAIN (method_list) == NULL_TREE)
-        break;
-      else
-        method_list = TREE_CHAIN (method_list);
-    }
+  for (i = 0; VEC_iterate (method_entry, *symbol_table, i, e); i++)
+    if (t == e->method && special == e->special)
+      goto done;
+
+  e = VEC_safe_push (method_entry, gc, *symbol_table, NULL);
+  e->method = t;
+  e->special = special;
 
-  TREE_CHAIN (method_list) = build_tree_list (special, t);
-  return i;
+ done:
+  return i+1;
 }
 
 tree 
Index: java-tree.h
===================================================================
--- java-tree.h	(revision 159899)
+++ java-tree.h	(working copy)
@@ -916,6 +916,14 @@ struct GTY(()) lang_decl {
 #define TYPE_REFLECTION_DATASIZE(T)					\
 				(TYPE_LANG_SPECIFIC (T)->reflection_datasize)
 
+typedef struct GTY(()) method_entry_d {
+  tree method;
+  tree special;
+} method_entry;
+
+DEF_VEC_O(method_entry);
+DEF_VEC_ALLOC_O(method_entry,gc);
+
 struct GTY(()) lang_type {
   tree signature;
   struct JCF *jcf;
@@ -923,18 +931,18 @@ struct GTY(()) lang_type {
   tree cpool_data_ref;		/* Cached */
   tree package_list;		/* List of package names, progressive */
 
-  tree otable_methods;          /* List of static decls referred to by this
-				   class.  */
+  VEC(method_entry,gc) *otable_methods; /* List of static decls referred
+					   to by this class.  */
   tree otable_decl;		/* The static address table.  */
   tree otable_syms_decl;
 
-  tree atable_methods;          /* List of static decls referred to by this
-				   class.  */
+  VEC(method_entry,gc) *atable_methods; /* List of abstract methods
+					   referred to by this class.  */
   tree atable_decl;		/* The static address table.  */
   tree atable_syms_decl;
 
-  tree itable_methods;          /* List of interfaces methods referred
-				   to by this class.  */
+  VEC(method_entry,gc) *itable_methods; /* List of interface methods
+					   referred to by this class.  */
   tree itable_decl;		/* The interfaces table.  */
   tree itable_syms_decl;
 
@@ -1103,7 +1111,8 @@ extern void make_class_data (tree);
 extern int alloc_name_constant (int, tree);
 extern int alloc_constant_fieldref (tree, tree);
 extern void emit_register_classes (tree *);
-extern tree emit_symbol_table (tree, tree, tree, tree, tree, int);
+extern tree emit_symbol_table (tree, tree, VEC(method_entry,gc) *,
+			       tree, tree, int);
 extern void lang_init_source (int);
 extern void write_classfile (tree);
 extern char *print_int_node (tree);
@@ -1206,7 +1215,7 @@ extern void register_exception_range(str
 extern void finish_method (tree);
 extern void java_expand_body (tree);
 
-extern int get_symbol_table_index (tree, tree, tree *);
+extern int get_symbol_table_index (tree, tree, VEC(method_entry,gc) **);
 
 extern tree make_catch_class_record (tree, tree);
 extern tree emit_catch_table (tree);


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