This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Remove global state from gcc/tracer.c
- From: David Malcolm <dmalcolm at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Jakub Jelinek <jakub at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 23 May 2013 16:51:35 -0400
- Subject: Re: Remove global state from gcc/tracer.c
- References: <1369269945 dot 26167 dot 50 dot camel at surprise> <20130523051453 dot GN1377 at tucnak dot redhat dot com> <1369306601 dot 26167 dot 70 dot camel at surprise> <1369324748 dot 21561 dot 35 dot camel at surprise> <1369339315 dot 21561 dot 42 dot camel at surprise> <519E7CBF dot 1030705 at redhat dot com>
On Thu, 2013-05-23 at 13:31 -0700, Richard Henderson wrote:
> > /* The Ith entry is the number of objects on a page or order I. */
> >
> > -static unsigned objects_per_page_table[NUM_ORDERS];
> > +DEFINE_STATIC_STATE_ARRAY(unsigned, objects_per_page_table, NUM_ORDERS)
> >
> > /* The Ith entry is the size of an object on a page of order I. */
> >
> > -static size_t object_size_table[NUM_ORDERS];
> > +DEFINE_STATIC_STATE_ARRAY(size_t, object_size_table, NUM_ORDERS)
> >
> > /* The Ith entry is a pair of numbers (mult, shift) such that
> > ((k * mult) >> shift) mod 2^32 == (k / OBJECT_SIZE(I)) mod 2^32,
> > for all k evenly divisible by OBJECT_SIZE(I). */
> >
> > -static struct
> > +struct inverse_table_def
> > {
> > size_t mult;
> > unsigned int shift;
> > -}
> > -inverse_table[NUM_ORDERS];
> > +};
> > +DEFINE_STATIC_STATE_ARRAY(inverse_table_def, inverse_table, NUM_ORDERS)
> >
> > /* A page_entry records the status of an allocation page. This
> > structure is dynamically sized to fit the bitmap in_use_p. */
> > @@ -343,7 +346,7 @@ struct free_object
> > #endif
> >
> > /* The rest of the global variables. */
> > -static struct globals
> > +struct globals
> > {
> > /* The Nth element in this array is a page with objects of size 2^N.
> > If there are any pages with free objects, they will be at the
> > @@ -457,7 +460,11 @@ static struct globals
> > /* The overhead for each of the allocation orders. */
> > unsigned long long total_overhead_per_order[NUM_ORDERS];
> > } stats;
> > -} G;
> > +};
> > +
> > +DEFINE_STATIC_STATE(globals, G)
>
> Be careful here. Note that all of the arrays that you convert are notionally
> static constants defining the bucket sizes for the algorithm, except we don't
> actually compute them at compile time. They would be true global data shared
> by all threads.
I know - but when you have a big hammer, sometimes it's easier just to
hit all of the nails, rather than just the ones you need to :)
[...]