Commit 63706895 authored by simonmar's avatar simonmar

[project @ 2001-12-12 14:25:03 by simonmar]

- Relax the restriction that roots must also be retainers, by changing
  the type of the 'r' argument to retainClosure from (StgClosure *) to
  retainer.  Now retainRoot can pass CCS_SYSTEM as the retainer for a
  root if the closure is itself not a retainer.

- Traverse roots from the stable ptr table, which might not also be
  retainers (hence the generalisation above).
parent 9021d33f
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* $Id: RetainerProfile.c,v 1.2 2001/11/26 16:54:21 simonmar Exp $ * $Id: RetainerProfile.c,v 1.3 2001/12/12 14:25:03 simonmar Exp $
* *
* (c) The GHC Team, 2001 * (c) The GHC Team, 2001
* Author: Sungwoo Park * Author: Sungwoo Park
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "RtsFlags.h" #include "RtsFlags.h"
#include "Weak.h" #include "Weak.h"
#include "Sanity.h" #include "Sanity.h"
#include "StablePriv.h"
#include "Profiling.h" #include "Profiling.h"
#include "Stats.h" #include "Stats.h"
#include "BlockAlloc.h" #include "BlockAlloc.h"
...@@ -60,8 +61,8 @@ StgWord flip = 0; // flip bit ...@@ -60,8 +61,8 @@ StgWord flip = 0; // flip bit
#define setRetainerSetToNull(c) \ #define setRetainerSetToNull(c) \
(c)->header.prof.hp.rs = (RetainerSet *)((StgWord)NULL | flip) (c)->header.prof.hp.rs = (RetainerSet *)((StgWord)NULL | flip)
static void retainStack(StgClosure *, StgClosure *, StgClosure *, StgPtr, StgPtr); static void retainStack(StgClosure *, retainer, StgClosure *, StgPtr, StgPtr);
static void retainClosure(StgClosure *, StgClosure *, StgClosure *); static void retainClosure(StgClosure *, StgClosure *, retainer);
#ifdef DEBUG_RETAINER #ifdef DEBUG_RETAINER
static void belongToHeap(StgPtr p); static void belongToHeap(StgPtr p);
#endif #endif
...@@ -135,7 +136,7 @@ typedef struct { ...@@ -135,7 +136,7 @@ typedef struct {
typedef struct { typedef struct {
StgClosure *c; StgClosure *c;
StgClosure *c_child_r; retainer c_child_r;
stackPos info; stackPos info;
} stackElement; } stackElement;
...@@ -344,7 +345,7 @@ find_srt( stackPos *info ) ...@@ -344,7 +345,7 @@ find_srt( stackPos *info )
* Note: SRTs are considered to be children as well. * Note: SRTs are considered to be children as well.
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
static inline void static inline void
push( StgClosure *c, StgClosure *c_child_r, StgClosure **first_child ) push( StgClosure *c, retainer c_child_r, StgClosure **first_child )
{ {
stackElement se; stackElement se;
bdescr *nbd; // Next Block Descriptor bdescr *nbd; // Next Block Descriptor
...@@ -660,7 +661,7 @@ popOff(void) { ...@@ -660,7 +661,7 @@ popOff(void) {
* is empty. * is empty.
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
static inline void static inline void
pop( StgClosure **c, StgClosure **cp, StgClosure **r ) pop( StgClosure **c, StgClosure **cp, retainer *r )
{ {
stackElement *se; stackElement *se;
...@@ -1048,7 +1049,7 @@ associate( StgClosure *c, RetainerSet *s ) ...@@ -1048,7 +1049,7 @@ associate( StgClosure *c, RetainerSet *s )
* retainClosure() is invoked instead of evacuate(). * retainClosure() is invoked instead of evacuate().
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
static void static void
retainStack( StgClosure *c, StgClosure *c_child_r, retainStack( StgClosure *c, retainer c_child_r,
StgClosure *stackOptionalFun, StgPtr stackStart, StgClosure *stackOptionalFun, StgPtr stackStart,
StgPtr stackEnd ) StgPtr stackEnd )
{ {
...@@ -1234,16 +1235,16 @@ retainStack( StgClosure *c, StgClosure *c_child_r, ...@@ -1234,16 +1235,16 @@ retainStack( StgClosure *c, StgClosure *c_child_r,
* *c0 can be TSO (as well as PAP and AP_UPD). * *c0 can be TSO (as well as PAP and AP_UPD).
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
static void static void
retainClosure( StgClosure *c0, StgClosure *cp0, StgClosure *r0 ) retainClosure( StgClosure *c0, StgClosure *cp0, retainer r0 )
{ {
// c = Current closure // c = Current closure
// cp = Current closure's Parent // cp = Current closure's Parent
// r = current closures' most recent Retainer // r = current closures' most recent Retainer
// c_child_r = current closure's children's most recent retainer // c_child_r = current closure's children's most recent retainer
// first_child = first child of c // first_child = first child of c
StgClosure *c, *cp, *r, *c_child_r, *first_child; StgClosure *c, *cp, *first_child;
RetainerSet *s, *retainerSetOfc; RetainerSet *s, *retainerSetOfc;
retainer R_r; retainer r, c_child_r;
StgWord typeOfc; StgWord typeOfc;
#ifdef DEBUG_RETAINER #ifdef DEBUG_RETAINER
...@@ -1391,7 +1392,6 @@ inner_loop: ...@@ -1391,7 +1392,6 @@ inner_loop:
s = retainerSetOf(cp); s = retainerSetOf(cp);
// (c, cp, r, s) is available. // (c, cp, r, s) is available.
R_r = getRetainerFrom(r);
// (c, cp, r, s, R_r) is available, so compute the retainer set for *c. // (c, cp, r, s, R_r) is available, so compute the retainer set for *c.
if (retainerSetOfc == NULL) { if (retainerSetOfc == NULL) {
...@@ -1399,20 +1399,20 @@ inner_loop: ...@@ -1399,20 +1399,20 @@ inner_loop:
numObjectVisited++; numObjectVisited++;
if (s == NULL) if (s == NULL)
associate(c, singleton(R_r)); associate(c, singleton(r));
else else
// s is actually the retainer set of *c! // s is actually the retainer set of *c!
associate(c, s); associate(c, s);
// compute c_child_r // compute c_child_r
c_child_r = isRetainer(c) ? c : r; c_child_r = isRetainer(c) ? getRetainerFrom(c) : r;
} else { } else {
// This is not the first visit to *c. // This is not the first visit to *c.
if (isMember(R_r, retainerSetOfc)) if (isMember(r, retainerSetOfc))
goto loop; // no need to process child goto loop; // no need to process child
if (s == NULL) if (s == NULL)
associate(c, addElement(R_r, retainerSetOfc)); associate(c, addElement(r, retainerSetOfc));
else { else {
// s is not NULL and cp is not a retainer. This means that // s is not NULL and cp is not a retainer. This means that
// each time *cp is visited, so is *c. Thus, if s has // each time *cp is visited, so is *c. Thus, if s has
...@@ -1423,7 +1423,7 @@ inner_loop: ...@@ -1423,7 +1423,7 @@ inner_loop:
} }
// Otherwise, just add R_r to the current retainer set of *c. // Otherwise, just add R_r to the current retainer set of *c.
else { else {
associate(c, addElement(R_r, retainerSetOfc)); associate(c, addElement(r, retainerSetOfc));
} }
} }
...@@ -1490,7 +1490,11 @@ retainRoot( StgClosure **tl ) ...@@ -1490,7 +1490,11 @@ retainRoot( StgClosure **tl )
ASSERT(isEmptyRetainerStack()); ASSERT(isEmptyRetainerStack());
currentStackBoundary = stackTop; currentStackBoundary = stackTop;
retainClosure(*tl, *tl, *tl); if (isRetainer(*tl)) {
retainClosure(*tl, *tl, getRetainerFrom(*tl));
} else {
retainClosure(*tl, *tl, CCS_SYSTEM);
}
// NOT TRUE: ASSERT(isMember(getRetainerFrom(*tl), retainerSetOf(*tl))); // NOT TRUE: ASSERT(isMember(getRetainerFrom(*tl), retainerSetOf(*tl)));
// *tl might be a TSO which is ThreadComplete, in which // *tl might be a TSO which is ThreadComplete, in which
...@@ -1522,6 +1526,9 @@ computeRetainerSet( void ) ...@@ -1522,6 +1526,9 @@ computeRetainerSet( void )
// retainRoot((StgClosure *)weak); // retainRoot((StgClosure *)weak);
retainRoot((StgClosure **)&weak); retainRoot((StgClosure **)&weak);
// Consider roots from the stable ptr table.
markStablePtrTable(retainRoot);
// The following code resets the rs field of each unvisited mutable // The following code resets the rs field of each unvisited mutable
// object (computing sumOfNewCostExtra and updating costArray[] when // object (computing sumOfNewCostExtra and updating costArray[] when
// debugging retainer profiler). // debugging retainer profiler).
......
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