Skip to content

Commit

Permalink
kernel: fix marking of precords and component objects
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Apr 28, 2018
1 parent 0591d21 commit 4489660
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -2009,14 +2009,14 @@ static Int InitKernel (

/* install the marking methods */
InfoBags[ T_COMOBJ ].name = "object (component)";
InitMarkFuncBags( T_COMOBJ , MarkAllSubBags );
InitMarkFuncBags( T_COMOBJ , MarkPRecSubBags );
InfoBags[ T_POSOBJ ].name = "object (positional)";
InitMarkFuncBags( T_POSOBJ , MarkAllSubBags );
InfoBags[ T_DATOBJ ].name = "object (data)";
InitMarkFuncBags( T_DATOBJ , MarkOneSubBags );
#if !defined(USE_THREADSAFE_COPYING)
InfoBags[ T_COMOBJ +COPYING ].name = "object (component,copied)";
InitMarkFuncBags( T_COMOBJ +COPYING , MarkAllSubBags );
InitMarkFuncBags( T_COMOBJ +COPYING , MarkPRecSubBags );
InfoBags[ T_POSOBJ +COPYING ].name = "object (positional,copied)";
InitMarkFuncBags( T_POSOBJ +COPYING , MarkAllSubBags );
InfoBags[ T_DATOBJ +COPYING ].name = "object (data,copied)";
Expand Down
31 changes: 27 additions & 4 deletions src/precord.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,29 @@ void LoadPRec( Obj prec )
}
}

/****************************************************************************
**
*F MarkPRecSubBags( <bag> ) . . . . marking function for precs and com. objs
**
** 'MarkPRecSubBags' is the marking function for bags of type 'T_PREC' or
** 'T_COMOBJ'.
*/
void MarkPRecSubBags(Obj bag)
{
const Bag * data = CONST_PTR_BAG(bag);
const UInt count = SIZE_BAG(bag) / sizeof(Bag);

// while data[0] is unused for regular precords, it used during copying
// to store a pointer to the copy; moreover, this mark function is also
// used for component objects, which store their type in slot 0
MarkBag(data[0]);

for (UInt i = 3; i < count; i += 2) {
MarkBag(data[i]);
}
}


/****************************************************************************
**
*F * * * * * * * * * * * * * initialize module * * * * * * * * * * * * * * *
Expand Down Expand Up @@ -864,11 +887,11 @@ static Int InitKernel (
/* GASMAN marking functions and GASMAN names */
InitBagNamesFromTable( BagNames );

InitMarkFuncBags( T_PREC , MarkAllSubBags );
InitMarkFuncBags( T_PREC +IMMUTABLE , MarkAllSubBags );
InitMarkFuncBags( T_PREC , MarkPRecSubBags );
InitMarkFuncBags( T_PREC +IMMUTABLE , MarkPRecSubBags );
#if !defined(USE_THREADSAFE_COPYING)
InitMarkFuncBags( T_PREC +COPYING , MarkAllSubBags );
InitMarkFuncBags( T_PREC +IMMUTABLE +COPYING , MarkAllSubBags );
InitMarkFuncBags( T_PREC +COPYING , MarkPRecSubBags );
InitMarkFuncBags( T_PREC +IMMUTABLE +COPYING , MarkPRecSubBags );
#endif

/* Immutable records are public */
Expand Down
4 changes: 4 additions & 0 deletions src/precord.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ extern void CopyPRecord(Obj copy, Obj original);
#endif



extern void MarkPRecSubBags(Obj bag);


/****************************************************************************
**
*F * * * * * * * * * * * * * initialize module * * * * * * * * * * * * * * *
Expand Down

0 comments on commit 4489660

Please sign in to comment.