This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 6/6] move many members of target_globals out of gc memory
- From: tsaunders at mozilla dot com
- To: gcc-patches at gcc dot gnu dot org
- Cc: Trevor Saunders <tsaunders at mozilla dot com>
- Date: Tue, 29 Apr 2014 07:08:36 -0400
- Subject: [PATCH 6/6] move many members of target_globals out of gc memory
- Authentication-results: sourceware.org; auth=none
- References: <1398769716-8629-1-git-send-email-tsaunders at mozilla dot com>
From: Trevor Saunders <tsaunders@mozilla.com>
Hi,
add a user of gc finalizers.
bootstrapped + regtested on x86_64-unknown-linux-gnu, ok?
Trev
gcc/ChangeLog:
* target-globals.c (target_globals::~target_globals): new destructor.
(target_globals_extra): Move out of save_target_globals.
(save_target_globals): Adjust.
* target-globals.h (target_globals): Mark members that don't point
into gc memory GTY((skip)).
---
gcc/target-globals.c | 56 +++++++++++++++++++++++++++++++++-------------------
gcc/target-globals.h | 16 ++++++++-------
2 files changed, 45 insertions(+), 27 deletions(-)
diff --git a/gcc/target-globals.c b/gcc/target-globals.c
index 5f1a208..8a64d3c 100644
--- a/gcc/target-globals.c
+++ b/gcc/target-globals.c
@@ -64,36 +64,52 @@ struct target_globals default_target_globals = {
&default_target_lower_subreg
};
+target_globals:: ~target_globals ()
+{
+ /* default_target_globals is weird and statically allocated, so don't try and
+ free its members. */
+ if (this == &default_target_globals)
+ return;
+
+ free (regs);
+ free (hard_regs);
+ free (reload);
+ free (expmed);
+ free (ira);
+ free (ira_int);
+ free (lra_int);
+}
+
+struct target_globals_extra
+{
+ struct target_globals g;
+ struct target_flag_state flag_state;
+ struct target_optabs optabs;
+ struct target_cfgloop cfgloop;
+ struct target_builtins builtins;
+ struct target_gcse gcse;
+ struct target_bb_reorder bb_reorder;
+ struct target_lower_subreg lower_subreg;
+};
+
struct target_globals *
save_target_globals (void)
{
struct target_globals *g;
- struct target_globals_extra {
- struct target_globals g;
- struct target_flag_state flag_state;
- struct target_optabs optabs;
- struct target_cfgloop cfgloop;
- struct target_builtins builtins;
- struct target_gcse gcse;
- struct target_bb_reorder bb_reorder;
- struct target_lower_subreg lower_subreg;
- } *p;
- p = (struct target_globals_extra *)
- ggc_internal_cleared_alloc (sizeof (struct target_globals_extra));
+ target_globals_extra *p = ggc_cleared_alloc<target_globals_extra> ();
g = (struct target_globals *) p;
g->flag_state = &p->flag_state;
- g->regs = ggc_internal_cleared_alloc (sizeof (struct target_regs));
+ g->regs = XCNEW (target_regs);
g->rtl = ggc_cleared_alloc<target_rtl> ();
- g->hard_regs
- = ggc_internal_cleared_alloc (sizeof (struct target_hard_regs));
- g->reload = ggc_internal_cleared_alloc (sizeof (struct target_reload));
- g->expmed = ggc_internal_cleared_alloc (sizeof (struct target_expmed));
+ g->hard_regs = XCNEW (target_hard_regs);
+ g->reload = XCNEW (target_reload);
+ g->expmed = XCNEW (target_expmed);
g->optabs = &p->optabs;
g->libfuncs = ggc_cleared_alloc<target_libfuncs> ();
g->cfgloop = &p->cfgloop;
- g->ira = ggc_internal_cleared_alloc (sizeof (struct target_ira));
- g->ira_int = ggc_internal_cleared_alloc (sizeof (struct target_ira_int));
- g->lra_int = ggc_internal_cleared_alloc (sizeof (struct target_lra_int));
+ g->ira = XCNEW (target_ira);
+ g->ira_int = XCNEW (target_ira_int);
+ g->lra_int = XCNEW (target_lra_int);
g->builtins = &p->builtins;
g->gcse = &p->gcse;
g->bb_reorder = &p->bb_reorder;
diff --git a/gcc/target-globals.h b/gcc/target-globals.h
index e848a01..82fd4f2 100644
--- a/gcc/target-globals.h
+++ b/gcc/target-globals.h
@@ -40,18 +40,20 @@ extern struct target_lower_subreg *this_target_lower_subreg;
#endif
struct GTY(()) target_globals {
+ ~target_globals ();
+
struct target_flag_state *GTY((skip)) flag_state;
- void *GTY((atomic)) regs;
+ void *GTY((skip)) regs;
struct target_rtl *rtl;
- void *GTY((atomic)) hard_regs;
- void *GTY((atomic)) reload;
- void *GTY((atomic)) expmed;
+ void *GTY((skip)) hard_regs;
+ void *GTY((skip)) reload;
+ void *GTY((skip)) expmed;
struct target_optabs *GTY((skip)) optabs;
struct target_libfuncs *libfuncs;
struct target_cfgloop *GTY((skip)) cfgloop;
- void *GTY((atomic)) ira;
- void *GTY((atomic)) ira_int;
- void *GTY((atomic)) lra_int;
+ void *GTY((skip)) ira;
+ void *GTY((skip)) ira_int;
+ void *GTY((skip)) lra_int;
struct target_builtins *GTY((skip)) builtins;
struct target_gcse *GTY((skip)) gcse;
struct target_bb_reorder *GTY((skip)) bb_reorder;
--
2.0.0.rc0