Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
af0bcf9c
Commit
af0bcf9c
authored
Mar 14, 1997
by
sof
Browse files
[project @ 1997-03-14 03:08:24 by sof]
Free foreign objects on exit
parent
a449ff3e
Changes
3
Hide whitespace changes
Inline
Side-by-side
ghc/runtime/storage/SMextn.lc
View file @
af0bcf9c
...
...
@@ -161,8 +161,8 @@ Trace_ForeignObj( FOptr )
P_ FOptr;
{
if (RTSflags.GcFlags.trace & DEBUG_TRACE_FOREIGNOBJS) {
printf("DEBUG: ForeignObj(%
l
x)=<%
lx,_
,%
l
x,%
l
x,%
l
x>\n", (W_) FOptr, (W_) FOptr[0], (W_) FOptr[1], (W_) FOptr[2], (W_) FOptr[3]);
printf(" Data = %
l
x, Finaliser = %
l
x, Next = %
l
x\n",
printf("DEBUG: ForeignObj(%
0
x)=<%
0x
,%
0
x,%
0
x,%
0
x>\n", (W_) FOptr, (W_) FOptr[0], (W_) FOptr[1], (W_) FOptr[2], (W_) FOptr[3]);
printf(" Data = %
0
x, Finaliser = %
0
x, Next = %
0
x\n",
(W_) ForeignObj_CLOSURE_DATA(FOptr),
(W_) ForeignObj_CLOSURE_FINALISER(FOptr),
(W_) ForeignObj_CLOSURE_LINK(FOptr) );
...
...
@@ -362,6 +362,74 @@ reportDeadForeignObjs(oldFOList, new, newFOList)
#endif /* _INFO_COPYING */
\end{code}
@freeForeigns@ summarily calls the finaliser routines for
all live foreign objects, done when closing down.
(code is just a rip off of the above).
\begin{code}
#if defined(_INFO_COPYING)
#if defined(DEBUG)
# if defined(GCgn)
EXTDATA_RO(Forward_Ref_New_info);
EXTDATA_RO(Forward_Ref_Old_info);
EXTDATA_RO(OldRoot_Forward_Ref_info);
# else
EXTDATA_RO(Forward_Ref_info);
# endif
#endif
/*
Call the ForeignObj finalising routine on all the live FOs,
used when shutting down.
*/
int
freeForeigns(foList)
P_ foList;
{
P_ FOptr, temp;
I_ FO_deaths = 0;
/* At this point, exitSSM() has been calledthe ForeignObjList is in an invalid state (since
some info ptrs will have been mangled) so we can't validate
it. ADR */
DEBUG_STRING("Freeing all live Foreign Objects:");
FOptr = foList;
while ( FOptr != NULL ) {
/* I'm not convinced that the situation of having
indirections linked into the FO list can ever occur,
but chasing indirections doesn't hurt. */
while(IS_INDIRECTION(INFO_PTR(FOptr))) {
FOptr = (P_) IND_CLOSURE_PTR(FOptr);
}
if ((P_) INFO_PTR(FOptr) == ForeignObj_info ) {
TRACE_ForeignObj(FOptr);
TRACE_FOdies(FOptr);
(*(void (*)(StgAddr))(ForeignObj_CLOSURE_FINALISER(FOptr)))((StgAddr)ForeignObj_CLOSURE_DATA(FOptr));
FO_deaths++;
temp = FOptr;
FOptr = ForeignObj_CLOSURE_LINK(FOptr);
/* Now trash the closure to encourage bugs to show themselves */
TRASH_ForeignObj_CLOSURE( temp );
} else {
fprintf(stderr, "Warning: Foreign object list contained unexpected element, bailing out of FO cleanup.\n");
return 1;
}
}
return 0;
}
#endif /* _INFO_COPYING */
\end{code}
\upsection
\begin{code}
...
...
ghc/runtime/storage/SMextn.lh
View file @
af0bcf9c
...
...
@@ -9,6 +9,7 @@ void initExtensions PROTO((smInfo *sm));
void evacSPTable PROTO((smInfo *sm));
void reportDeadForeignObjs PROTO((StgPtr oldMPList, StgPtr new, StgPtr *newMPLust));
int freeForeigns PROTO((StgPtr foList));
# endif /* _INFO_COPYING */
...
...
ghc/runtime/storage/SMinit.lc
View file @
af0bcf9c
...
...
@@ -23,8 +23,10 @@ A filehandle to which any storage-manager statistics should be written.
rtsBool
exitSM (smInfo *sm_info)
{
int rc;
/* Upon closing down the storage manager, we free all foreign objects */
freeForeigns(sm_info->ForeignObjList);
rc = freeForeigns(sm_info->ForeignObjList);
/* Return code ignored for now */
stat_exit(sm_info->hp - hp_start);
return rtsTrue; /* I'm happy */
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment