diff options
author | Hans Boehm <Hans_Boehm@hp.com> | 2001-12-14 19:01:02 +0000 |
---|---|---|
committer | Hans Boehm <hboehm@gcc.gnu.org> | 2001-12-14 19:01:02 +0000 |
commit | eec875422f79e536fcde443bfe8c0a01b260deb2 (patch) | |
tree | def86bbb77acbb0823471cf90f10ce49709dfe9d /gcc/java/class.c | |
parent | abf80f8ff8818e104126e16df6bfcc97587a9cce (diff) | |
download | gcc-eec875422f79e536fcde443bfe8c0a01b260deb2.zip gcc-eec875422f79e536fcde443bfe8c0a01b260deb2.tar.gz gcc-eec875422f79e536fcde443bfe8c0a01b260deb2.tar.bz2 |
class.c (get_dispatch_table): Fix java vtable layout for TARGET_VTABLE_USES_DESCRIPTORS.
* 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.
From-SVN: r48004
Diffstat (limited to 'gcc/java/class.c')
-rw-r--r-- | gcc/java/class.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/gcc/java/class.c b/gcc/java/class.c index f328806..5695aba 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -694,6 +694,13 @@ add_method_1 (handle_class, access_flags, name, function_type) TREE_CHAIN (fndecl) = TYPE_METHODS (handle_class); TYPE_METHODS (handle_class) = fndecl; + /* Notice that this is a finalizer and update the class type + accordingly. This is used to optimize instance allocation. */ + if (name == finalize_identifier_node + && TREE_TYPE (function_type) == void_type_node + && TREE_VALUE (TYPE_ARG_TYPES (function_type)) == void_type_node) + HAS_FINALIZER_P (handle_class) = 1; + if (access_flags & ACC_PUBLIC) METHOD_PUBLIC (fndecl) = 1; if (access_flags & ACC_PROTECTED) METHOD_PROTECTED (fndecl) = 1; if (access_flags & ACC_PRIVATE) @@ -1374,6 +1381,7 @@ get_dispatch_table (type, this_class_addr) tree list = NULL_TREE; int nvirtuals = TREE_VEC_LENGTH (vtable); int arraysize; + tree gc_descr; for (i = nvirtuals; --i >= 0; ) { @@ -1415,15 +1423,17 @@ get_dispatch_table (type, this_class_addr) using the Boehm GC we sometimes stash a GC type descriptor there. We set the PURPOSE to NULL_TREE not to interfere (reset) the emitted byte count during the output to the assembly file. */ - for (j = 1; j < TARGET_VTABLE_USES_DESCRIPTORS; ++j) - list = tree_cons (NULL_TREE, null_pointer_node, list); - list = tree_cons (NULL_TREE, get_boehm_type_descriptor (type), list); - - for (j = 1; j < TARGET_VTABLE_USES_DESCRIPTORS; ++j) - list = tree_cons (NULL_TREE, null_pointer_node, list); + /* With TARGET_VTABLE_USES_DESCRIPTORS, we only add one extra + fake "function descriptor". It's first word is the is the class + pointer, and subsequent words (usually one) contain the GC descriptor. + In all other cases, we reserve two extra vtable slots. */ + gc_descr = get_boehm_type_descriptor (type); + list = tree_cons (NULL_TREE, gc_descr, list); + for (j = 1; j < TARGET_VTABLE_USES_DESCRIPTORS-1; ++j) + list = tree_cons (NULL_TREE, gc_descr, list); list = tree_cons (integer_zero_node, this_class_addr, list); - arraysize = nvirtuals + 2; + arraysize = (TARGET_VTABLE_USES_DESCRIPTORS? nvirtuals + 1 : nvirtuals + 2); if (TARGET_VTABLE_USES_DESCRIPTORS) arraysize *= TARGET_VTABLE_USES_DESCRIPTORS; return build (CONSTRUCTOR, |