added U3_CELLOC_TOGGLE

This commit is contained in:
Philip C Monk 2015-05-08 21:22:11 -04:00
parent 3155535c80
commit 1edf15843f
3 changed files with 28 additions and 18 deletions

View File

@ -8,6 +8,12 @@
*/ */
# undef U3_MEMORY_DEBUG # undef U3_MEMORY_DEBUG
/* U3_CELLOC_TOGGLE: enable toggling of the custum cell allocator
* via -g. This slightly slows down the cell allocator even when
* it's on. Note that toggling -g breaks the image. If
* U3_MEMORY_DEBUG is on, this should generally be on as well.
*/
# define U3_CELLOC_TOGGLE
/** Constants. /** Constants.
**/ **/

33
n/a.c
View File

@ -561,9 +561,12 @@ u3a_malloc(size_t len_i)
c3_w* c3_w*
u3a_celloc(void) u3a_celloc(void)
{ {
#ifdef U3_MEMORY_DEBUG #ifdef U3_CELLOC_TOGGLE
return u3a_walloc(c3_wiseof(u3a_cell)); if ( u3C.wag_w & u3o_debug_ram ) {
#else return u3a_walloc(c3_wiseof(u3a_cell));
}
#endif
u3p(u3a_fbox) cel_p; u3p(u3a_fbox) cel_p;
if ( (u3R == &(u3H->rod_u)) || !(cel_p = u3R->all.cel_p) ) { if ( (u3R == &(u3H->rod_u)) || !(cel_p = u3R->all.cel_p) ) {
@ -577,7 +580,6 @@ u3a_celloc(void)
return u3a_boxto(box_u); return u3a_boxto(box_u);
} }
#endif
} }
/* u3a_cfree(): free a cell. /* u3a_cfree(): free a cell.
@ -585,9 +587,12 @@ u3a_celloc(void)
void void
u3a_cfree(c3_w* cel_w) u3a_cfree(c3_w* cel_w)
{ {
#ifdef U3_MEMORY_DEBUG #ifdef U3_CELLOC_TOGGLE
return u3a_wfree(cel_w); if ( u3C.wag_w & u3o_debug_ram ) {
#else return u3a_wfree(cel_w);
}
#endif
if ( u3R == &(u3H->rod_u) ) { if ( u3R == &(u3H->rod_u) ) {
return u3a_wfree(cel_w); return u3a_wfree(cel_w);
} }
@ -598,7 +603,6 @@ u3a_cfree(c3_w* cel_w)
u3to(u3a_fbox, fre_p)->nex_p = u3R->all.cel_p; u3to(u3a_fbox, fre_p)->nex_p = u3R->all.cel_p;
u3R->all.cel_p = fre_p; u3R->all.cel_p = fre_p;
} }
#endif
} }
/* u3a_realloc(): aligned realloc in bytes. /* u3a_realloc(): aligned realloc in bytes.
@ -1335,10 +1339,10 @@ u3a_mark_ptr(void* ptr_v)
use_ws -= 1; use_ws -= 1;
siz_w = 0; siz_w = 0;
} }
// else if ( 0x80000000 == (c3_w)use_ws ) { // see _raft_prof() else if ( 0x80000000 == (c3_w)use_ws ) { // see _raft_prof()
// use_ws = -1; use_ws = -1;
// siz_w = 0xffffffff; siz_w = 0xffffffff;
// } }
else { else {
use_ws = -1; use_ws = -1;
siz_w = box_u->siz_w; siz_w = box_u->siz_w;
@ -1479,10 +1483,7 @@ u3a_sweep(void)
(u3_noun)u3a_to_pom(u3a_outa(u3a_boxto(box_w))), (u3_noun)u3a_to_pom(u3a_outa(u3a_boxto(box_w))),
((u3a_noun *)(u3a_boxto(box_w)))->mug_w, ((u3a_noun *)(u3a_boxto(box_w)))->mug_w,
box_u->use_w, box_u->eus_w); box_u->use_w, box_u->eus_w);
//static int xuc_i = 0; // u3m_p("weak", u3a_to_pom(u3a_outa(u3a_boxto(box_w))));
//if ( 2 != ++xuc_i && 3 != xuc_i ) {
// u3m_p("weak", u3a_to_pom(u3a_outa(u3a_boxto(box_w))));
//}
} }
weq_w += box_u->siz_w; weq_w += box_u->siz_w;
} }

View File

@ -1847,6 +1847,10 @@ static void
_raft_grab(u3_noun ova) _raft_grab(u3_noun ova)
{ {
if ( u3_nul != u3A->sac ) { if ( u3_nul != u3A->sac ) {
if ( !(u3C.wag_w & u3o_debug_ram) ) {
fprintf(stderr, "massing doesn't work without the -g flag\r\n");
goto _raft_grab_end;
}
c3_w usr_w = 0, ova_w = 0, sac_w = 0, utv_w = 0, utm_w = 0, wep_w = 0; c3_w usr_w = 0, ova_w = 0, sac_w = 0, utv_w = 0, utm_w = 0, wep_w = 0;
usr_w = _raft_prof(u3_nul, 0, u3A->sac); usr_w = _raft_prof(u3_nul, 0, u3A->sac);
@ -1876,10 +1880,9 @@ _raft_grab(u3_noun ova)
fprintf(stderr, "sweep: "); fprintf(stderr, "sweep: ");
_raft_print_memory(wep_w); _raft_print_memory(wep_w);
_raft_grab_end:
u3z(u3A->sac); u3z(u3A->sac);
u3A->sac = u3_nul; u3A->sac = u3_nul;
} else {
// u3m_grab(ova, u3_none);
} }
} }