This is the mail archive of the
mailing list for the GCC project.
Re: Type safe vector API
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Nathan Sidwell <nathan at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Ben Elliston <bje at au dot ibm dot com>
- Date: Fri, 25 Jun 2004 00:19:24 -0700
- Subject: Re: Type safe vector API
- Organization: CodeSourcery, LLC
- References: <40D980E9.firstname.lastname@example.org>
Nathan Sidwell wrote:
Here's a patch which implements a type safe vector API, and a separate
which applies it to the CLASSTYPE_VBASECLASSES.
The basic idea is that you define a vector of pointers with
and a vector of objects with
these produce a structure declaration and a set of inline functions to
manipulate the vector.
You define a pointer to vector object with
and away you go. You have to deal with pointers to vectors, as
the implementation uses the trailing array hack. There is an API
call to allow you to have a structure ending with a vector member
(something that would be useful for a BINFO or TEMPLATE_ARG_VEC).
I couldn't measure time or size difference with this patch, as I
didn't have a testcase with significant virtual bases.
I've been waiting to see if someone else would comment.
To me, this looks fine. I'm a little nervous about the way in which
you're using the API for CLASSTYPE_VBASECLASSES in that it looks like
you're conservatively estimating the size of the vector, so it might not
actually be a win over the TREE_LIST thing we have now. As you say,
however, this is a tiny amount of memory one way or the other.
You need comments on some of the functions; for example, macro_input.
If nobody objects in another 24 hours, please go ahead and check this
in. Hopefully the tree-ssa folks can make use of this for their
purposes as well.