summaryrefslogtreecommitdiff
path: root/gcc/java/constants.c
diff options
context:
space:
mode:
authoraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>2007-02-02 16:34:17 +0000
committeraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>2007-02-02 16:34:17 +0000
commitcd725222ac425b66dc3901f74f55f38e32947a59 (patch)
tree825931419e51fa7cc806a34c9dce994cb91d820f /gcc/java/constants.c
parent8a6f311ec471a5f351d390a168b792fa20a1cac1 (diff)
downloadgcc-cd725222ac425b66dc3901f74f55f38e32947a59.tar.gz
2007-02-02 Andrew Haley <aph@redhat.com>
* expr.c (expand_byte_code): Call cache_this_class_ref() and cache_cpool_data_ref(). Set TYPE_CPOOL_DATA_REF. (cache_cpool_data_ref): New function. * constants.c (build_ref_from_constant_pool): Remove special-case code for flag_indirect_classes. (build_constant_data_ref): Move special-case code for flag_indirect_classes here from build_ref_from_constant_pool. * decl.c (finish_method): Move class initialization from here to cache_this_class_ref. * class.c (cache_this_class_ref): New function. (build_class_ref): Use this_classdollar for the ouput class. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121508 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java/constants.c')
-rw-r--r--gcc/java/constants.c68
1 files changed, 37 insertions, 31 deletions
diff --git a/gcc/java/constants.c b/gcc/java/constants.c
index 70e5321de00..ca138f62130 100644
--- a/gcc/java/constants.c
+++ b/gcc/java/constants.c
@@ -36,7 +36,6 @@ static void set_constant_entry (CPool *, int, int, jword);
static int find_tree_constant (CPool *, int, tree);
static int find_name_and_type_constant (CPool *, tree, tree);
static tree get_tag_node (int);
-static tree build_constant_data_ref (void);
/* Set the INDEX'th constant in CPOOL to have the given TAG and VALUE. */
@@ -424,14 +423,36 @@ alloc_class_constant (tree clas)
/* Return the decl of the data array of the current constant pool. */
-static tree
-build_constant_data_ref (void)
+tree
+build_constant_data_ref (bool indirect)
{
- tree decl = TYPE_CPOOL_DATA_REF (output_class);
+ if (indirect)
+ {
+ tree d;
+ tree cpool_type = build_array_type (ptr_type_node, NULL_TREE);
+ tree decl = build_class_ref (output_class);
+ tree klass = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (decl)),
+ decl);
+ tree constants = build3 (COMPONENT_REF,
+ TREE_TYPE (constants_field_decl_node), klass,
+ constants_field_decl_node,
+ NULL_TREE);
+ tree data = build3 (COMPONENT_REF,
+ TREE_TYPE (constants_data_field_decl_node),
+ constants,
+ constants_data_field_decl_node,
+ NULL_TREE);
- if (decl == NULL_TREE)
+ TREE_THIS_NOTRAP (klass) = 1;
+ data = fold_convert (build_pointer_type (cpool_type), data);
+ d = build1 (INDIRECT_REF, cpool_type, data);
+ TREE_INVARIANT (d) = 1;
+
+ return d;
+ }
+ else
{
- tree type;
+ tree type, decl;
tree decl_name = mangled_classname ("_CD_", output_class);
/* Build a type with unspecified bounds. The will make sure
@@ -446,10 +467,9 @@ build_constant_data_ref (void)
decl = build_decl (VAR_DECL, decl_name, type);
TREE_STATIC (decl) = 1;
- TYPE_CPOOL_DATA_REF (output_class) = decl;
- }
- return decl;
+ return decl;
+ }
}
/* Get the pointer value at the INDEX'th element of the constant pool. */
@@ -457,27 +477,13 @@ build_constant_data_ref (void)
tree
build_ref_from_constant_pool (int index)
{
- tree d = build_constant_data_ref ();
- tree i = build_int_cst (NULL_TREE, index);
- if (flag_indirect_classes)
- {
- tree decl = build_class_ref (output_class);
- tree klass = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (decl)),
- decl);
- tree constants = build3 (COMPONENT_REF,
- TREE_TYPE (constants_field_decl_node), klass,
- constants_field_decl_node,
- NULL_TREE);
- tree data = build3 (COMPONENT_REF,
- TREE_TYPE (constants_data_field_decl_node),
- constants,
- constants_data_field_decl_node,
- NULL_TREE);
- data = fold_convert (build_pointer_type (TREE_TYPE (d)), data);
- d = build1 (INDIRECT_REF, TREE_TYPE (d), data);
- /* FIXME: These should be cached. */
- TREE_INVARIANT (d) = 1;
- }
+ tree i;
+ tree d = TYPE_CPOOL_DATA_REF (output_class);
+
+ if (d == NULL_TREE)
+ d = build_constant_data_ref (flag_indirect_classes);
+
+ i = build_int_cst (NULL_TREE, index);
d = build4 (ARRAY_REF, TREE_TYPE (TREE_TYPE (d)), d, i,
NULL_TREE, NULL_TREE);
TREE_INVARIANT (d) = 1;
@@ -557,7 +563,7 @@ build_constants_constructor (void)
tags_list = tree_cons (NULL_TREE, get_tag_node (0), tags_list);
data_list = tree_cons (NULL_TREE, null_pointer_node, data_list);
- data_decl = build_constant_data_ref ();
+ data_decl = build_constant_data_ref (false);
TREE_TYPE (data_decl) = build_array_type (ptr_type_node, index_type);
DECL_INITIAL (data_decl) = build_constructor_from_list
(TREE_TYPE (data_decl), data_list);