From bcc7380e82e017e671c784b6cfd3dd095b2fa6bd Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 26 Apr 2018 13:10:55 +0200 Subject: [PATCH] kernel: fix marking of precords and component objects --- src/objects.c | 4 ++-- src/precord.c | 26 ++++++++++++++++++++++---- src/precord.h | 4 ++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/objects.c b/src/objects.c index c6b4e00bd62..5d52715029b 100644 --- a/src/objects.c +++ b/src/objects.c @@ -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)"; diff --git a/src/precord.c b/src/precord.c index c10c42ce247..605846a0a67 100644 --- a/src/precord.c +++ b/src/precord.c @@ -821,6 +821,24 @@ void LoadPRec( Obj prec ) } } +/**************************************************************************** +** +*F MarkPRecSubBags( ) . . . . 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); + MarkBag(data[0]); // unused for precords; type for component objects + for (UInt i = 3; i < count; i += 2) { + MarkBag(data[i]); + } +} + + /**************************************************************************** ** *F * * * * * * * * * * * * * initialize module * * * * * * * * * * * * * * * @@ -864,11 +882,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 */ diff --git a/src/precord.h b/src/precord.h index e753f5c376d..f2d23e97695 100644 --- a/src/precord.h +++ b/src/precord.h @@ -260,6 +260,10 @@ extern void CopyPRecord(Obj copy, Obj original); #endif + +extern void MarkPRecSubBags(Obj bag); + + /**************************************************************************** ** *F * * * * * * * * * * * * * initialize module * * * * * * * * * * * * * * *