keep all dynamic arrays linked and garbage collect them.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@481 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
a5638757d3
commit
61affa1652
23
C/heapgc.c
23
C/heapgc.c
@ -369,6 +369,14 @@ push_registers(Int num_regs, yamop *nextop)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
/* push array entries first */
|
||||||
|
ArrayEntry *al = DynArrayList;
|
||||||
|
while (al != NULL) {
|
||||||
|
if (al->ArrayEArity > 0) {
|
||||||
|
TrailTerm(TR++) = al->ValueOfVE;
|
||||||
|
}
|
||||||
|
al = al->NextArrayE;
|
||||||
|
}
|
||||||
#ifdef COROUTINING
|
#ifdef COROUTINING
|
||||||
TrailTerm(TR) = WokenGoals;
|
TrailTerm(TR) = WokenGoals;
|
||||||
TrailTerm(TR+1) = MutableList;
|
TrailTerm(TR+1) = MutableList;
|
||||||
@ -411,6 +419,14 @@ pop_registers(Int num_regs, yamop *nextop)
|
|||||||
int i;
|
int i;
|
||||||
tr_fr_ptr ptr = TR;
|
tr_fr_ptr ptr = TR;
|
||||||
|
|
||||||
|
/* pop array entries first */
|
||||||
|
ArrayEntry *al = DynArrayList;
|
||||||
|
while (al != NULL) {
|
||||||
|
if (al->ArrayEArity > 0) {
|
||||||
|
al->ValueOfVE = TrailTerm(ptr++);
|
||||||
|
}
|
||||||
|
al = al->NextArrayE;
|
||||||
|
}
|
||||||
#ifdef COROUTINING
|
#ifdef COROUTINING
|
||||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||||
WokenGoals = TrailTerm(ptr++);
|
WokenGoals = TrailTerm(ptr++);
|
||||||
@ -1206,11 +1222,12 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else if (IsPairTerm(trail_cell)) {
|
} else if (IsPairTerm(trail_cell)) {
|
||||||
/* do nothing */
|
/* can safely ignore this */
|
||||||
}
|
}
|
||||||
#if MULTI_ASSIGNMENT_VARIABLES
|
#if MULTI_ASSIGNMENT_VARIABLES
|
||||||
else {
|
else {
|
||||||
tr_fr_ptr *lkp;
|
tr_fr_ptr *lkp;
|
||||||
|
CELL *cptr = RepAppl(trail_cell);
|
||||||
/* This is a bit complex. The idea is that we may have several
|
/* This is a bit complex. The idea is that we may have several
|
||||||
trailings for the same mavar in the same trail segment. Essentially,
|
trailings for the same mavar in the same trail segment. Essentially,
|
||||||
the problem arises because of !. What we want is to ignore all but
|
the problem arises because of !. What we want is to ignore all but
|
||||||
@ -1221,10 +1238,10 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B
|
|||||||
|
|
||||||
Solution: we keep a list of all found entries and search in the end
|
Solution: we keep a list of all found entries and search in the end
|
||||||
*/
|
*/
|
||||||
if (!(lkp = gc_lookup_ma_var(RepAppl(trail_cell), trail_ptr))) {
|
if (!(lkp = gc_lookup_ma_var(cptr, trail_ptr))) {
|
||||||
if (HEAP_PTR(trail_cell)) {
|
if (HEAP_PTR(trail_cell)) {
|
||||||
/* fool the gc into thinking this is a variable */
|
/* fool the gc into thinking this is a variable */
|
||||||
TrailTerm(trail_ptr) = (CELL)RepAppl(trail_cell);
|
TrailTerm(trail_ptr) = (CELL)cptr;
|
||||||
mark_external_reference(&(TrailTerm(trail_ptr)));
|
mark_external_reference(&(TrailTerm(trail_ptr)));
|
||||||
/* reset the gc to believe the original tag */
|
/* reset the gc to believe the original tag */
|
||||||
TrailTerm(trail_ptr) = AbsAppl((CELL *)TrailTerm(trail_ptr));
|
TrailTerm(trail_ptr) = AbsAppl((CELL *)TrailTerm(trail_ptr));
|
||||||
|
1
C/init.c
1
C/init.c
@ -1008,6 +1008,7 @@ InitCodes(void)
|
|||||||
#endif
|
#endif
|
||||||
heap_regs->term_prolog = MkAtomTerm(LookupAtom("prolog"));
|
heap_regs->term_prolog = MkAtomTerm(LookupAtom("prolog"));
|
||||||
heap_regs->term_refound_var = MkAtomTerm(LookupAtom("$I_FOUND_THE_VARIABLE_AGAIN"));
|
heap_regs->term_refound_var = MkAtomTerm(LookupAtom("$I_FOUND_THE_VARIABLE_AGAIN"));
|
||||||
|
heap_regs->dyn_array_list = NULL;
|
||||||
heap_regs->n_of_file_aliases = 0;
|
heap_regs->n_of_file_aliases = 0;
|
||||||
heap_regs->file_aliases = NULL;
|
heap_regs->file_aliases = NULL;
|
||||||
heap_regs->foreign_code_loaded = NULL;
|
heap_regs->foreign_code_loaded = NULL;
|
||||||
|
2
C/save.c
2
C/save.c
@ -1114,6 +1114,8 @@ restore_codes(void)
|
|||||||
#endif
|
#endif
|
||||||
heap_regs->term_prolog = AtomTermAdjust(heap_regs->term_prolog);
|
heap_regs->term_prolog = AtomTermAdjust(heap_regs->term_prolog);
|
||||||
heap_regs->term_refound_var = AtomTermAdjust(heap_regs->term_refound_var);
|
heap_regs->term_refound_var = AtomTermAdjust(heap_regs->term_refound_var);
|
||||||
|
heap_regs->dyn_array_list =
|
||||||
|
(struct array_entry *)AddrAdjust((ADDR)heap_regs->dyn_array_list);
|
||||||
heap_regs->file_aliases =
|
heap_regs->file_aliases =
|
||||||
(struct AliasDescS *)AddrAdjust((ADDR)heap_regs->file_aliases);
|
(struct AliasDescS *)AddrAdjust((ADDR)heap_regs->file_aliases);
|
||||||
heap_regs->yap_lib_dir =
|
heap_regs->yap_lib_dir =
|
||||||
|
4
H/Heap.h
4
H/Heap.h
@ -10,7 +10,7 @@
|
|||||||
* File: Heap.h *
|
* File: Heap.h *
|
||||||
* mods: *
|
* mods: *
|
||||||
* comments: Heap Init Structure *
|
* comments: Heap Init Structure *
|
||||||
* version: $Id: Heap.h,v 1.25 2002-05-14 18:24:33 vsc Exp $ *
|
* version: $Id: Heap.h,v 1.26 2002-05-23 03:52:34 vsc Exp $ *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
/* information that can be stored in Code Space */
|
/* information that can be stored in Code Space */
|
||||||
@ -281,6 +281,7 @@ typedef struct various_codes {
|
|||||||
PredEntry *pred_dollar_catch;
|
PredEntry *pred_dollar_catch;
|
||||||
PredEntry *pred_throw;
|
PredEntry *pred_throw;
|
||||||
PredEntry *pred_handle_throw;
|
PredEntry *pred_handle_throw;
|
||||||
|
struct array_entry *dyn_array_list;
|
||||||
UInt n_of_file_aliases;
|
UInt n_of_file_aliases;
|
||||||
UInt sz_of_file_aliases;
|
UInt sz_of_file_aliases;
|
||||||
struct AliasDescS * file_aliases;
|
struct AliasDescS * file_aliases;
|
||||||
@ -472,6 +473,7 @@ typedef struct various_codes {
|
|||||||
#define PredDollarCatch heap_regs->pred_dollar_catch
|
#define PredDollarCatch heap_regs->pred_dollar_catch
|
||||||
#define PredThrow heap_regs->pred_throw
|
#define PredThrow heap_regs->pred_throw
|
||||||
#define PredHandleThrow heap_regs->pred_handle_throw
|
#define PredHandleThrow heap_regs->pred_handle_throw
|
||||||
|
#define DynArrayList heap_regs->dyn_array_list
|
||||||
#define NOfFileAliases heap_regs->n_of_file_aliases
|
#define NOfFileAliases heap_regs->n_of_file_aliases
|
||||||
#define SzOfFileAliases heap_regs->sz_of_file_aliases
|
#define SzOfFileAliases heap_regs->sz_of_file_aliases
|
||||||
#define FileAliases heap_regs->file_aliases
|
#define FileAliases heap_regs->file_aliases
|
||||||
|
@ -416,13 +416,14 @@ Inline(IsBBProperty, PropFlags, int, flags, (flags == BBProperty))
|
|||||||
|
|
||||||
/* array property entry structure */
|
/* array property entry structure */
|
||||||
/* first case is for dynamic arrays */
|
/* first case is for dynamic arrays */
|
||||||
typedef struct {
|
typedef struct array_entry {
|
||||||
Prop NextOfPE; /* used to chain properties */
|
Prop NextOfPE; /* used to chain properties */
|
||||||
PropFlags KindOfPE; /* kind of property */
|
PropFlags KindOfPE; /* kind of property */
|
||||||
Int ArrayEArity; /* Arity of Array (positive) */
|
Int ArrayEArity; /* Arity of Array (positive) */
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
rwlock_t ArRWLock; /* a read-write lock to protect the entry */
|
rwlock_t ArRWLock; /* a read-write lock to protect the entry */
|
||||||
#endif
|
#endif
|
||||||
|
struct array_entry *NextArrayE; /* Pointer to the actual array */
|
||||||
Term ValueOfVE; /* Pointer to the actual array */
|
Term ValueOfVE; /* Pointer to the actual array */
|
||||||
} ArrayEntry;
|
} ArrayEntry;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user