diff options
author | aph <aph@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-29 18:43:25 +0000 |
---|---|---|
committer | aph <aph@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-29 18:43:25 +0000 |
commit | f53ce661177e4d4d44f53bd236857c26e5de43a3 (patch) | |
tree | 158742ad984de1e20c807a73f81b51044ae5edee /gcc/java/constants.c | |
parent | 5e507a76a292330204dfdcb2590dbaa0fab300ae (diff) | |
download | gcc-f53ce661177e4d4d44f53bd236857c26e5de43a3.tar.gz |
2005-04-28 Andrew Haley <aph@redhat.com>
PR java/19285
* java-tree.h (soft_resolvepoolentry_node): New.
(alloc_constant_fieldref): Declare.
* expr.c (expand_java_field_op): Don't call class_init for
accesses to static fields with indirect dispatch.
* builtins.c (initialize_builtins): Add "__builtin_expect".
* decl.c (soft_resolvepoolentry_node): New variable.
(java_init_decl_processing): Create a decl for
"_Jv_ResolvePoolEntry".
* class.c (build_fieldref_cache_entry): New function.
(build_static_field_ref): Rewrite for indirect dispatch.
* constants.c (find_name_and_type_constant_tree): New function.
(alloc_constant_fieldref): Likewise.
(build_constants_constructor): Handle CONSTANT_Fieldref and
CONSTANT_NameAndType.
PR java/21115
* expr.c (force_evaluation_order): Convert outgoing args smaller
than integer.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@99010 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java/constants.c')
-rw-r--r-- | gcc/java/constants.c | 72 |
1 files changed, 63 insertions, 9 deletions
diff --git a/gcc/java/constants.c b/gcc/java/constants.c index a5d9622bdab..ff58b87852d 100644 --- a/gcc/java/constants.c +++ b/gcc/java/constants.c @@ -356,6 +356,41 @@ alloc_name_constant (int tag, tree name) return find_tree_constant (outgoing_cpool, tag, name); } +/* Create a constant pool entry for a name_and_type. This one has '.' + rather than '/' because it isn't going into a class file, it's + going into a compiled object. We don't use the '/' separator in + compiled objects. */ + +static int +find_name_and_type_constant_tree (CPool *cpool, tree name, tree type) +{ + int name_index = find_utf8_constant (cpool, name); + int type_index + = find_utf8_constant (cpool, + identifier_subst (build_java_signature (type), + "", '/', '.', "")); + return find_constant1 (cpool, CONSTANT_NameAndType, + (name_index << 16) | type_index); +} + +/* Look for a field ref that matches DECL in the constant pool of + CLASS. + Return the index of the entry. */ + +int +alloc_constant_fieldref (tree class, tree decl) +{ + CPool *outgoing_cpool = cpool_for_class (class); + int class_index + = find_tree_constant (outgoing_cpool, CONSTANT_Class, + DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))); + int name_type_index + = find_name_and_type_constant_tree (outgoing_cpool, DECL_NAME (decl), + TREE_TYPE (decl)); + return find_constant1 (outgoing_cpool, CONSTANT_Fieldref, + (class_index << 16) | name_type_index); +} + /* Build an identifier for the internal name of reference type TYPE. */ tree @@ -442,14 +477,33 @@ build_constants_constructor (void) tree data_list = NULL_TREE; int i; for (i = outgoing_cpool->count; --i > 0; ) - { - tags_list - = tree_cons (NULL_TREE, get_tag_node (outgoing_cpool->tags[i]), - tags_list); - data_list - = tree_cons (NULL_TREE, build_utf8_ref (outgoing_cpool->data[i].t), - data_list); - } + switch (outgoing_cpool->tags[i]) + { + case CONSTANT_Fieldref: + case CONSTANT_NameAndType: + { + jword temp = outgoing_cpool->data[i].w; + + tags_list + = tree_cons (NULL_TREE, + build_int_cst (NULL_TREE, outgoing_cpool->tags[i]), + tags_list); + data_list + = tree_cons (NULL_TREE, + fold_convert (ptr_type_node, + (build_int_cst (NULL_TREE, temp))), + data_list); + } + break; + default: + tags_list + = tree_cons (NULL_TREE, get_tag_node (outgoing_cpool->tags[i]), + tags_list); + data_list + = tree_cons (NULL_TREE, build_utf8_ref (outgoing_cpool->data[i].t), + data_list); + break; + } if (outgoing_cpool->count > 0) { tree data_decl, tags_decl, tags_type; @@ -461,7 +515,7 @@ build_constants_constructor (void) data_list = tree_cons (NULL_TREE, null_pointer_node, data_list); data_decl = build_constant_data_ref (); - TREE_TYPE (data_decl) = build_array_type (ptr_type_node, index_type), + TREE_TYPE (data_decl) = build_array_type (ptr_type_node, index_type); DECL_INITIAL (data_decl) = build_constructor (TREE_TYPE (data_decl), data_list); DECL_SIZE (data_decl) = TYPE_SIZE (TREE_TYPE (data_decl)); |