diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-03-22 17:13:09 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-03-22 17:13:09 +0000 |
commit | f359257fae481ceaf3bb32cbd2c52f6fe45bcb5a (patch) | |
tree | 5b3bbbdb8fe402b5bc8d6d12ae7f7da6f784d0d0 | |
parent | 8baac3168953aa0e8cbdb942eb12e8fca8802fc6 (diff) | |
download | gcc-f359257fae481ceaf3bb32cbd2c52f6fe45bcb5a.tar.gz |
2008-03-22 Basile Starynkevitch <basile@starynkevitch.net>
* gcc/basilys.c: (basilysgc_add_strbuf_raw) when growing young strbuf,
call basilysgc_reserve and basilys_allocatereserved to avoid
growing a buffer which has just been promoted to old by the zone
reallocation. (basilysgc_add_strbuf_raw) use a basilys frame.
(basilysgc_put_mapobjects, basilysgc_remove_mapobjects)
(basilysgc_put_mapstrings, basilysgc_remove_mapstrings)
(basilysgc_raw_put_mappointers, basilysgc_raw_remove_mappointers)
call basilysgc_reserve and basilys_allocatereserved likewise.
* gcc/basilys.h: (basilysgc_reserve, basilys_allocatereserved) new functions.
added frameloc when ENABLE_CHECKING in basilys frames.
* gcc/melt/warm-basilys.bysl: added (empty) support for framloe when
ENABLE_CHECKING in generated basilys frames.
* gcc/Makefile.in: remove T_CFLAGS from MELT_CFLAGS.
* contrib/cold-basilys.lisp: added empty framloc support when ENABLE_CHECKING in basilys frame.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@133450 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | contrib/ChangeLog.melt | 3 | ||||
-rw-r--r-- | contrib/cold-basilys.lisp | 6 | ||||
-rw-r--r-- | gcc/ChangeLog.melt | 18 | ||||
-rw-r--r-- | gcc/Makefile.in | 7 | ||||
-rw-r--r-- | gcc/basilys.c | 274 | ||||
-rw-r--r-- | gcc/basilys.h | 80 | ||||
-rw-r--r-- | gcc/melt/warm-basilys.bysl | 12 |
7 files changed, 306 insertions, 94 deletions
diff --git a/contrib/ChangeLog.melt b/contrib/ChangeLog.melt index fa46a65c551..4c26894757e 100644 --- a/contrib/ChangeLog.melt +++ b/contrib/ChangeLog.melt @@ -1,4 +1,7 @@ +2008-03-22 Basile Starynkevitch <basile@starynkevitch.net> + * cold-basilys.lisp: added empty framloc support when ENABLE_CHECKING in basilys frame. + 2008-03-20 Basile Starynkevitch <basile@starynkevitch.net> * cold-basilys.lisp: removed invocation if indent & basilys-gcc programs. (output_ccode) added newline emission after outputting preprocessor directives. diff --git a/contrib/cold-basilys.lisp b/contrib/cold-basilys.lisp index 18402f452d1..eab663cd505 100644 --- a/contrib/cold-basilys.lisp +++ b/contrib/cold-basilys.lisp @@ -3708,6 +3708,9 @@ nil) (format str "#endif~%") (format str " struct {~%") (format str " unsigned nbvar;~%") + (format str "#if ENABLE_CHECKING~%") + (format str " const struct framloc_basilys_st* floc;~%") + (format str "#endif~%") (format str " struct basilysclosure_st* clos;~%") (format str " struct excepth_basilys_st* exh;~%") (format str " struct callframe_basilys_st* prev;~%") @@ -3717,6 +3720,9 @@ nil) (format str " long _spare_;") (format str " } curfram__ = { /*nbvar*/~d,~%" nbptr) (format str " (struct basilysclosure_st*)0,~%") + (format str "#if ENABLE_CHECKING~%") + (format str " (struct framloc_basilys_st*)0,~%") + (format str "#endif~%") (format str " (struct excepth_basilys_st*)0,~%") (format str " (struct callframe_basilys_st*)0, ~%") (progn diff --git a/gcc/ChangeLog.melt b/gcc/ChangeLog.melt index 8b23ef66b85..fdf113b52e6 100644 --- a/gcc/ChangeLog.melt +++ b/gcc/ChangeLog.melt @@ -1,4 +1,22 @@ +2008-03-22 Basile Starynkevitch <basile@starynkevitch.net> + * basilys.c: (basilysgc_add_strbuf_raw) when growing young strbuf, + call basilysgc_reserve and basilys_allocatereserved to avoid + growing a buffer which has just been promoted to old by the zone + reallocation. (basilysgc_add_strbuf_raw) use a basilys frame. + (basilysgc_put_mapobjects, basilysgc_remove_mapobjects) + (basilysgc_put_mapstrings, basilysgc_remove_mapstrings) + (basilysgc_raw_put_mappointers, basilysgc_raw_remove_mappointers) + call basilysgc_reserve and basilys_allocatereserved likewise. + + * basilys.h: (basilysgc_reserve, basilys_allocatereserved) new functions. + added frameloc when ENABLE_CHECKING in basilys frames. + + * melt/warm-basilys.bysl: added (empty) support for framloe when + ENABLE_CHECKING in generated basilys frames. + + * Makefile.in: remove T_CFLAGS from MELT_CFLAGS. + 2008-03-21 Basile Starynkevitch <basile@starynkevitch.net> * basilys.c: (basilysgc_read_file) added second argument locnam. (do_initial_command) uses basilys_secondargument_string. !!!!! A diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 16eb4d686d4..eb3ab10a69d 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -4550,9 +4550,10 @@ melt_build_include_dir= melt-private-build-include ## the C flags (without any gcc -I...stuff) to be included in -## compilation of MELT generated C code thru the melt-cc-script -## do not put $(INTERNAL_CFLAGS) $(COVERAGE_FLAGS) $(WARN_CFLAGS) there! -MELT_CFLAGS= $(X_CFLAGS) $(T_CFLAGS) $(CFLAGS) $(XCFLAGS) $(INTERNAL_CFLAGS) @DEFS@ +## compilation of MELT generated C code thru the melt-cc-script do not +## put $(INTERNAL_CFLAGS) $(COVERAGE_FLAGS) $(WARN_CFLAGS) $(T_CFLAGS) +## there! +MELT_CFLAGS= $(X_CFLAGS) $(CFLAGS) $(XCFLAGS) $(INTERNAL_CFLAGS) @DEFS@ # we want to generate all the direct (non system) dependencies of run-basilys.h # the following should work if $(CC) is some recent version of GCC (probably >= 4.x) diff --git a/gcc/basilys.c b/gcc/basilys.c index 08e4c894d90..c4e2061731a 100644 --- a/gcc/basilys.c +++ b/gcc/basilys.c @@ -1580,10 +1580,25 @@ basilysgc_add_strbuf_raw (struct basilysstrbuf_st *strbuf_p, const char *str) if (newblen > BASILYS_MAXLEN) fatal_error ("strbuf overflow to %d bytes", newblen); /* the newly grown buffer is allocated in young memory if the - previous was young, or in old memory if it was already old */ + previous was young, or in old memory if it was already old; + but we have to deal with the rare case when the allocation + triggers a GC which migrate the strbuf from young to old */ if (basilys_is_young (buf_strbufv->bufzn)) { - newb = basilysgc_allocate (newblen + 1, 0); + /* bug to avoid: the strbuf was young, the allocation of + newb triggers a GC, and then the strbuf becomes old. we + cannot put newb inside it (this violate the GC invariant + of no unfollowed -on store list- old to young + pointers). So we reserve the required length to make sure + that the following newb allocation does not trigger a + GC */ + basilysgc_reserve (newblen + 10 * sizeof (void *)); + /* does the above reservation triggered a GC which moved buf_strbufv to old? */ + if (!basilys_is_young (buf_strbufv->bufzn)) + goto strbuf_in_old_memory; + gcc_assert (basilys_is_young (buf_strbufv)); + newb = basilys_allocatereserved (newblen + 1, 0); + gcc_assert (basilys_is_young (buf_strbufv)); memcpy (newb, buf_strbufv->bufzn + buf_strbufv->bufstart, siz); strcpy (newb + siz, str); memset (buf_strbufv->bufzn, 0, oldblen); @@ -1591,6 +1606,10 @@ basilysgc_add_strbuf_raw (struct basilysstrbuf_st *strbuf_p, const char *str) } else { + /* we may come here if the strbuf was young but became old + by the basilysgc_reserve call above */ + strbuf_in_old_memory: + gcc_assert (!basilys_is_young (buf_strbufv)); newb = ggc_alloc_cleared (newblen + 1); memcpy (newb, buf_strbufv->bufzn + buf_strbufv->bufstart, siz); strcpy (newb + siz, str); @@ -1870,31 +1889,40 @@ basilysgc_strbuf_add_indent (struct basilysstrbuf_st *strbuf_p, int depth, int linethresh) { int llln = 0; /* last line length */ - if (!strbuf_p || basilys_magic_discr ((void *) strbuf_p) != OBMAG_STRBUF) - return; + BASILYS_ENTERFRAME (2, NULL); + /* we need a frame, because we have more than one call to + basilysgc_add_strbuf_raw */ +#define strbv curfram__.varptr[0] +#define strbufv ((struct basilysstrbuf_st*)(strbv)) + if (!strbufv || basilys_magic_discr ((void *) strbufv) != OBMAG_STRBUF) + goto end; if (linethresh > 0 && linethresh < 40) linethresh = 40; /* compute the last line length llln */ { char *bs = 0, *be = 0, *nl = 0; - bs = strbuf_p->bufzn + strbuf_p->bufstart; - be = strbuf_p->bufzn + strbuf_p->bufend; + bs = strbufv->bufzn + strbufv->bufstart; + be = strbufv->bufzn + strbufv->bufend; for (nl = be - 1; nl > bs && *nl && *nl != '\n'; nl--); llln = be - nl; gcc_assert (llln >= 0); } if (linethresh > 0 && llln < linethresh) - basilysgc_add_strbuf_raw (strbuf_p, " "); + basilysgc_add_strbuf_raw (strbufv, " "); else { int nbsp = depth; static const char spaces32[] = " "; - basilysgc_add_strbuf_raw (strbuf_p, "\n"); + basilysgc_add_strbuf_raw (strbufv, "\n"); if (nbsp < 0) nbsp = 0; if (nbsp > 0 && nbsp % 32 != 0) - basilysgc_add_strbuf_raw (strbuf_p, spaces32 + (32 - nbsp % 32)); + basilysgc_add_strbuf_raw (strbufv, spaces32 + (32 - nbsp % 32)); } +end: + BASILYS_EXITFRAME (); +#undef strbufv +#undef strbv } @@ -2563,14 +2591,21 @@ basilysgc_put_mapobjects (basilysmapobjects_ptr_t goto end; if (!map_mapobjectv->entab) { + size_t lensiz = 0; len = basilys_primtab[1]; /* i.e. 3 */ + lensiz = len * sizeof (struct entryobjectsbasilys_st); if (basilys_is_young (mapobjectv)) - map_mapobjectv->entab = - basilysgc_allocate (len * - sizeof (struct entryobjectsbasilys_st), 0); + { + basilysgc_reserve (lensiz + 20); + if (!basilys_is_young (mapobjectv)) + goto alloc_old_smallmapobj; + map_mapobjectv->entab = basilys_allocatereserved (lensiz, 0); + } else - map_mapobjectv->entab = - ggc_alloc_cleared (len * sizeof (struct entryobjectsbasilys_st)); + { + alloc_old_smallmapobj: + map_mapobjectv->entab = ggc_alloc_cleared (lensiz); + } map_mapobjectv->lenix = 1; basilysgc_touch (map_mapobjectv); } @@ -2581,15 +2616,22 @@ basilysgc_put_mapobjects (basilysmapobjects_ptr_t { int ix, newcnt = 0; int newlen = basilys_primtab[map_mapobjectv->lenix + 1]; + size_t newlensiz = 0; struct entryobjectsbasilys_st *newtab = NULL; struct entryobjectsbasilys_st *oldtab = NULL; + newlensiz = newlen * sizeof (struct entryobjectsbasilys_st); if (basilys_is_young (map_mapobjectv->entab)) - newtab = - basilysgc_allocate (newlen * - sizeof (struct entryobjectsbasilys_st), 0); + { + basilysgc_reserve (newlensiz + 100); + if (!basilys_is_young (map_mapobjectv)) + goto alloc_old_mapobj; + newtab = basilys_allocatereserved (newlensiz, 0); + } else - newtab = - ggc_alloc_cleared (newlen * sizeof (struct entryobjectsbasilys_st)); + { + alloc_old_mapobj: + newtab = ggc_alloc_cleared (newlensiz); + }; oldtab = map_mapobjectv->entab; for (ix = 0; ix < len; ix++) { @@ -2673,19 +2715,28 @@ basilysgc_remove_mapobjects (basilysmapobjects_ptr_t cnt = map_mapobjectv->count; if (len >= 7 && cnt < len / 2 - 2) { - int newcnt = 0, newlen = 0, newlenix; + int newcnt = 0, newlen = 0, newlenix = 0; + size_t newlensiz = 0; struct entryobjectsbasilys_st *oldtab = NULL, *newtab = NULL; for (newlenix = map_mapobjectv->lenix; (newlen = basilys_primtab[newlenix]) > 2 * cnt + 3; newlenix--); if (newlen >= len) goto end; + newlensiz = newlen * sizeof (struct entryobjectsbasilys_st); if (basilys_is_young (map_mapobjectv->entab)) - newtab = - basilysgc_allocate (newlen * - sizeof (struct entryobjectsbasilys_st), 0); + { + /* reserve a zone; if a GC occurred, the mapobject & entab + could become old */ + basilysgc_reserve (newlensiz + 10 * sizeof (void *)); + if (!basilys_is_young (map_mapobjectv)) + goto alloc_old_entries; + newtab = basilys_allocatereserved (newlensiz, 0); + } else - newtab = - ggc_alloc_cleared (newlen * sizeof (struct entryobjectsbasilys_st)); + { + alloc_old_entries: + newtab = ggc_alloc_cleared (newlensiz); + } oldtab = map_mapobjectv->entab; for (ix = 0; ix < len; ix++) { @@ -2839,14 +2890,21 @@ basilysgc_put_mapstrings (struct basilysmapstrings_st attrdup = strcpy (xcalloc (atlen + 1, 1), attr); if (!map_mapstringv->entab) { + size_t lensiz = 0; len = basilys_primtab[1]; /* i.e. 3 */ + lensiz = len * sizeof (struct entrystringsbasilys_st); if (basilys_is_young (mapstringv)) - map_mapstringv->entab = - basilysgc_allocate (len * - sizeof (struct entrystringsbasilys_st), 0); + { + basilysgc_reserve (lensiz + 16 * sizeof (void *)); + if (!basilys_is_young (mapstringv)) + goto alloc_old_small_mapstring; + map_mapstringv->entab = basilys_allocatereserved (lensiz, 0); + } else - map_mapstringv->entab = - ggc_alloc_cleared (len * sizeof (struct entrystringsbasilys_st)); + { + alloc_old_small_mapstring: + map_mapstringv->entab = ggc_alloc_cleared (lensiz); + } map_mapstringv->lenix = 1; basilysgc_touch (map_mapstringv); } @@ -2859,13 +2917,19 @@ basilysgc_put_mapstrings (struct basilysmapstrings_st int newlen = basilys_primtab[map_mapstringv->lenix + 1]; struct entrystringsbasilys_st *oldtab = NULL; struct entrystringsbasilys_st *newtab = NULL; + size_t newlensiz = newlen * sizeof (struct entrystringsbasilys_st); if (basilys_is_young (mapstringv)) - newtab = - basilysgc_allocate (newlen * - sizeof (struct entrystringsbasilys_st), 0); + { + basilysgc_reserve (newlensiz + 10 * sizeof (void *)); + if (!basilys_is_young (mapstringv)) + goto alloc_old_mapstring; + newtab = basilys_allocatereserved (newlensiz, 0); + } else - newtab = - ggc_alloc_cleared (newlen * sizeof (struct entrystringsbasilys_st)); + { + alloc_old_mapstring: + newtab = ggc_alloc_cleared (newlensiz); + }; oldtab = map_mapstringv->entab; for (ix = 0; ix < len; ix++) { @@ -2981,19 +3045,26 @@ basilysgc_remove_mapstrings (struct basilysmapstrings_st * cnt = map_mapstringv->count; if (len > 7 && 2 * cnt + 2 < len) { - int newcnt = 0, newlen = 0, newlenix; + int newcnt = 0, newlen = 0, newlenix = 0; + size_t newlensiz = 0; struct entrystringsbasilys_st *oldtab = NULL, *newtab = NULL; for (newlenix = map_mapstringv->lenix; (newlen = basilys_primtab[newlenix]) > 2 * cnt + 3; newlenix--); if (newlen >= len) goto end; + newlensiz = newlen * sizeof (struct entrystringsbasilys_st); if (basilys_is_young (mapstringv)) - newtab = - basilysgc_allocate (newlen * - sizeof (struct entrystringsbasilys_st), 0); + { + basilysgc_reserve (newlensiz + 10 * sizeof (void *)); + if (!basilys_is_young (mapstringv)) + goto alloc_old_mapstring_newtab; + newtab = basilys_allocatereserved (newlensiz, 0); + } else - newtab = - ggc_alloc_cleared (newlen * sizeof (struct entrystringsbasilys_st)); + { + alloc_old_mapstring_newtab: + newtab = ggc_alloc_cleared (newlensiz); + } oldtab = map_mapstringv->entab; for (ix = 0; ix < len; ix++) { @@ -3027,6 +3098,10 @@ end: + + + + /* index of entry to get or add an attribute in an mappointer (or -1 on error) */ struct entrypointerbasilys_st { @@ -3144,6 +3219,7 @@ basilysgc_raw_put_mappointers (void *mappointer_p, const void *attr, basilys_ptr_t valu_p) { long ix = 0, len = 0, cnt = 0; + size_t lensiz = 0; BASILYS_ENTERFRAME (2, NULL); #define mappointerv curfram__.varptr[0] #define valuv curfram__.varptr[1] @@ -3154,13 +3230,20 @@ basilysgc_raw_put_mappointers (void *mappointer_p, if (!map_mappointerv->entab) { len = basilys_primtab[1]; /* i.e. 3 */ + lensiz = len * sizeof (struct entrypointerbasilys_st); if (basilys_is_young (mappointerv)) - map_mappointerv->entab = - basilysgc_allocate (len * - sizeof (struct entrypointerbasilys_st), 0); + { + basilysgc_reserve (lensiz + 10 * sizeof (void *)); + if (!basilys_is_young (mappointerv)) + goto alloc_old_mappointer_small_entab; + map_mappointerv->entab = basilys_allocatereserved (lensiz, 0); + } else - map_mappointerv->entab = - ggc_alloc_cleared (len * sizeof (struct entrypointerbasilys_st)); + { + alloc_old_mappointer_small_entab: + map_mappointerv->entab = + ggc_alloc_cleared (len * sizeof (struct entrypointerbasilys_st)); + } map_mappointerv->lenix = 1; basilysgc_touch (map_mappointerv); } @@ -3173,13 +3256,21 @@ basilysgc_raw_put_mappointers (void *mappointer_p, int newlen = basilys_primtab[map_mappointerv->lenix + 1]; struct entrypointerbasilys_st *oldtab = NULL; struct entrypointerbasilys_st *newtab = NULL; + size_t newlensiz = newlen * sizeof (struct entrypointerbasilys_st); if (basilys_is_young (mappointerv)) - newtab = - basilysgc_allocate (newlen * - sizeof (struct entrypointerbasilys_st), 0); + { + basilysgc_reserve (newlensiz + 10 * sizeof (void *)); + if (!basilys_is_young (mappointerv)) + goto alloc_old_mappointer_entab; + newtab = basilys_allocatereserved (newlensiz, 0); + } else - newtab = - ggc_alloc_cleared (newlen * sizeof (struct entrypointerbasilys_st)); + { + alloc_old_mappointer_entab: + newtab = + ggc_alloc_cleared (newlen * + sizeof (struct entrypointerbasilys_st)); + } oldtab = map_mappointerv->entab; for (ix = 0; ix < len; ix++) { @@ -3266,19 +3357,28 @@ basilysgc_raw_remove_mappointers (void *mappointer_p, const void *attr) cnt = map_mappointerv->count; if (len > 7 && 2 * cnt + 2 < len) { - int newcnt = 0, newlen = 0, newlenix; + int newcnt = 0, newlen = 0, newlenix = 0; struct entrypointerbasilys_st *oldtab = NULL, *newtab = NULL; + size_t newlensiz = 0; for (newlenix = map_mappointerv->lenix; (newlen = basilys_primtab[newlenix]) > 2 * cnt + 3; newlenix--); if (newlen >= len) goto end; + newlensiz = newlen * sizeof (struct entrypointerbasilys_st); if (basilys_is_young (mappointerv)) - newtab = - basilysgc_allocate (newlen * - sizeof (struct entrypointerbasilys_st), 0); + { + basilysgc_reserve (newlensiz + 10 * sizeof (void *)); + if (!basilys_is_young (mappointerv)) + goto allocate_old_newtab_mappointer; + newtab = basilys_allocatereserved (newlensiz, 0); + } else - newtab = - ggc_alloc_cleared (newlen * sizeof (struct entrypointerbasilys_st)); + { + allocate_old_newtab_mappointer: + newtab = + ggc_alloc_cleared (newlen * + sizeof (struct entrypointerbasilys_st)); + }; oldtab = map_mappointerv->entab; for (ix = 0; ix < len; ix++) { @@ -3485,16 +3585,6 @@ end: } -#if 0 && NOT_NEEDED -static const char * -copynamestring (const char *string) -{ - size_t len = strlen (string) + 1; - char *s = (char *) obstack_alloc (&bname_obstack, len); - strcpy (s, string); - return s; -} -#endif #if ENABLE_CHECKING @@ -3816,7 +3906,7 @@ bad: C code should contain a function named start_module_basilys; that function is called with the given modata and returns the module */ basilys_ptr_t -basilysgc_compile_dyn (basilys_ptr_t modata_p, const char *modfile) +basilysgc_compile_dyn (basilys_ptr_t modata_p, const char *modfile) { char *srcpath = NULL; FILE *srcfi = NULL; @@ -3989,7 +4079,7 @@ basilysgc_compile_dyn (basilys_ptr_t modata_p, const char *modfile) /* catch all situation, failed to find the dynamic stuff */ fatal_error ("failed to find dynamic stuff for basilys generated %s (%s)", modfile, lt_dlerror ()); - dylibfound: +dylibfound: dlsy = lt_dlsym (dlh, "start_module_basilys"); if (!dlsy) fatal_error @@ -5037,7 +5127,7 @@ end: basilys_ptr_t -basilysgc_read_file (const char *filnam, const char*locnam) +basilysgc_read_file (const char *filnam, const char *locnam) { struct reading_st rds; FILE *fil = 0; @@ -5051,7 +5141,7 @@ basilysgc_read_file (const char *filnam, const char*locnam) if (!filnam) goto end; if (!locnam || !locnam[0]) - locnam = basename(filnam); + locnam = basename (filnam); debugeprintf ("basilysgc_read_file filnam %s locnam %s", filnam, locnam); fil = fopen (filnam, "rt"); if (!fil) @@ -5125,7 +5215,7 @@ do_initial_command (void) pararg[0].bp_aptr = (basilys_ptr_t *) & cstrv; if (basilys_secondargument_string && basilys_secondargument_string[0]) { - csecstrv = + csecstrv = basilysgc_new_string (BASILYSGOB (DISCR_STRING), basilys_secondargument_string); pararg[1].bp_aptr = (basilys_ptr_t *) & csecstrv; @@ -5137,7 +5227,7 @@ do_initial_command (void) BPARSTR_PTR, pararg, "", NULL); debugeprintf ("do_initial_command after apply closv %p", closv); } - end:; +end:; debugeprintf ("do_initial_command end %s", basilys_argument_string); BASILYS_EXITFRAME (); #undef dictv @@ -5187,6 +5277,8 @@ basilys_initialize (void) basilys_storalz = ((void **) basilys_endalz) - 2; basilys_newspeclist = NULL; basilys_oldspeclist = NULL; + debugeprintf ("basilys_initialize alloczon %p - %p (%ld Kw)", + basilys_startalz, basilys_endalz, (long) wantedwords >> 10); } debugeprintf ("basilys_initialize cpp_PREFIX=%s", cpp_PREFIX); debugeprintf ("basilys_initialize cpp_EXEC_PREFIX=%s", cpp_EXEC_PREFIX); @@ -5767,7 +5859,7 @@ basilys_output_cfile_decl_impl (basilys_ptr_t unitnam, fflush (cfil); fprintf (cfil, "\n/**** end of %s ****/\n", basilys_string_str (unitnam)); fclose (cfil); - debugeprintf("output_cfile done dotcnam %s", dotcnam); + debugeprintf ("output_cfile done dotcnam %s", dotcnam); free (dotcnam); free (dotcpercentnam); } @@ -5834,24 +5926,26 @@ execute_basilys (void) return 0; } -struct gimple_opt_pass pass_basilys = -{ +struct gimple_opt_pass pass_basilys = { { - GIMPLE_PASS, /* type */ - "basilys", /* name */ - gate_basilys, /* gate */ - execute_basilys, /* execute */ - NULL, /* sub */ - NULL, /* next */ - 0, /* static_pass_number */ - TV_BASILE_ANALYSIS, /* tv_id */ - PROP_cfg | PROP_ssa, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0, /* todo_flags_finish */ - } + GIMPLE_PASS, /* type */ + "basilys", /* name */ + gate_basilys, /* gate */ + execute_basilys, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + TV_BASILE_ANALYSIS, /* tv_id */ + PROP_cfg | PROP_ssa, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ + } }; + + + #include "gt-basilys.h" /* eof basilys.c */ diff --git a/gcc/basilys.h b/gcc/basilys.h index 39feaee8dc5..812edb46df4 100644 --- a/gcc/basilys.h +++ b/gcc/basilys.h @@ -986,6 +986,54 @@ basilysgc_allocate (size_t basesz, size_t gap) return ptr; } +/* we need sometimes to reserve some wanted size in the allocation + zone without actaully using it now; this is needed for the few + basilys data structures, e.g. basilysstrbuf_st, which have some + content (e.g. the buffer zone itself bufzn) which should be kept + young if the datastructure is young, and should become old (ie. GGC + allocated) when it becomes old */ +static inline void +basilysgc_reserve(size_t wanted) +{ + if (wanted < 100*sizeof(void*) + sizeof(struct basilysforward_st)) + wanted = 100*sizeof(void*) + sizeof(struct basilysforward_st); + if ((wanted % BASILYS_ALIGN) != 0) + wanted += (BASILYS_ALIGN - (wanted % BASILYS_ALIGN)); + if (BASILYS_UNLIKELY (basilys_curalz + wanted + 2 * BASILYS_ALIGN + >= (char *) basilys_storalz)) + basilys_garbcoll (wanted, BASILYS_MINOR_OR_FULL); +} + +/* allocates a previously reserved zone of BASESZ with extra GAP; + this should never trigger the GC, because space was reserved + earlier */ +static inline void * +basilys_allocatereserved (size_t basesz, size_t gap) +{ + size_t wanted; + void *ptr; + if (basesz < sizeof (struct basilysforward_st)) + basesz = sizeof (struct basilysforward_st); + if ((basesz % BASILYS_ALIGN) != 0) + basesz += (BASILYS_ALIGN - (basesz % BASILYS_ALIGN)); + if ((gap % BASILYS_ALIGN) != 0) + gap += (BASILYS_ALIGN - (gap % BASILYS_ALIGN)); + wanted = basesz + gap; + gcc_assert (wanted >= sizeof (struct basilysforward_st)); + if (BASILYS_UNLIKELY (basilys_curalz + wanted + 2 * BASILYS_ALIGN + >= (char *) basilys_storalz)) + fatal_error("allocatereserved out of space for %ld wanted bytes", + (long) wanted); + ptr = basilys_curalz; +#if ENABLE_CHECKING + if (ptr == tracedptr1) + debugeprintf("allocated tracedptr1 %p", ptr); + else if (ptr == tracedptr2) + debugeprintf("allocated tracedptr2 %p", ptr); +#endif + basilys_curalz += wanted; + return ptr; +} /* we maintain a small cache hasharray of touched values - the touched cache size should be a small prime */ @@ -1890,11 +1938,19 @@ basilys_is_instance_of (basilys_ptr_t inst_p, basilys_ptr_t class_p) * CALL FRAMES ***/ +struct framloc_basilys_st { + const char* frlo_file; + int frlo_line; +}; + /* call frames for our copying garbage collector cannot be GTY-ed because they are inside the C call stack */ struct callframe_basilys_st { unsigned nbvar; +#if ENABLE_CHECKING + struct framloc_basilys_st* floc; +#endif struct basilysclosure_st *clos; struct excepth_basilys_st *exh; /* for our exceptions - not implemented yet */ struct callframe_basilys_st *prev; @@ -1914,22 +1970,44 @@ extern basilys_ptr_t basilys_jmpval; #endif /* declare the current callframe */ +#if ENABLE_CHECKING #define BASILYS_DECLFRAME(NBVAR) struct { \ unsigned nbvar; \ + const struct framloc_basilys_st* floc; \ struct basilysclosure_st* clos; \ struct excepth_basilys_st* exh; \ struct callframe_basilys_st* prev; \ void* /* a basilys_ptr_t */ varptr[NBVAR]; \ } curfram__ - /* initialize the current callframe and link it at top */ #define BASILYS_INITFRAME(NBVAR,CLOS) do { \ + static const struct framloc_basilys_st here= \ + { __FILE__, __LINE__ }; \ memset(&curfram__, 0, sizeof(curfram__)); \ curfram__.nbvar = (NBVAR); \ + curfram__.floc = &here; \ curfram__.prev = basilys_topframe; \ curfram__.clos = (CLOS); \ basilys_topframe = ((void*)&curfram__); \ } while(0) +#else +#define BASILYS_DECLFRAME(NBVAR) struct { \ + unsigned nbvar; \ + struct basilysclosure_st* clos; \ + struct excepth_basilys_st* exh; \ + struct callframe_basilys_st* prev; \ + void* /* a basilys_ptr_t */ varptr[NBVAR]; \ +} curfram__ +/* initialize the current callframe and link it at top */ +#define BASILYS_INITFRAME(NBVAR,CLOS) do { \ + memset(&curfram__, 0, sizeof(curfram__)); \ + curfram__.nbvar = (NBVAR); \ + curfram__.prev = basilys_topframe; \ + curfram__.clos = (CLOS); \ + basilys_topframe = ((void*)&curfram__); \ +} while(0) +#endif + /* declare and initialize the current callframe */ #define BASILYS_ENTERFRAME(NBVAR,CLOS) \ diff --git a/gcc/melt/warm-basilys.bysl b/gcc/melt/warm-basilys.bysl index 9d82412820c..5f823beaf57 100644 --- a/gcc/melt/warm-basilys.bysl +++ b/gcc/melt/warm-basilys.bysl @@ -6338,6 +6338,12 @@ (add2sbuf_indentnl implbuf 0) (add2sbuf_strconst implbuf " struct { unsigned nbvar;") (add2sbuf_indentnl implbuf 0) + (add2sbuf_strconst implbuf "#if ENABLE_CHECKING") + (add2sbuf_indentnl implbuf 0) + (add2sbuf_strconst implbuf " struct framloc_basilys_st* floc;") + (add2sbuf_indentnl implbuf 0) + (add2sbuf_strconst implbuf "#endif") + (add2sbuf_indentnl implbuf 0) (add2sbuf_strconst implbuf " struct basilysclosure_st *clos;") (add2sbuf_indentnl implbuf 0) (add2sbuf_strconst implbuf " struct excepth_basilys_st *exh;") @@ -6371,6 +6377,12 @@ (add2sbuf_strconst implbuf " long _spare_; } curfram__ = {") (add2sbuf_longdec implbuf nbval) (add2sbuf_strconst implbuf ", ") + (add2sbuf_strconst implbuf "#if ENABLE_CHECKING") + (add2sbuf_indentnl implbuf 0) + (add2sbuf_strconst implbuf " (struct framloc_basilys_st *)0, ") + (add2sbuf_indentnl implbuf 0) + (add2sbuf_strconst implbuf "#endif") + (add2sbuf_indentnl implbuf 0) (add2sbuf_strconst implbuf " (struct basilysclosure_st *)0, ") (add2sbuf_strconst implbuf " (struct excepth_basilys_st *)0, ") (add2sbuf_strconst implbuf " (struct callframe_basilys_st *) 0, ") |