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: Richard Henderson <rth at redhat dot com>
- To: David Malcolm <dmalcolm 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 13:31:59 -0700
- 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>
> /* 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.
The G structure contains all of the data that you'd actually want to put into
the "universe".
That said, I'd really like to avoid ultra-macroization as with
> +#define probability_cutoff \
> + universe.tracer_c->x_probability_cutoff
> +#define branch_ratio_cutoff \
> + universe.tracer_c->x_branch_ratio_cutoff
> +#define bb_seen \
> + universe.tracer_c->x_bb_seen
if we can avoid it.
I think we need more weigh in from other maintainers on this, rather than
iterating a 5th time today...
r~