[gs-cvs] rev 7668 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Thu Feb 1 20:47:30 PST 2007
Author: leonardo
Date: 2007-02-01 20:47:29 -0800 (Thu, 01 Feb 2007)
New Revision: 7668
Modified:
trunk/gs/src/gsalloc.c
trunk/gs/src/gxalloc.h
trunk/gs/src/ialloc.c
trunk/gs/src/idosave.h
trunk/gs/src/igc.c
trunk/gs/src/igcref.c
trunk/gs/src/isave.c
trunk/gs/src/isave.h
trunk/gs/src/zvmem.c
Log:
Fix (memory management) : Make the NO_INVISIBLE_LEVELS feature be permanent.
DETAILS :
This change is algorithmically equivalent,
It removes some macros, which are not longer in use.
For details about NO_INVISIBLE_LEVELS see
http://ghostscript.com/pipermail/gs-cvs/2006-April/006467.html
Now we believe that NO_INVISIBLE_LEVELS feature
has been tested enough (during 10 monthes) to become permanent.
Two obsolete macros alloc_restore_state_step, alloc_forget_save
are expanded and removed.
EXPECTED DIFFERENCES :
None.
Modified: trunk/gs/src/gsalloc.c
===================================================================
--- trunk/gs/src/gsalloc.c 2007-02-01 19:48:10 UTC (rev 7667)
+++ trunk/gs/src/gsalloc.c 2007-02-02 04:47:29 UTC (rev 7668)
@@ -85,18 +85,14 @@
ENUM_PTRS_BEGIN(ref_memory_enum_ptrs) return 0;
ENUM_PTR3(0, gs_ref_memory_t, streams, names_array, changes);
ENUM_PTR(3, gs_ref_memory_t, saved);
-#if NO_INVISIBLE_LEVELS
ENUM_PTR(4, gs_ref_memory_t, scan_limit);
-#endif
ENUM_PTRS_END
private RELOC_PTRS_WITH(ref_memory_reloc_ptrs, gs_ref_memory_t *mptr)
{
RELOC_PTR(gs_ref_memory_t, streams);
RELOC_PTR(gs_ref_memory_t, names_array);
RELOC_PTR(gs_ref_memory_t, changes);
-#if NO_INVISIBLE_LEVELS
RELOC_PTR(gs_ref_memory_t, scan_limit);
-#endif
/* Don't relocate the saved pointer now -- see igc.c for details. */
mptr->reloc_saved = RELOC_OBJ(mptr->saved);
}
@@ -328,10 +324,8 @@
mem->allocated = 0;
mem->inherited = 0;
mem->changes = 0;
-#if NO_INVISIBLE_LEVELS
mem->scan_limit = 0;
mem->total_scanned = 0;
-#endif
ialloc_reset_free(mem);
}
Modified: trunk/gs/src/gxalloc.h
===================================================================
--- trunk/gs/src/gxalloc.h 2007-02-01 19:48:10 UTC (rev 7667)
+++ trunk/gs/src/gxalloc.h 2007-02-02 04:47:29 UTC (rev 7668)
@@ -26,8 +26,6 @@
#include "gsalloc.h"
#include "gxobj.h"
-#define NO_INVISIBLE_LEVELS 1 /* old code = 0, new code = 1 */
-
/* ================ Chunks ================ */
/*
@@ -382,9 +380,7 @@
/* Sharing / saved state information */
int num_contexts; /* # of contexts sharing this VM */
struct alloc_change_s *changes;
-#if NO_INVISIBLE_LEVELS
struct alloc_change_s *scan_limit;
-#endif
struct alloc_save_s *saved;
long total_scanned;
struct alloc_save_s *reloc_saved; /* for GC */
Modified: trunk/gs/src/ialloc.c
===================================================================
--- trunk/gs/src/ialloc.c 2007-02-01 19:48:10 UTC (rev 7667)
+++ trunk/gs/src/ialloc.c 2007-02-02 04:47:29 UTC (rev 7668)
@@ -185,7 +185,6 @@
*/
chunk_t *pcc = mem->pcc;
ref *end;
-#if NO_INVISIBLE_LEVELS
ref_packed **ppr = 0;
int code = 0;
@@ -194,7 +193,6 @@
if (code < 0)
return code;
}
-#endif
obj = gs_alloc_struct_array((gs_memory_t *) mem, num_refs + 1,
ref, &st_refs, cname);
if (obj == 0)
@@ -219,10 +217,8 @@
chunk_locate_ptr(obj, &cl);
cl.cp->has_refs = true;
}
-#if NO_INVISIBLE_LEVELS
if (ppr)
*ppr = (ref_packed *)obj;
-#endif
}
make_array(parr, attrs | mem->space, num_refs, obj);
return 0;
@@ -286,10 +282,8 @@
) {
if ((obj_header_t *) obj == mem->cc.rcur) {
/* Deallocate the entire refs object. */
-#if NO_INVISIBLE_LEVELS
if ((gs_memory_t *)mem != mem->stable_memory)
alloc_save_remove(mem, (ref_packed *)obj, "gs_free_ref_array");
-#endif
gs_free_object((gs_memory_t *) mem, obj, cname);
mem->cc.rcur = 0;
mem->cc.rtop = 0;
@@ -319,10 +313,8 @@
if_debug4('a', "[a%d:-$L]%s(%u) 0x%lx\n",
ialloc_trace_space(mem), client_name_string(cname),
num_refs, (ulong) obj);
-#if NO_INVISIBLE_LEVELS
if ((gs_memory_t *)mem != mem->stable_memory)
alloc_save_remove(mem, (ref_packed *)obj, "gs_free_ref_array");
-#endif
alloc_free_chunk(cl.cp, mem);
return;
}
Modified: trunk/gs/src/idosave.h
===================================================================
--- trunk/gs/src/idosave.h 2007-02-01 19:48:10 UTC (rev 7667)
+++ trunk/gs/src/idosave.h 2007-02-02 04:47:29 UTC (rev 7668)
@@ -33,11 +33,9 @@
ref_packed *ptr, client_name_t cname);
int alloc_save_change_in(gs_ref_memory_t *mem, const ref *pcont,
ref_packed *ptr, client_name_t cname);
-#if NO_INVISIBLE_LEVELS
/* Remove an AC_OFFSET_ALLOCATED element. */
void alloc_save_remove(gs_ref_memory_t *mem, ref_packed *obj, client_name_t cname);
/* Allocate a structure for recording an allocation event. */
int alloc_save_change_alloc(gs_ref_memory_t *mem, client_name_t cname, ref_packed ***ppr);
-#endif
#endif /* idosave_INCLUDED */
Modified: trunk/gs/src/igc.c
===================================================================
--- trunk/gs/src/igc.c 2007-02-01 19:48:10 UTC (rev 7667)
+++ trunk/gs/src/igc.c 2007-02-02 04:47:29 UTC (rev 7668)
@@ -373,7 +373,6 @@
end_phase("finish trace");
}
-#if NO_INVISIBLE_LEVELS
/* Filter save change lists with removing elements,
which point to unmarked blocks of refs. */
{
@@ -385,7 +384,6 @@
alloc_save__filter_changes(mem);
}
}
-#endif
/* Clear marks and relocation in spaces that are only being traced. */
/* We have to clear the marks first, because we want the */
/* relocation to wind up as o_untraced, not o_unmarked. */
Modified: trunk/gs/src/igcref.c
===================================================================
--- trunk/gs/src/igcref.c 2007-02-01 19:48:10 UTC (rev 7667)
+++ trunk/gs/src/igcref.c 2007-02-02 04:47:29 UTC (rev 7668)
@@ -33,9 +33,7 @@
/* Forward references */
ptr_proc_reloc(igc_reloc_ref_ptr, ref_packed);
-#if NO_INVISIBLE_LEVELS
ptr_proc_reloc(igc_reloc_ref_ptr_nocheck, ref_packed);
-#endif
refs_proc_reloc(igc_reloc_refs);
/*
@@ -549,7 +547,6 @@
}
}
-#if NO_INVISIBLE_LEVELS
/* Relocate a pointer to a ref. */
/* See gsmemory.h for why the argument is const and the result is not. */
ref_packed *
@@ -658,93 +655,7 @@
return u.w;
}
}
-#else
-/* Relocate a pointer to a ref. */
-/* See gsmemory.h for why the argument is const and the result is not. */
-ref_packed *
-igc_reloc_ref_ptr(const ref_packed * prp, gc_state_t *gcst)
-{
- /*
- * Search forward for relocation. This algorithm is intrinsically very
- * inefficient; we hope eventually to replace it with a better one.
- */
- const ref_packed *rp = prp;
- uint dec = 0;
-#ifdef ALIGNMENT_ALIASING_BUG
- const ref *rpref;
-# define RP_REF(rp) (rpref = (const ref *)rp, rpref)
-#else
-# define RP_REF(rp) ((const ref *)rp)
-#endif
- /*
- * Iff this pointer points into a space that wasn't traced,
- * the referent won't be marked. In this case, we shouldn't
- * do any relocation. Check for this first.
- */
- if (r_is_packed(rp)) {
- if (!r_has_pmark(rp))
- goto ret_rp;
- } else {
- if (!r_has_attr(RP_REF(rp), l_mark))
- goto ret_rp;
- }
- for (;;) {
- if (r_is_packed(rp)) {
- /*
- * Normally, an unmarked packed ref will be an
- * integer whose value is the amount of relocation.
- * However, the relocation value might have been
- * too large to fit. If this is the case, for
- * each such unmarked packed ref we pass over,
- * we have to decrement the final relocation.
- */
- rputc((*rp & lp_mark ? '1' : '0'));
- if (!(*rp & lp_mark)) {
- if (*rp != pt_tag(pt_integer) + packed_max_value) {
- /* This is a stored relocation value. */
- rputc('\n');
- rp = print_reloc(prp, "ref",
- (const ref_packed *)
- ((const char *)prp -
- (*rp & packed_value_mask) + dec));
- break;
- }
- /*
- * We know this is the first of an aligned block
- * of packed refs. Skip over the entire block,
- * decrementing the final relocation.
- */
- dec += sizeof(ref_packed) * align_packed_per_ref;
- rp += align_packed_per_ref;
- } else
- rp++;
- continue;
- }
- if (!ref_type_uses_size_or_null(r_type(RP_REF(rp)))) {
- /* reloc is in r_size */
- rputc('\n');
- rp = print_reloc(prp, "ref",
- (const ref_packed *)
- (r_size(RP_REF(rp)) == 0 ? prp :
- (const ref_packed *)((const char *)prp -
- r_size(RP_REF(rp)) + dec)));
- break;
- }
- rputc('u');
- rp += packed_per_ref;
- }
-ret_rp:
- /* Use a severely deprecated pun to remove the const property. */
- {
- union { const ref_packed *r; ref_packed *w; } u;
-
- u.r = rp;
- return u.w;
- }
-}
-#endif
-
/* ------ Compaction phase ------ */
/* Compact a ref object. */
@@ -762,23 +673,14 @@
It was useful during the development,
when some assumptions were temporary wrong.
We keep it for records. */
-#define LAST_ELEM_MAY_BE_MARKED (0 && NO_INVISIBLE_LEVELS)
src = (ref_packed *) (pre + 1);
end = (ref_packed *) ((byte *) src + size);
-#if LAST_ELEM_MAY_BE_MARKED
/*
- * We know that a block of refs always ends with an unmarked
- * full-size ref, so we only need to check for reaching the end
- * of the block when we see one of those.
- */
-#else
- /*
* We know that a block of refs always ends with a
* full-size ref, so we only need to check for reaching the end
* of the block when we see one of those.
*/
-#endif
if (dpre == pre) /* Loop while we don't need to copy. */
for (;;) {
if (r_is_packed(src)) {
@@ -796,15 +698,6 @@
if_debug1('8', " [8]ref 0x%lx \"copied\"\n", (ulong) src);
r_clear_attrs(pref, l_mark);
src += packed_per_ref;
-#if LAST_ELEM_MAY_BE_MARKED
- /* The last (the extra) ref may be marked from
- alloc_change_t::offset==AC_OFFSET_ALLOCATED,
- if the extra ref ends an empty ref array. */
- if (src >= end) {
- src -= packed_per_ref;
- break;
- }
-#endif
}
} else
*dpre = *pre;
@@ -830,13 +723,6 @@
r_clear_attrs(&rtemp, l_mark);
ref_assign_inline((ref *) dest, &rtemp);
src += packed_per_ref;
-#if LAST_ELEM_MAY_BE_MARKED
- /* The last (the extra) ref may be marked from
- alloc_change_t::offset==AC_OFFSET_ALLOCATED,
- if the extra ref ends an empty ref array. */
- if (src >= end)
- break;
-#endif
dest += packed_per_ref;
} else { /* check for end of block */
src += packed_per_ref;
@@ -845,7 +731,6 @@
}
}
}
-#undef LAST_ELEM_MAY_BE_MARKED
new_size = (byte *) dest - (byte *) (dpre + 1) + sizeof(ref);
#ifdef DEBUG
/* Check that the relocation came out OK. */
Modified: trunk/gs/src/isave.c
===================================================================
--- trunk/gs/src/isave.c 2007-02-01 19:48:10 UTC (rev 7667)
+++ trunk/gs/src/isave.c 2007-02-02 04:47:29 UTC (rev 7668)
@@ -27,9 +27,7 @@
#include "isstate.h"
#include "store.h" /* for ref_assign */
#include "ivmspace.h"
-#if NO_INVISIBLE_LEVELS
#include "igc.h"
-#endif
#include "gsutil.h" /* gs_next_ids prototype */
/* Structure descriptor */
@@ -155,10 +153,8 @@
str, spacen, (ulong)sav, (ulong)sav->client_data, (ulong)sav->id);
}
-#if NO_INVISIBLE_LEVELS
/* A link to igcref.c . */
ptr_proc_reloc(igc_reloc_ref_ptr_nocheck, ref_packed);
-#endif
/*
* Structure for saved change chain for save/restore. Because of the
@@ -172,9 +168,7 @@
ref contents;
#define AC_OFFSET_STATIC (-2) /* static object */
#define AC_OFFSET_REF (-1) /* dynamic ref */
-#if NO_INVISIBLE_LEVELS
#define AC_OFFSET_ALLOCATED (-3) /* a newly allocated ref array */
-#endif
short offset; /* if >= 0, offset within struct */
};
@@ -195,7 +189,6 @@
if (ptr->offset >= 0)
ENUM_RETURN((byte *) ptr->where - ptr->offset);
else
-#if NO_INVISIBLE_LEVELS
if (ptr->offset != AC_OFFSET_ALLOCATED)
ENUM_RETURN_REF(ptr->where);
else {
@@ -204,9 +197,6 @@
alloc_save__filter_changes. */
ENUM_RETURN(0);
}
-#else
- ENUM_RETURN_REF(ptr->where);
-#endif
case 2:
ENUM_RETURN_REF(&ptr->contents);
ENUM_PTRS_END
@@ -219,7 +209,6 @@
case AC_OFFSET_REF:
RELOC_REF_PTR_VAR(ptr->where);
break;
-#if NO_INVISIBLE_LEVELS
case AC_OFFSET_ALLOCATED:
/* We know that ptr->where may point to an unmarked object
because change_enum_ptrs skipped it,
@@ -238,7 +227,6 @@
if (ptr->where != 0 && !gcst->relocating_untraced)
ptr->where = igc_reloc_ref_ptr_nocheck(ptr->where, gcst);
break;
-#endif
default:
{
byte *obj = (byte *) ptr->where - ptr->offset;
@@ -292,9 +280,7 @@
private void restore_free(gs_ref_memory_t *);
private int save_set_new(gs_ref_memory_t * mem, bool to_new, bool set_limit, ulong *pscanned);
private int save_set_new_changes(gs_ref_memory_t *, bool, bool);
-#if NO_INVISIBLE_LEVELS
private bool check_l_mark(void *obj);
-#endif
/* Initialize the save/restore machinery. */
void
@@ -384,7 +370,6 @@
if (code < 0)
return code;
-#if !NO_INVISIBLE_LEVELS
if ((lsave->state.total_scanned += scanned) > max_repeated_scan) {
/* Do a second, invisible save. */
alloc_save_t *rsave;
@@ -412,9 +397,6 @@
print_save("save", lmem->space, lsave);
}
}
-#else
- (void)scanned;
-#endif
}
alloc_set_in_save(dmem);
*psid = sid;
@@ -535,7 +517,6 @@
return alloc_save_change_in(mem, pcont, where, cname);
}
-#if NO_INVISIBLE_LEVELS
/* Allocate a structure for recording an allocation event. */
int
alloc_save_change_alloc(gs_ref_memory_t *mem, client_name_t cname, ref_packed ***ppr)
@@ -612,8 +593,6 @@
alloc_save__filter_changes_in_space(mem);
}
-#endif
-
/* Return (the id of) the innermost externally visible save object, */
/* i.e., the innermost save with a non-zero ID. */
ulong
@@ -854,11 +833,9 @@
alloc_save_print(cp, true);
}
#endif
-#if NO_INVISIBLE_LEVELS
if (cp->offset == AC_OFFSET_ALLOCATED)
DO_NOTHING;
else
-#endif
if (r_is_packed(&cp->contents))
*cp->where = *(ref_packed *) & cp->contents;
else
@@ -1163,11 +1140,9 @@
ref_packed *prp = chp->where;
if_debug1('U', "[U]forgetting change 0x%lx\n", (ulong) chp);
-#if NO_INVISIBLE_LEVELS
if (chp->offset == AC_OFFSET_ALLOCATED)
DO_NOTHING;
else
-#endif
if (!r_is_packed(prp))
r_clear_attrs((ref *) prp, l_new);
next = chp->next;
@@ -1244,7 +1219,6 @@
return 0;
}
-#if NO_INVISIBLE_LEVELS
/* Check if a block contains refs marked by garbager. */
private bool
check_l_mark(void *obj)
@@ -1278,7 +1252,6 @@
}
#undef RP_REF
}
-#endif
/* Set or reset the l_new attribute in every relevant slot. */
/* This includes every slot on the current change chain, */
@@ -1295,7 +1268,6 @@
if (code < 0)
return code;
-#if !NO_INVISIBLE_LEVELS
/* Handle newly allocated ref objects. */
SCAN_MEM_CHUNKS(mem, cp) {
if (cp->has_refs) {
@@ -1323,7 +1295,6 @@
END_CHUNKS_SCAN
if_debug2('u', "[u]set_new (%s) scanned %ld\n",
(to_new ? "restore" : "save"), scanned);
-#endif
*pscanned = scanned;
return 0;
}
@@ -1334,12 +1305,9 @@
{
register alloc_change_t *chp = mem->changes;
register uint new = (to_new ? l_new : 0);
-#if NO_INVISIBLE_LEVELS
ulong scanned = mem->total_scanned;
-#endif
for (; chp; chp = chp->next) {
-#if NO_INVISIBLE_LEVELS
if (chp->offset == AC_OFFSET_ALLOCATED) {
if (chp->where != 0) {
uint size;
@@ -1349,9 +1317,7 @@
return code;
scanned += size;
}
- } else
-#endif
- {
+ } else {
ref_packed *prp = chp->where;
if_debug3('U', "[U]set_new 0x%lx: (0x%lx, %d)\n",
@@ -1363,12 +1329,9 @@
(rp->tas.type_attrs & ~l_new) + new;
}
}
-#if NO_INVISIBLE_LEVELS
if (mem->scan_limit == chp)
break;
-#endif
}
-#if NO_INVISIBLE_LEVELS
if (set_limit) {
if (scanned >= max_repeated_scan) {
mem->scan_limit = mem->changes;
@@ -1376,6 +1339,5 @@
} else
mem->total_scanned = scanned;
}
-#endif
return 0;
}
Modified: trunk/gs/src/isave.h
===================================================================
--- trunk/gs/src/isave.h 2007-02-01 19:48:10 UTC (rev 7667)
+++ trunk/gs/src/isave.h 2007-02-02 04:47:29 UTC (rev 7668)
@@ -81,8 +81,6 @@
* if this is the case, the operation cannot fail.
*/
int alloc_restore_step_in(gs_dual_memory_t *, alloc_save_t *);
-/* Backward compatibility */
-#define alloc_restore_state_step(save) alloc_restore_step_in(idmemory, save)
/*
* Forget a save -- like committing a transaction (restore is like
@@ -91,15 +89,11 @@
* require checking pointers for recency.
*/
int alloc_forget_save_in(gs_dual_memory_t *, alloc_save_t *);
-/* Backward compatibility */
-#define alloc_forget_save(save) alloc_forget_save_in(idmemory, save)
/* Release all memory -- like doing a restore "past the bottom". */
int alloc_restore_all(gs_dual_memory_t *);
-#if NO_INVISIBLE_LEVELS
/* Filter save change lists. */
void alloc_save__filter_changes(gs_ref_memory_t *mem);
-#endif
/* ------ Internals ------ */
Modified: trunk/gs/src/zvmem.c
===================================================================
--- trunk/gs/src/zvmem.c 2007-02-01 19:48:10 UTC (rev 7667)
+++ trunk/gs/src/zvmem.c 2007-02-02 04:47:29 UTC (rev 7668)
@@ -151,7 +151,7 @@
*/
vmsave->gsave = 0;
/* Now it's safe to restore the state of memory. */
- code = alloc_restore_state_step(asave);
+ code = alloc_restore_step_in(idmemory, asave);
if (code < 0)
return code;
last = code;
@@ -407,7 +407,7 @@
gs_grestore(last);
}
/* Forget the save in the memory manager. */
- code = alloc_forget_save(asave);
+ code = alloc_forget_save_in(idmemory, asave);
if (code < 0)
return code;
{
More information about the gs-cvs
mailing list