Commit 63015c7f authored by simonm's avatar simonm
Browse files

[project @ 1999-02-11 17:40:23 by simonm]

finalise/finalize changes.
parent 09e2e8bb
/* -----------------------------------------------------------------------------
* $Id: StgMiscClosures.h,v 1.9 1999/02/05 16:02:29 simonm Exp $
* $Id: StgMiscClosures.h,v 1.10 1999/02/11 17:40:23 simonm Exp $
*
* (c) The GHC Team, 1998-1999
*
......@@ -28,7 +28,7 @@ STGFUN(BCO_entry);
STGFUN(EVACUATED_entry);
STGFUN(FOREIGN_entry);
STGFUN(WEAK_entry);
STGFUN(NO_FINALISER_entry);
STGFUN(NO_FINALIZER_entry);
STGFUN(DEAD_WEAK_entry);
STGFUN(STABLE_NAME_entry);
STGFUN(TSO_entry);
......@@ -60,7 +60,7 @@ extern const StgInfoTable EVACUATED_info;
extern const StgInfoTable FOREIGN_info;
extern const StgInfoTable WEAK_info;
extern const StgInfoTable DEAD_WEAK_info;
extern const StgInfoTable NO_FINALISER_info;
extern const StgInfoTable NO_FINALIZER_info;
extern const StgInfoTable STABLE_NAME_info;
extern const StgInfoTable FULL_MVAR_info;
extern const StgInfoTable EMPTY_MVAR_info;
......@@ -87,7 +87,7 @@ extern const StgInfoTable ret_bco_info;
extern StgClosure END_TSO_QUEUE_closure;
extern StgClosure END_MUT_LIST_closure;
extern StgClosure NO_FINALISER_closure;
extern StgClosure NO_FINALIZER_closure;
extern StgClosure dummy_ret_closure;
extern StgIntCharlikeClosure CHARLIKE_closure[];
......
/* -----------------------------------------------------------------------------
* $Id: Evaluator.c,v 1.8 1999/02/05 16:02:38 simonm Exp $
* $Id: Evaluator.c,v 1.9 1999/02/11 17:40:24 simonm Exp $
*
* Copyright (c) The GHC Team 1994-1999.
*
......@@ -202,7 +202,7 @@ static /*inline*/ void PushTaggedInteger ( mpz_ptr x )
SET_HDR(w, &WEAK_info, CCCS);
w->key = stgCast(StgClosure*,result);
w->value = stgCast(StgClosure*,result); /* or any other closure you have handy */
w->finaliser = funPtrToIO(mpz_free);
w->finalizer = funPtrToIO(mpz_free);
w->link = weak_ptr_list;
weak_ptr_list = w;
IF_DEBUG(weak, fprintf(stderr,"New weak pointer watching Foreign MPZ at %p\n",w));
......@@ -2330,7 +2330,7 @@ enterLoop:
SET_HDR(w, &WEAK_info, CCCS);
w->key = PopCPtr();
w->value = PopCPtr();
w->finaliser = PopCPtr();
w->finalizer = PopCPtr();
w->link = weak_ptr_list;
weak_ptr_list = w;
IF_DEBUG(weak, fprintf(stderr,"New weak pointer at %p\n",w));
......
/* -----------------------------------------------------------------------------
* $Id: GC.c,v 1.29 1999/02/09 12:50:38 simonm Exp $
* $Id: GC.c,v 1.30 1999/02/11 17:40:26 simonm Exp $
*
* (c) The GHC Team 1998-1999
*
......@@ -652,8 +652,8 @@ void GarbageCollect(void (*get_roots)(void))
alloc_blocks = 0;
alloc_blocks_lim = RtsFlags.GcFlags.minAllocAreaSize;
/* start any pending finalisers */
scheduleFinalisers(old_weak_ptr_list);
/* start any pending finalizers */
scheduleFinalizers(old_weak_ptr_list);
/* check sanity after GC */
IF_DEBUG(sanity, checkSanity(N));
......@@ -692,7 +692,7 @@ void GarbageCollect(void (*get_roots)(void))
new live weak pointers, then all the currently unreachable ones are
dead.
For generational GC: we just don't try to finalise weak pointers in
For generational GC: we just don't try to finalize weak pointers in
older generations than the one we're collecting. This could
probably be optimised by keeping per-generation lists of weak
pointers, but for a few weak pointers this scheme will work.
......@@ -707,7 +707,7 @@ traverse_weak_ptr_list(void)
if (weak_done) { return rtsFalse; }
/* doesn't matter where we evacuate values/finalisers to, since
/* doesn't matter where we evacuate values/finalizers to, since
* these pointers are treated as roots (iff the keys are alive).
*/
evac_gen = 0;
......@@ -717,9 +717,9 @@ traverse_weak_ptr_list(void)
if ((new = isAlive(w->key))) {
w->key = new;
/* evacuate the value and finaliser */
/* evacuate the value and finalizer */
w->value = evacuate(w->value);
w->finaliser = evacuate(w->finaliser);
w->finalizer = evacuate(w->finalizer);
/* remove this weak ptr from the old_weak_ptr list */
*last_w = w->link;
/* and put it on the new weak ptr list */
......@@ -739,12 +739,12 @@ traverse_weak_ptr_list(void)
/* If we didn't make any changes, then we can go round and kill all
* the dead weak pointers. The old_weak_ptr list is used as a list
* of pending finalisers later on.
* of pending finalizers later on.
*/
if (flag == rtsFalse) {
for (w = old_weak_ptr_list; w; w = w->link) {
w->value = evacuate(w->value);
w->finaliser = evacuate(w->finaliser);
w->finalizer = evacuate(w->finalizer);
}
weak_done = rtsTrue;
}
......
/* -----------------------------------------------------------------------------
* $Id: RtsStartup.c,v 1.6 1999/02/05 16:02:50 simonm Exp $
* $Id: RtsStartup.c,v 1.7 1999/02/11 17:40:27 simonm Exp $
*
* (c) The GHC Team, 1998-1999
*
......@@ -114,8 +114,8 @@ extern void startupHaskell(int argc, char *argv[])
void
shutdownHaskell(void)
{
/* Finalise any remaining weak pointers */
finaliseWeakPointersNow();
/* Finalize any remaining weak pointers */
finalizeWeakPointersNow();
#if defined(GRAN)
#error FixMe.
......
/* -----------------------------------------------------------------------------
* $Id: Sanity.c,v 1.9 1999/02/05 16:02:52 simonm Exp $
* $Id: Sanity.c,v 1.10 1999/02/11 17:40:28 simonm Exp $
*
* (c) The GHC Team, 1998-1999
*
......@@ -264,7 +264,7 @@ checkClosure( StgClosure* p )
{ StgWeak *w = (StgWeak *)p;
ASSERT(LOOKS_LIKE_PTR(w->key));
ASSERT(LOOKS_LIKE_PTR(w->value));
ASSERT(LOOKS_LIKE_PTR(w->finaliser));
ASSERT(LOOKS_LIKE_PTR(w->finalizer));
if (w->link) {
ASSERT(LOOKS_LIKE_PTR(w->link));
}
......
/* -----------------------------------------------------------------------------
* $Id: Weak.h,v 1.3 1999/02/05 16:03:04 simonm Exp $
* $Id: Weak.h,v 1.4 1999/02/11 17:40:28 simonm Exp $
*
* (c) The GHC Team, 1998-1999
*
* Weak pointers / finalisers
* Weak pointers / finalizers
*
* ---------------------------------------------------------------------------*/
extern StgWeak *weak_ptr_list;
void finaliseWeakPointersNow(void);
void scheduleFinalisers(StgWeak *w);
void finalizeWeakPointersNow(void);
void scheduleFinalizers(StgWeak *w);
void markWeakList(void);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment