This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[binfo] Change base access vector
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 23 Jul 2004 19:57:23 +0100
- Subject: [binfo] Change base access vector
- Organization: Codesourcery LLC
Mark,
this patch changes the vector of base accesses to be a VEC(tree) too.
It is not appropriate to have these held with the vector of base binfos
as this one can be shared by derived classes, whereas the base binfo
vector is unique.
This will have a small memory saving of 12bytes per class.
booted & tested on i686-pc-linux-gnu, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2004-07-23 Nathan Sidwell <nathan@codesourcery.com>
* tree.h (BINFO_BASE_ACCESSES): Accesses are a VEC(tree).
(BINFO_BASE_ACCESS): Adjust.
(BINFO_BASE_ACCESS_APPEND): New.
(struct tree_binfo): Make base_accesses a VEC(tree) pointer.
* dbxout.c (dbxout_type): Adjust binfo access accessing.
* dwarf2out.c (gen_member_die): Likewise.
* tree-dump.c (deque_and_dump): Likewise.
2004-07-23 Nathan Sidwell <nathan@codesourcery.com>
* decl.c (xref_basetypes): Adjust base access vector creation.
* rtti.c (get_pseudo_ti_init, get_pseudo_ti_desc): Adjust base
access accesses.
* search.c (dynamic_cast_base_recurse, dfs_access_in_type): Likewise.
Index: dbxout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dbxout.c,v
retrieving revision 1.192
diff -c -3 -p -r1.192 dbxout.c
*** dbxout.c 20 Jul 2004 15:14:14 -0000 1.192
--- dbxout.c 23 Jul 2004 12:46:31 -0000
*************** dbxout_type (tree type, int full)
*** 1684,1689 ****
--- 1684,1690 ----
{
int i;
tree child;
+ VEC (tree) *accesses = BINFO_BASE_ACCESSES (binfo);
if (use_gnu_debug_info_extensions)
{
*************** dbxout_type (tree type, int full)
*** 1696,1703 ****
}
for (i = 0; BINFO_BASE_ITERATE (binfo, i, child); i++)
{
! tree access = (BINFO_BASE_ACCESSES (binfo)
! ? BINFO_BASE_ACCESS (binfo, i)
: access_public_node);
if (use_gnu_debug_info_extensions)
--- 1697,1703 ----
}
for (i = 0; BINFO_BASE_ITERATE (binfo, i, child); i++)
{
! tree access = (accesses ? VEC_index (tree, accesses, i)
: access_public_node);
if (use_gnu_debug_info_extensions)
Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.536
diff -c -3 -p -r1.536 dwarf2out.c
*** dwarf2out.c 23 Jul 2004 04:35:12 -0000 1.536
--- dwarf2out.c 23 Jul 2004 12:46:57 -0000
*************** gen_member_die (tree type, dw_die_ref co
*** 11897,11909 ****
/* First output info about the base classes. */
if (binfo)
{
! tree accesses = BINFO_BASE_ACCESSES (binfo);
int i;
tree base;
for (i = 0; BINFO_BASE_ITERATE (binfo, i, base); i++)
gen_inheritance_die (base,
! (accesses ? TREE_VEC_ELT (accesses, i)
: access_public_node), context_die);
}
--- 11897,11909 ----
/* First output info about the base classes. */
if (binfo)
{
! VEC (tree) *accesses = BINFO_BASE_ACCESSES (binfo);
int i;
tree base;
for (i = 0; BINFO_BASE_ITERATE (binfo, i, base); i++)
gen_inheritance_die (base,
! (accesses ? VEC_index (tree, accesses, i)
: access_public_node), context_die);
}
Index: tree-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-dump.c,v
retrieving revision 1.28
diff -c -3 -p -r1.28 tree-dump.c
*** tree-dump.c 20 Jul 2004 12:24:57 -0000 1.28
--- tree-dump.c 23 Jul 2004 12:46:59 -0000
*************** dequeue_and_dump (dump_info_p di)
*** 252,258 ****
{
unsigned ix;
tree base;
! tree accesses = BINFO_BASE_ACCESSES (t);
dump_child ("type", BINFO_TYPE (t));
--- 252,258 ----
{
unsigned ix;
tree base;
! VEC (tree) *accesses = BINFO_BASE_ACCESSES (t);
dump_child ("type", BINFO_TYPE (t));
*************** dequeue_and_dump (dump_info_p di)
*** 262,268 ****
dump_int (di, "bases", BINFO_N_BASE_BINFOS (t));
for (ix = 0; BINFO_BASE_ITERATE (t, ix, base); ix++)
{
! tree access = (accesses ? TREE_VEC_ELT (accesses, ix)
: access_public_node);
const char *string = NULL;
--- 262,268 ----
dump_int (di, "bases", BINFO_N_BASE_BINFOS (t));
for (ix = 0; BINFO_BASE_ITERATE (t, ix, base); ix++)
{
! tree access = (accesses ? VEC_index (tree, accesses, ix)
: access_public_node);
const char *string = NULL;
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.569
diff -c -3 -p -r1.569 tree.h
*** tree.h 22 Jul 2004 16:39:49 -0000 1.569
--- tree.h 23 Jul 2004 12:47:09 -0000
*************** struct tree_type GTY(())
*** 1671,1677 ****
access_public_node, access_protected_node or access_private_node.
If this array is not present, public access is implied. */
#define BINFO_BASE_ACCESSES(NODE) (TREE_BINFO_CHECK(NODE)->binfo.base_accesses)
! #define BINFO_BASE_ACCESS(NODE,N) TREE_VEC_ELT (BINFO_BASE_ACCESSES(NODE), (N))
/* The index in the VTT where this subobject's sub-VTT can be found.
NULL_TREE if there is no sub-VTT. */
--- 1671,1681 ----
access_public_node, access_protected_node or access_private_node.
If this array is not present, public access is implied. */
#define BINFO_BASE_ACCESSES(NODE) (TREE_BINFO_CHECK(NODE)->binfo.base_accesses)
!
! #define BINFO_BASE_ACCESS(NODE,N) \
! VEC_index (tree, BINFO_BASE_ACCESSES (NODE), (N))
! #define BINFO_BASE_ACCESS_APPEND(NODE,T) \
! VEC_quick_push (tree, BINFO_BASE_ACCESSES (NODE), (T))
/* The index in the VTT where this subobject's sub-VTT can be found.
NULL_TREE if there is no sub-VTT. */
*************** struct tree_binfo GTY (())
*** 1701,1707 ****
tree vtable;
tree virtuals;
tree vptr_field;
! tree base_accesses;
tree inheritance;
tree vtt_subvtt;
--- 1705,1711 ----
tree vtable;
tree virtuals;
tree vptr_field;
! VEC(tree) *base_accesses;
tree inheritance;
tree vtt_subvtt;
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1259
diff -c -3 -p -r1.1259 decl.c
*** cp/decl.c 21 Jul 2004 19:23:03 -0000 1.1259
--- cp/decl.c 23 Jul 2004 12:47:40 -0000
*************** xref_basetypes (tree ref, tree base_list
*** 9091,9097 ****
if (max_bases)
{
! BINFO_BASE_ACCESSES (binfo) = make_tree_vec (max_bases);
/* An aggregate cannot have baseclasses. */
CLASSTYPE_NON_AGGREGATE (ref) = 1;
--- 9091,9097 ----
if (max_bases)
{
! BINFO_BASE_ACCESSES (binfo) = VEC_alloc (tree, max_bases);
/* An aggregate cannot have baseclasses. */
CLASSTYPE_NON_AGGREGATE (ref) = 1;
*************** xref_basetypes (tree ref, tree base_list
*** 9181,9197 ****
if (!BINFO_INHERITANCE_CHAIN (base_binfo))
BINFO_INHERITANCE_CHAIN (base_binfo) = binfo;
- TREE_VEC_ELT (BINFO_BASE_ACCESSES (binfo),
- BINFO_N_BASE_BINFOS (binfo)) = access;
BINFO_BASE_APPEND (binfo, base_binfo);
}
- if (max_bases)
- /* If any bases were invalid, we will have allocated too many
- slots. */
- TREE_VEC_LENGTH (BINFO_BASE_ACCESSES (binfo))
- = BINFO_N_BASE_BINFOS (binfo);
-
/* Unmark all the types. */
for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
CLEAR_CLASSTYPE_MARKED (BINFO_TYPE (base_binfo));
--- 9181,9190 ----
if (!BINFO_INHERITANCE_CHAIN (base_binfo))
BINFO_INHERITANCE_CHAIN (base_binfo) = binfo;
BINFO_BASE_APPEND (binfo, base_binfo);
+ BINFO_BASE_ACCESS_APPEND (binfo, access);
}
/* Unmark all the types. */
for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
CLEAR_CLASSTYPE_MARKED (BINFO_TYPE (base_binfo));
Index: cp/rtti.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/rtti.c,v
retrieving revision 1.190
diff -c -3 -p -r1.190 rtti.c
*** cp/rtti.c 20 Jul 2004 12:25:30 -0000 1.190
--- cp/rtti.c 23 Jul 2004 12:47:43 -0000
*************** get_pseudo_ti_init (tree type, tree var_
*** 1043,1049 ****
int hint = class_hint_flags (type);
tree binfo = TYPE_BINFO (type);
int nbases = BINFO_N_BASE_BINFOS (binfo);
! tree base_accesses = BINFO_BASE_ACCESSES (binfo);
tree base_inits = NULL_TREE;
int ix;
--- 1043,1049 ----
int hint = class_hint_flags (type);
tree binfo = TYPE_BINFO (type);
int nbases = BINFO_N_BASE_BINFOS (binfo);
! VEC (tree) *base_accesses = BINFO_BASE_ACCESSES (binfo);
tree base_inits = NULL_TREE;
int ix;
*************** get_pseudo_ti_init (tree type, tree var_
*** 1056,1062 ****
tree tinfo;
tree offset;
! if (TREE_VEC_ELT (base_accesses, ix) == access_public_node)
flags |= 2;
tinfo = get_tinfo_ptr (BINFO_TYPE (base_binfo));
if (BINFO_VIRTUAL_P (base_binfo))
--- 1056,1062 ----
tree tinfo;
tree offset;
! if (VEC_index (tree, base_accesses, ix) == access_public_node)
flags |= 2;
tinfo = get_tinfo_ptr (BINFO_TYPE (base_binfo));
if (BINFO_VIRTUAL_P (base_binfo))
*************** get_pseudo_ti_desc (tree type)
*** 1190,1201 ****
else
{
tree binfo = TYPE_BINFO (type);
! tree base_accesses = BINFO_BASE_ACCESSES (binfo);
tree base_binfo = BINFO_BASE_BINFO (binfo, 0);
int num_bases = BINFO_N_BASE_BINFOS (binfo);
if (num_bases == 1
! && TREE_VEC_ELT (base_accesses, 0) == access_public_node
&& !BINFO_VIRTUAL_P (base_binfo)
&& integer_zerop (BINFO_OFFSET (base_binfo)))
/* single non-virtual public. */
--- 1190,1201 ----
else
{
tree binfo = TYPE_BINFO (type);
! VEC (tree) *base_accesses = BINFO_BASE_ACCESSES (binfo);
tree base_binfo = BINFO_BASE_BINFO (binfo, 0);
int num_bases = BINFO_N_BASE_BINFOS (binfo);
if (num_bases == 1
! && VEC_index (tree, base_accesses, 0) == access_public_node
&& !BINFO_VIRTUAL_P (base_binfo)
&& integer_zerop (BINFO_OFFSET (base_binfo)))
/* single non-virtual public. */
Index: cp/search.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/search.c,v
retrieving revision 1.306
diff -c -3 -p -r1.306 search.c
*** cp/search.c 23 Jul 2004 08:53:34 -0000 1.306
--- cp/search.c 23 Jul 2004 12:47:48 -0000
*************** static int
*** 287,293 ****
dynamic_cast_base_recurse (tree subtype, tree binfo, bool is_via_virtual,
tree *offset_ptr)
{
! tree accesses;
tree base_binfo;
int i;
int worst = -2;
--- 287,293 ----
dynamic_cast_base_recurse (tree subtype, tree binfo, bool is_via_virtual,
tree *offset_ptr)
{
! VEC (tree) *accesses;
tree base_binfo;
int i;
int worst = -2;
*************** dynamic_cast_base_recurse (tree subtype,
*** 306,312 ****
accesses = BINFO_BASE_ACCESSES (binfo);
for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
! tree base_access = TREE_VEC_ELT (accesses, i);
int rval;
if (base_access != access_public_node)
--- 306,312 ----
accesses = BINFO_BASE_ACCESSES (binfo);
for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
! tree base_access = VEC_index (tree, accesses, i);
int rval;
if (base_access != access_public_node)
*************** dfs_access_in_type (tree binfo, void *da
*** 625,638 ****
if (!access)
{
int i;
! tree base_binfo, accesses;
/* Otherwise, scan our baseclasses, and pick the most favorable
access. */
accesses = BINFO_BASE_ACCESSES (binfo);
for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
! tree base_access = TREE_VEC_ELT (accesses, i);
access_kind base_access_now = BINFO_ACCESS (base_binfo);
if (base_access_now == ak_none || base_access_now == ak_private)
--- 625,639 ----
if (!access)
{
int i;
! tree base_binfo;
! VEC (tree) *accesses;
/* Otherwise, scan our baseclasses, and pick the most favorable
access. */
accesses = BINFO_BASE_ACCESSES (binfo);
for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
! tree base_access = VEC_index (tree, accesses, i);
access_kind base_access_now = BINFO_ACCESS (base_binfo);
if (base_access_now == ak_none || base_access_now == ak_private)