diff options
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/java/class.c | 47 | ||||
-rw-r--r-- | gcc/java/decl.c | 4 | ||||
-rw-r--r-- | gcc/java/except.c | 10 | ||||
-rw-r--r-- | gcc/java/expr.c | 33 | ||||
-rw-r--r-- | gcc/java/java-tree.h | 48 | ||||
-rw-r--r-- | gcc/java/lang.c | 24 |
7 files changed, 87 insertions, 84 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 1940e00..c9336d3 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,8 @@ +2014-10-12 Trevor Saunders <tsaunders@mozilla.com> + + * class.c, decl.c, except.c, expr.c, java-tree.h, lang.c: Use + hash_table instead of hashtab. + 2014-10-07 Marek Polacek <polacek@redhat.com> * jvgenmain.c (main): Provide declarations for JvRunMain{,Name}. diff --git a/gcc/java/class.c b/gcc/java/class.c index 0d51165..25af697 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -774,7 +774,7 @@ add_method_1 (tree this_class, int access_flags, tree name, tree function_type) /* Initialize the initialized (static) class table. */ if (access_flags & ACC_STATIC) DECL_FUNCTION_INITIALIZED_CLASS_TABLE (fndecl) = - htab_create_ggc (50, htab_hash_pointer, htab_eq_pointer, NULL); + hash_table<ict_hasher>::create_ggc (50); DECL_CHAIN (fndecl) = TYPE_METHODS (this_class); TYPE_METHODS (this_class) = fndecl; @@ -3070,14 +3070,12 @@ build_assertion_table_entry (tree code, tree op1, tree op2) /* Add an entry to the type assertion table. Callback used during hashtable traversal. */ -static int -add_assertion_table_entry (void **htab_entry, void *ptr) +int +add_assertion_table_entry (type_assertion **slot, vec<constructor_elt, va_gc> **v) { tree entry; tree code_val, op1_utf8, op2_utf8; - vec<constructor_elt, va_gc> **v - = ((vec<constructor_elt, va_gc> **) ptr); - type_assertion *as = (type_assertion *) *htab_entry; + type_assertion *as = *slot; code_val = build_int_cst (NULL_TREE, as->assertion_code); @@ -3103,11 +3101,12 @@ static tree emit_assertion_table (tree klass) { tree null_entry, ctor, table_decl; - htab_t assertions_htab = TYPE_ASSERTIONS (klass); + hash_table<type_assertion_hasher> *assertions_htab = TYPE_ASSERTIONS (klass); vec<constructor_elt, va_gc> *v = NULL; /* Iterate through the hash table. */ - htab_traverse (assertions_htab, add_assertion_table_entry, &v); + assertions_htab + ->traverse<vec<constructor_elt, va_gc> **, add_assertion_table_entry> (&v); /* Finish with a null entry. */ null_entry = build_assertion_table_entry (integer_zero_node, @@ -3146,36 +3145,28 @@ init_class_processing (void) gcc_obstack_init (&temporary_obstack); } -static hashval_t java_treetreehash_hash (const void *); -static int java_treetreehash_compare (const void *, const void *); - /* A hash table mapping trees to trees. Used generally. */ #define JAVA_TREEHASHHASH_H(t) ((hashval_t)TYPE_UID (t)) -static hashval_t -java_treetreehash_hash (const void *k_p) +hashval_t +treetreehasher::hash (treetreehash_entry *k) { - const struct treetreehash_entry *const k - = (const struct treetreehash_entry *) k_p; return JAVA_TREEHASHHASH_H (k->key); } -static int -java_treetreehash_compare (const void * k1_p, const void * k2_p) +bool +treetreehasher::equal (treetreehash_entry *k1, tree k2) { - const struct treetreehash_entry *const k1 - = (const struct treetreehash_entry *) k1_p; - const_tree const k2 = (const_tree) k2_p; return (k1->key == k2); } tree -java_treetreehash_find (htab_t ht, tree t) +java_treetreehash_find (hash_table<treetreehasher> *ht, tree t) { struct treetreehash_entry *e; hashval_t hv = JAVA_TREEHASHHASH_H (t); - e = (struct treetreehash_entry *) htab_find_with_hash (ht, t, hv); + e = ht->find_with_hash (t, hv); if (e == NULL) return NULL; else @@ -3183,13 +3174,12 @@ java_treetreehash_find (htab_t ht, tree t) } tree * -java_treetreehash_new (htab_t ht, tree t) +java_treetreehash_new (hash_table<treetreehasher> *ht, tree t) { - void **e; struct treetreehash_entry *tthe; hashval_t hv = JAVA_TREEHASHHASH_H (t); - e = htab_find_slot_with_hash (ht, t, hv, INSERT); + treetreehash_entry **e = ht->find_slot_with_hash (t, hv, INSERT); if (*e == NULL) { tthe = ggc_cleared_alloc<treetreehash_entry> (); @@ -3197,15 +3187,14 @@ java_treetreehash_new (htab_t ht, tree t) *e = tthe; } else - tthe = (struct treetreehash_entry *) *e; + tthe = *e; return &tthe->value; } -htab_t +hash_table<treetreehasher> * java_treetreehash_create (size_t size) { - return htab_create_ggc (size, java_treetreehash_hash, - java_treetreehash_compare, NULL); + return hash_table<treetreehasher>::create_ggc (size); } /* Break down qualified IDENTIFIER into package and class-name components. diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 607aece..7271ea7 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -1846,8 +1846,8 @@ end_java_method (void) variable to the block_body */ fbody = DECL_SAVED_TREE (fndecl); block_body = BIND_EXPR_BODY (fbody); - htab_traverse (DECL_FUNCTION_INIT_TEST_TABLE (fndecl), - attach_init_test_initialization_flags, block_body); + hash_table<treetreehasher> *ht = DECL_FUNCTION_INIT_TEST_TABLE (fndecl); + ht->traverse<tree, attach_init_test_initialization_flags> (block_body); } finish_method (fndecl); diff --git a/gcc/java/except.c b/gcc/java/except.c index 47c76e8..492e977 100644 --- a/gcc/java/except.c +++ b/gcc/java/except.c @@ -433,10 +433,10 @@ prepare_eh_table_type (tree type) return exp; } -static int -expand_catch_class (void **entry, void *x ATTRIBUTE_UNUSED) +int +expand_catch_class (treetreehash_entry **entry, int) { - struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry; + struct treetreehash_entry *ite = *entry; tree addr = TREE_VALUE ((tree)ite->value); tree decl; STRIP_NOPS (addr); @@ -452,9 +452,7 @@ void java_expand_catch_classes (tree this_class) { if (TYPE_TO_RUNTIME_MAP (this_class)) - htab_traverse - (TYPE_TO_RUNTIME_MAP (this_class), - expand_catch_class, NULL); + TYPE_TO_RUNTIME_MAP (this_class)->traverse<int, expand_catch_class> (0); } /* Build and push the variable that will hold the exception object diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 51b8f0f..877f1b0 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -398,22 +398,19 @@ pop_type (tree type) /* Return true if two type assertions are equal. */ -static int -type_assertion_eq (const void * k1_p, const void * k2_p) +bool +type_assertion_hasher::equal (type_assertion *k1, type_assertion *k2) { - const type_assertion k1 = *(const type_assertion *)k1_p; - const type_assertion k2 = *(const type_assertion *)k2_p; - return (k1.assertion_code == k2.assertion_code - && k1.op1 == k2.op1 - && k1.op2 == k2.op2); + return (k1->assertion_code == k2->assertion_code + && k1->op1 == k2->op1 + && k1->op2 == k2->op2); } /* Hash a type assertion. */ -static hashval_t -type_assertion_hash (const void *p) +hashval_t +type_assertion_hasher::hash (type_assertion *k_p) { - const type_assertion *k_p = (const type_assertion *) p; hashval_t hash = iterative_hash (&k_p->assertion_code, sizeof k_p->assertion_code, 0); @@ -449,15 +446,14 @@ type_assertion_hash (const void *p) void add_type_assertion (tree klass, int assertion_code, tree op1, tree op2) { - htab_t assertions_htab; + hash_table<type_assertion_hasher> *assertions_htab; type_assertion as; - void **as_pp; + type_assertion **as_pp; assertions_htab = TYPE_ASSERTIONS (klass); if (assertions_htab == NULL) { - assertions_htab = htab_create_ggc (7, type_assertion_hash, - type_assertion_eq, NULL); + assertions_htab = hash_table<type_assertion_hasher>::create_ggc (7); TYPE_ASSERTIONS (current_class) = assertions_htab; } @@ -465,14 +461,14 @@ add_type_assertion (tree klass, int assertion_code, tree op1, tree op2) as.op1 = op1; as.op2 = op2; - as_pp = htab_find_slot (assertions_htab, &as, INSERT); + as_pp = assertions_htab->find_slot (&as, INSERT); /* Don't add the same assertion twice. */ if (*as_pp) return; *as_pp = ggc_alloc<type_assertion> (); - **(type_assertion **)as_pp = as; + **as_pp = as; } @@ -1946,10 +1942,9 @@ pop_arguments (tree method_type) /* Attach to PTR (a block) the declaration found in ENTRY. */ int -attach_init_test_initialization_flags (void **entry, void *ptr) +attach_init_test_initialization_flags (treetreehash_entry **slot, tree block) { - tree block = (tree)ptr; - struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry; + treetreehash_entry *ite = *slot; if (block != error_mark_node) { diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index e832f44..40b687d 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -710,6 +710,25 @@ union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"), && TREE_CODE (TREE_TYPE (NODE)) != POINTER_TYPE) \ || TREE_CODE (NODE) == REAL_CST) +struct GTY((for_user)) treetreehash_entry { + tree key; + tree value; +}; + +struct treetreehasher : ggc_hasher<treetreehash_entry *> +{ + typedef tree compare_type; + + static hashval_t hash (treetreehash_entry *); + static bool equal (treetreehash_entry *, tree); +}; + +struct ict_hasher : ggc_hasher<tree_node *> +{ + static hashval_t hash (tree t) { return htab_hash_pointer (t); } + static bool equal (tree a, tree b) { return a == b; } +}; + /* DECL_LANG_SPECIFIC for FUNCTION_DECLs. */ struct GTY(()) lang_decl_func { /* tree chain; not yet used. */ @@ -726,10 +745,10 @@ struct GTY(()) lang_decl_func { tree exc_obj; /* Decl holding the exception object. */ /* Class initialization test variables */ - htab_t GTY ((param_is (struct treetreehash_entry))) init_test_table; + hash_table<treetreehasher> *init_test_table; /* Initialized (static) Class Table */ - htab_t GTY ((param_is (union tree_node))) ict; + hash_table<ict_hasher> *ict; unsigned int native : 1; /* Nonzero if this is a native method */ unsigned int strictfp : 1; @@ -742,11 +761,6 @@ struct GTY(()) lang_decl_func { unsigned int varargs : 1; /* Varargs method. */ }; -struct GTY(()) treetreehash_entry { - tree key; - tree value; -}; - /* These represent the possible assertion_codes that can be emitted in the type assertion table. */ enum @@ -778,15 +792,21 @@ typedef enum JV_ANNOTATION_DEFAULT_KIND } jv_attr_kind; -typedef struct GTY(()) type_assertion { +typedef struct GTY((for_user)) type_assertion { int assertion_code; /* 'opcode' for the type of this assertion. */ tree op1; /* First operand. */ tree op2; /* Second operand. */ } type_assertion; -extern tree java_treetreehash_find (htab_t, tree); -extern tree * java_treetreehash_new (htab_t, tree); -extern htab_t java_treetreehash_create (size_t size); +struct type_assertion_hasher : ggc_hasher<type_assertion *> +{ + static hashval_t hash (type_assertion *); + static bool equal (type_assertion *, type_assertion *); +}; + +extern tree java_treetreehash_find (hash_table<treetreehasher> *, tree); +extern tree * java_treetreehash_new (hash_table<treetreehasher> *, tree); +extern hash_table<treetreehasher> *java_treetreehash_create (size_t size); /* DECL_LANG_SPECIFIC for VAR_DECL, PARM_DECL and sometimes FIELD_DECL (access methods on outer class fields) and final fields. */ @@ -893,11 +913,11 @@ struct GTY(()) lang_type { type matcher. */ vec<constructor_elt, va_gc> *catch_classes; - htab_t GTY ((param_is (struct treetreehash_entry))) type_to_runtime_map; + hash_table<treetreehasher> *type_to_runtime_map; /* The mapping of classes to exception region markers. */ - htab_t GTY ((param_is (struct type_assertion))) type_assertions; + hash_table<type_assertion_hasher> *type_assertions; /* Table of type assertions to be evaluated by the runtime when this class is loaded. */ @@ -1013,7 +1033,7 @@ extern void maybe_rewrite_invocation (tree *, vec<tree, va_gc> **, tree *, extern tree build_known_method_ref (tree, tree, tree, tree, vec<tree, va_gc> *, tree); extern tree build_class_init (tree, tree); -extern int attach_init_test_initialization_flags (void **, void *); +extern int attach_init_test_initialization_flags (treetreehash_entry **, tree); extern tree build_invokevirtual (tree, tree, tree); extern tree build_invokeinterface (tree, tree); extern tree build_jni_stub (tree); diff --git a/gcc/java/lang.c b/gcc/java/lang.c index 8a68691..7f0b09d 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -57,8 +57,6 @@ static void put_decl_string (const char *, int); static void put_decl_node (tree, int); static void java_print_error_function (diagnostic_context *, const char *, diagnostic_info *); -static int merge_init_test_initialization (void * *, void *); -static int inline_init_test_initialization (void * *, void *); static bool java_dump_tree (void *, tree); static void dump_compound_expr (dump_info_p, tree); static bool java_decl_ok_for_sibcall (const_tree); @@ -713,10 +711,10 @@ decl_constant_value (tree decl) /* Create a mapping from a boolean variable in a method being inlined to one in the scope of the method being inlined into. */ -static int -merge_init_test_initialization (void **entry, void *x) +int +merge_init_test_initialization (treetreehash_entry **entry, void *x) { - struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry; + struct treetreehash_entry *ite = *entry; splay_tree decl_map = (splay_tree)x; splay_tree_node n; tree *init_test_decl; @@ -761,9 +759,8 @@ merge_init_test_initialization (void **entry, void *x) void java_inlining_merge_static_initializers (tree fn, void *decl_map) { - htab_traverse - (DECL_FUNCTION_INIT_TEST_TABLE (fn), - merge_init_test_initialization, decl_map); + DECL_FUNCTION_INIT_TEST_TABLE (fn) + ->traverse<void *, merge_init_test_initialization> (decl_map); } /* Lookup a DECL_FUNCTION_INIT_TEST_TABLE entry in the method we're @@ -772,10 +769,10 @@ java_inlining_merge_static_initializers (tree fn, void *decl_map) from the variable in the inlined class to the corresponding pre-existing one. */ -static int -inline_init_test_initialization (void **entry, void *x) +int +inline_init_test_initialization (treetreehash_entry **entry, void *x) { - struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry; + struct treetreehash_entry *ite = *entry; splay_tree decl_map = (splay_tree)x; tree h = java_treetreehash_find @@ -796,9 +793,8 @@ inline_init_test_initialization (void **entry, void *x) void java_inlining_map_static_initializers (tree fn, void *decl_map) { - htab_traverse - (DECL_FUNCTION_INIT_TEST_TABLE (fn), - inline_init_test_initialization, decl_map); + DECL_FUNCTION_INIT_TEST_TABLE (fn) + ->traverse<void *, inline_init_test_initialization> (decl_map); } /* Avoid voluminous output for deep recursion of compound exprs. */ |