diff options
author | Richard Henderson <rth@redhat.com> | 2001-09-21 09:58:22 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2001-09-21 09:58:22 -0700 |
commit | 6723181663a87a735bdfdf2e16a6bd41dbc30be1 (patch) | |
tree | 746cb9ad4b9e1b8562a39be3d23d3c85abfdac19 /gcc/java | |
parent | 2e3b2d2c0791d979571fd33155b62e66ea7fe27c (diff) | |
download | gcc-6723181663a87a735bdfdf2e16a6bd41dbc30be1.zip gcc-6723181663a87a735bdfdf2e16a6bd41dbc30be1.tar.gz gcc-6723181663a87a735bdfdf2e16a6bd41dbc30be1.tar.bz2 |
tree.def (FDESC_EXPR): New.
gcc/
* tree.def (FDESC_EXPR): New.
* expr.c (expand_expr): Handle it.
* varasm.c (initializer_constant_valid_p): Likewise.
(output_constant): Likewise.
* defaults.h (TARGET_VTABLE_USES_DESCRIPTORS): New.
* config/ia64/ia64.h (TARGET_VTABLE_USES_DESCRIPTORS): New.
(ASM_OUTPUT_FDESC): New.
* doc/tm.texi: Document the new macros.
gcc/cp/
* class.c (set_vindex): Mind TARGET_VTABLE_USES_DESCRIPTORS.
(build_vtbl_initializer): Likewise.
(build_vfn_ref): New.
* cp-tree.h: Declare it.
* call.c (build_over_call): Use it.
* decl2.c (mark_vtable_entries): Mark FDESC_EXPR.
* typeck.c (get_member_function_from_ptrfunc): Mind descriptors.
gcc/java/
* class.c (get_dispatch_table): Handle function descriptors.
(build_dtable_decl): Likewise.
* expr.c (build_invokevirtual): Likewise.
gcc/testsuite/
* g++.old-deja/g++.abi/ptrmem.C: Update for ia64 c++ abi.
* g++.old-deja/g++.abi/vtable2.C: Likewise.
From-SVN: r45733
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/java/class.c | 79 | ||||
-rw-r--r-- | gcc/java/expr.c | 11 |
3 files changed, 81 insertions, 15 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index a2ba2a6..fcfb7eb 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,9 @@ +2001-09-21 Richard Henderson <rth@redhat.com> + + * class.c (get_dispatch_table): Handle function descriptors. + (build_dtable_decl): Likewise. + * expr.c (build_invokevirtual): Likewise. + 2001-09-19 Alexandre Petit-Bianco <apbianco@redhat.com> * parse.h: (WFL_STRIP_BRACKET): Re-written using diff --git a/gcc/java/class.c b/gcc/java/class.c index 2e6eadf..260db75 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -1372,9 +1372,11 @@ get_dispatch_table (type, this_class_addr) { int abstract_p = CLASS_ABSTRACT (TYPE_NAME (type)); tree vtable = get_dispatch_vector (type); - int i; + int i, j; tree list = NULL_TREE; int nvirtuals = TREE_VEC_LENGTH (vtable); + int arraysize; + for (i = nvirtuals; --i >= 0; ) { tree method = TREE_VEC_ELT (vtable, i); @@ -1383,27 +1385,52 @@ get_dispatch_table (type, this_class_addr) if (! abstract_p) warning_with_decl (method, "abstract method in non-abstract class"); - method = null_pointer_node; + + if (TARGET_VTABLE_USES_DESCRIPTORS) + for (j = 0; j < TARGET_VTABLE_USES_DESCRIPTORS; ++j) + list = tree_cons (NULL_TREE, null_pointer_node, list); + else + list = tree_cons (NULL_TREE, null_pointer_node, list); } else { if (!DECL_RTL_SET_P (method)) make_decl_rtl (method, NULL); - method = build1 (ADDR_EXPR, nativecode_ptr_type_node, method); + + if (TARGET_VTABLE_USES_DESCRIPTORS) + for (j = 0; j < TARGET_VTABLE_USES_DESCRIPTORS; ++j) + { + tree fdesc = build (FDESC_EXPR, nativecode_ptr_type_node, + method, build_int_2 (j, 0)); + TREE_CONSTANT (fdesc) = 1; + list = tree_cons (NULL_TREE, fdesc, list); + } + else + list = tree_cons (NULL_TREE, + build1 (ADDR_EXPR, nativecode_ptr_type_node, + method), + list); } - list = tree_cons (NULL_TREE /*DECL_VINDEX (method) + 2*/, - method, list); } + /* Dummy entry for compatibility with G++ -fvtable-thunks. When 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. */ - 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); + 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); list = tree_cons (integer_zero_node, this_class_addr, list); - return build (CONSTRUCTOR, build_prim_array_type (nativecode_ptr_type_node, - nvirtuals + 2), - NULL_TREE, list); + + arraysize = nvirtuals + 2; + if (TARGET_VTABLE_USES_DESCRIPTORS) + arraysize *= TARGET_VTABLE_USES_DESCRIPTORS; + return build (CONSTRUCTOR, + build_prim_array_type (nativecode_ptr_type_node, arraysize), + NULL_TREE, list); } void @@ -1733,13 +1760,37 @@ build_dtable_decl (type) TYPE. */ if (current_class == type) { - tree dummy = NULL_TREE, aomt, n; + tree dummy = NULL_TREE; + int n; dtype = make_node (RECORD_TYPE); + PUSH_FIELD (dtype, dummy, "class", class_ptr_type); - n = build_int_2 (TREE_VEC_LENGTH (get_dispatch_vector (type)), 0); - aomt = build_array_type (ptr_type_node, build_index_type (n)); - PUSH_FIELD (dtype, dummy, "methods", aomt); + for (n = 1; n < TARGET_VTABLE_USES_DESCRIPTORS; ++n) + { + tree tmp_field = build_decl (FIELD_DECL, NULL_TREE, ptr_type_node); + TREE_CHAIN (dummy) = tmp_field; + DECL_CONTEXT (tmp_field) = dtype; + DECL_ARTIFICIAL (tmp_field) = 1; + dummy = tmp_field; + } + + PUSH_FIELD (dtype, dummy, "gc_descr", ptr_type_node); + for (n = 1; n < TARGET_VTABLE_USES_DESCRIPTORS; ++n) + { + tree tmp_field = build_decl (FIELD_DECL, NULL_TREE, ptr_type_node); + TREE_CHAIN (dummy) = tmp_field; + DECL_CONTEXT (tmp_field) = dtype; + DECL_ARTIFICIAL (tmp_field) = 1; + dummy = tmp_field; + } + + n = TREE_VEC_LENGTH (get_dispatch_vector (type)); + if (TARGET_VTABLE_USES_DESCRIPTORS) + n *= TARGET_VTABLE_USES_DESCRIPTORS; + + PUSH_FIELD (dtype, dummy, "methods", + build_prim_array_type (nativecode_ptr_type_node, n)); layout_type (dtype); } else diff --git a/gcc/java/expr.c b/gcc/java/expr.c index ff0a327..5481289 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -1845,9 +1845,18 @@ build_invokevirtual (dtable, method) 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)); + + if (TARGET_VTABLE_USES_DESCRIPTORS) + method_index = size_binop (MULT_EXPR, method_index, + size_int (TARGET_VTABLE_USES_DESCRIPTORS)); + func = fold (build (PLUS_EXPR, nativecode_ptr_ptr_type_node, dtable, convert (nativecode_ptr_ptr_type_node, method_index))); - func = build1 (INDIRECT_REF, nativecode_ptr_type_node, func); + + if (TARGET_VTABLE_USES_DESCRIPTORS) + func = build1 (NOP_EXPR, nativecode_ptr_type_node, func); + else + func = build1 (INDIRECT_REF, nativecode_ptr_type_node, func); return func; } |