summaryrefslogtreecommitdiff
path: root/gcc/java/expr.c
diff options
context:
space:
mode:
authorhboehm <hboehm@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-14 19:01:02 +0000
committerhboehm <hboehm@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-14 19:01:02 +0000
commita8f5ddb8b5f8949f32c7e04dad87e81ddf92d629 (patch)
treedef86bbb77acbb0823471cf90f10ce49709dfe9d /gcc/java/expr.c
parent44397f89280626458ac2e2959e2387ff1eaf0da3 (diff)
downloadgcc-a8f5ddb8b5f8949f32c7e04dad87e81ddf92d629.tar.gz
* class.c (get_dispatch_table): Fix java vtable layout
for TARGET_VTABLE_USES_DESCRIPTORS. * decl.c (java_init_decl_processing): Initialize alloc_no_finalizer_node, finalize_identifier_node. * expr.c (class_has_finalize_method): New function. (expand_java_NEW): Generate calls for finalizer-free allocation. (build_invokevirtual): Fix java vtable layout for TARGET_VTABLE_USES_DESCRIPTORS. * java-tree.h (enum java_tree_index): New entries: JTI_ALLOC_NO_FINALIZER_NODE, JTI_FINALIZE_IDENTIFIER_NODE. (alloc_no_finalizer_node, finalize_deintifier_node): New macros. (class_has_finalize_method): declare. (HAS_FINALIZER_P): New macro. * parse.y (patch_invoke): Generate calls for finalizer-free allocation. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48004 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java/expr.c')
-rw-r--r--gcc/java/expr.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index f865d958008..ef1a13959e1 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -1131,15 +1131,31 @@ build_address_of (value)
return build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (value)), value);
}
+bool class_has_finalize_method (type)
+ tree type;
+{
+ tree super = CLASSTYPE_SUPER (type);
+
+ if (super == NULL_TREE)
+ return false; /* Every class with a real finalizer inherits */
+ /* from java.lang.Object. */
+ else
+ return HAS_FINALIZER_P (type) || class_has_finalize_method (super);
+}
+
static void
expand_java_NEW (type)
tree type;
{
+ tree alloc_node;
+
+ alloc_node = (class_has_finalize_method (type) ? alloc_object_node
+ : alloc_no_finalizer_node);
if (! CLASS_LOADED_P (type))
load_class (type, 1);
safe_layout_class (type);
push_value (build (CALL_EXPR, promote_type (type),
- build_address_of (alloc_object_node),
+ build_address_of (alloc_node),
tree_cons (NULL_TREE, build_class_ref (type),
build_tree_list (NULL_TREE,
size_in_bytes (type))),
@@ -1849,9 +1865,12 @@ build_invokevirtual (dtable, method)
= build_pointer_type (nativecode_ptr_type_node);
tree method_index = convert (sizetype, DECL_VINDEX (method));
- /* Add one to skip "class" field of dtable, and one to skip unused
- vtable entry (for C++ compatibility). */
- method_index = size_binop (PLUS_EXPR, method_index, size_int (2));
+ if (TARGET_VTABLE_USES_DESCRIPTORS)
+ /* Add one to skip bogus descriptor for class and GC descriptor. */
+ method_index = size_binop (PLUS_EXPR, method_index, size_int (1));
+ else
+ /* Add 1 to skip "class" field of dtable, and 1 to skip GC descriptor. */
+ method_index = size_binop (PLUS_EXPR, method_index, size_int (2));
method_index = size_binop (MULT_EXPR, method_index,
TYPE_SIZE_UNIT (nativecode_ptr_ptr_type_node));