Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#include "bool.h"
#include "code.h"
#include "error.h"
#ifdef USE_GASMAN
#include "gasman_intern.h"
#endif
#include "gvars.h"
#include "integer.h"
#include "io.h"
Expand Down
3 changes: 3 additions & 0 deletions src/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include "error.h"
#include "funcs.h"
#include "gapstate.h"
#ifdef USE_GASMAN
#include "gasman_intern.h"
#endif
#include "gvars.h"
#include "integer.h"
#include "io.h"
Expand Down
1 change: 1 addition & 0 deletions src/gasman.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
*/

#include "gasman.h"
#include "gasman_intern.h"

#include "gaputils.h"
#include "io.h"
Expand Down
117 changes: 2 additions & 115 deletions src/gasman.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ static inline UInt SIZE_BAG_CONTENTS(const void *ptr) {
** Note that 'LINK_BAG' is a macro, so do not call it with arguments that
** have side effects.
*/
#ifdef USE_GASMAN
#define LINK_BAG(bag) (BAG_HEADER(bag)->link)
#endif


/****************************************************************************
Expand Down Expand Up @@ -833,23 +835,6 @@ extern void MarkBag( Bag bag );
#define MARK_BAG(bag) MarkBag(bag)


/****************************************************************************
**
*F MarkBagWeakly(<bag>) . . . . . . . . . . . . . mark a bag as weakly live
**
** 'MarkBagWeakly' is an alternative to MarkBag, intended to be used by the
** marking functions of weak pointer objects. A bag which is marked both
** weakly and strongly is treated as strongly marked. A bag which is only
** weakly marked will be recovered by garbage collection, but its identifier
** remains, marked in a way which can be detected by
** "IS_WEAK_DEAD_BAG". Which should always be checked before copying or
** using such an identifier.
*/
#if !defined(USE_BOEHM_GC)
extern void MarkBagWeakly( Bag bag );
#endif


/****************************************************************************
**
*F MarkArrayOfBags(<array>,<count>) . . . . . . . mark all bags in an array
Expand All @@ -860,32 +845,6 @@ extern void MarkBagWeakly( Bag bag );
extern void MarkArrayOfBags(const Bag array[], UInt count);


/****************************************************************************
**
*F
*/

#ifdef USE_GASMAN

extern Bag * MptrBags;
extern Bag * MptrEndBags;
extern Bag * AllocBags;

#define IS_WEAK_DEAD_BAG(bag) ( (((UInt)bag & (sizeof(Bag)-1)) == 0) && \
(Bag)MptrBags <= (bag) && \
(bag) < (Bag)MptrEndBags && \
(((UInt)*bag) & (sizeof(Bag)-1)) == 1)

#elif defined(USE_BOEHM_GC)

#define IS_WEAK_DEAD_BAG(bag) (!(bag))
#define REGISTER_WP(loc, obj) \
GC_general_register_disappearing_link((void **)(loc), (obj))
#define FORGET_WP(loc) \
GC_unregister_disappearing_link((void **)(loc))

#endif

/****************************************************************************
**
*F InitSweepFuncBags(<type>,<sweep-func>) . . . . install sweeping function
Expand Down Expand Up @@ -921,26 +880,6 @@ extern void InitSweepFuncBags (
TNumSweepFuncBags sweep_func );
#endif

/****************************************************************************
**
*V GlobalBags . . . . . . . . . . . . . . . . . . . . . list of global bags
*/
#ifdef USE_GASMAN

#ifndef NR_GLOBAL_BAGS
#define NR_GLOBAL_BAGS 20000L
#endif


typedef struct {
Bag * addr [NR_GLOBAL_BAGS];
const Char * cookie [NR_GLOBAL_BAGS];
UInt nr;
} TNumGlobalBags;

extern TNumGlobalBags GlobalBags;

#endif

/****************************************************************************
**
Expand Down Expand Up @@ -971,24 +910,6 @@ extern void InitGlobalBag (
Bag * addr,
const Char * cookie );

#ifdef USE_GASMAN

extern void SortGlobals( UInt byWhat );

extern Bag * GlobalByCookie(
const Char * cookie );


extern void StartRestoringBags( UInt nBags, UInt maxSize);


extern Bag NextBagRestoring( UInt type, UInt flags, UInt size );


extern void FinishedRestoringBags( void );

#endif


/****************************************************************************
**
Expand Down Expand Up @@ -1045,26 +966,6 @@ extern void InitCollectFuncBags (
#endif


/****************************************************************************
**
*F CheckMasterPointers() . . . . . . . . . . . . do some consistency checks
**
** 'CheckMasterPointers' tests for masterpointers which are not one of the
** following:
**
** 0 denoting the end of the free chain
** NewWeakDeadBagMarker denoting the relic of a bag that was weakly
** OldWeakDeadBagMarker but not strongly linked at the last garbage
** collection
** a pointer into the masterpointer area a link on the free chain
** a pointer into the bags area a real object
**
*/
#ifdef USE_GASMAN
extern void CheckMasterPointers( void );
#endif


/****************************************************************************
**
*F InitBags(...) . . . . . . . . . . . . . . . . . . . . . initialize Gasman
Expand Down Expand Up @@ -1122,20 +1023,6 @@ extern void InitBags(UInt initial_size,

extern void FinishBags( void );

/****************************************************************************
**
*F CallbackForAllBags( <func> ) call a C function on all non-zero mptrs
**
** This calls a C function on every bag, including ones that are not
** reachable from the root, and will be deleted at the next garbage
** collection, by simply walking the masterpointer area. Not terribly safe.
**
*/
#ifdef USE_GASMAN
extern void CallbackForAllBags( void (*func)(Bag) );
#endif


#if !defined(USE_GASMAN)
void *AllocateMemoryBlock(UInt size);
#endif
Expand Down
98 changes: 98 additions & 0 deletions src/gasman_intern.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#ifndef GAP_GASMAN_INTERN_H
#define GAP_GASMAN_INTERN_H

#include "gasman.h"

#ifndef USE_GASMAN
#error This file must only be included if GASMAN is used
#endif


/****************************************************************************
**
*F MarkBagWeakly(<bag>) . . . . . . . . . . . . . mark a bag as weakly live
**
** 'MarkBagWeakly' is an alternative to MarkBag, intended to be used by the
** marking functions of weak pointer objects. A bag which is marked both
** weakly and strongly is treated as strongly marked. A bag which is only
** weakly marked will be recovered by garbage collection, but its identifier
** remains, marked in a way which can be detected by
** "IS_WEAK_DEAD_BAG". Which should always be checked before copying or
** using such an identifier.
*/
extern void MarkBagWeakly( Bag bag );


/****************************************************************************
**
*/
extern Bag * MptrBags;
extern Bag * MptrEndBags;
extern Bag * AllocBags;


/****************************************************************************
**
*V GlobalBags . . . . . . . . . . . . . . . . . . . . . list of global bags
*/
#ifndef NR_GLOBAL_BAGS
#define NR_GLOBAL_BAGS 20000L
#endif


typedef struct {
Bag * addr [NR_GLOBAL_BAGS];
const Char * cookie [NR_GLOBAL_BAGS];
UInt nr;
} TNumGlobalBags;

extern TNumGlobalBags GlobalBags;



extern void SortGlobals( UInt byWhat );

extern Bag * GlobalByCookie(
const Char * cookie );


extern void StartRestoringBags( UInt nBags, UInt maxSize);


extern Bag NextBagRestoring( UInt type, UInt flags, UInt size );


extern void FinishedRestoringBags( void );


/****************************************************************************
**
*F CheckMasterPointers() . . . . . . . . . . . . do some consistency checks
**
** 'CheckMasterPointers' tests for masterpointers which are not one of the
** following:
**
** 0 denoting the end of the free chain
** NewWeakDeadBagMarker denoting the relic of a bag that was weakly
** OldWeakDeadBagMarker but not strongly linked at the last garbage
** collection
** a pointer into the masterpointer area a link on the free chain
** a pointer into the bags area a real object
**
*/
extern void CheckMasterPointers( void );


/****************************************************************************
**
*F CallbackForAllBags( <func> ) call a C function on all non-zero mptrs
**
** This calls a C function on every bag, including ones that are not
** reachable from the root, and will be deleted at the next garbage
** collection, by simply walking the masterpointer area. Not terribly safe.
**
*/
extern void CallbackForAllBags( void (*func)(Bag) );


#endif
7 changes: 5 additions & 2 deletions src/opers.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include "calls.h"
#include "error.h"
#include "gapstate.h"
#ifdef USE_GASMAN
#include "gasman_intern.h"
#endif
#include "gvars.h"
#include "io.h"
#include "lists.h"
Expand Down Expand Up @@ -1650,7 +1653,7 @@ static void HandleMethodNotFound(Obj oper,
**
*/

#ifdef GASMAN
#ifdef USE_GASMAN

static Obj FLUSH_ALL_METHOD_CACHES;

Expand All @@ -1670,7 +1673,7 @@ static void FixTypeIDs( Bag b ) {

Obj FuncCOMPACT_TYPE_IDS( Obj self )
{
#ifdef GASMAN
#ifdef USE_GASMAN
NextTypeID = INT_INTOBJ_MIN;
CallbackForAllBags( FixTypeIDs );
CALL_0ARGS(FLUSH_ALL_METHOD_CACHES);
Expand Down
7 changes: 2 additions & 5 deletions src/plist.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
** list, and so on. If the physical length of a list is greater than the
** logical, there will be unused entries at the end of the list, comtaining
** 0. The physical length might be greater than the logical, because the
** physical size of a list is increased by at least 12.5\%, to avoid doing
** physical size of a list is increased by at least 25\%, to avoid doing
** this too often.
**
** This representation is encoded by the macros 'NEW_PLIST', 'GROW_PLIST',
Expand Down Expand Up @@ -62,7 +62,7 @@
*F GROW_PLIST(<list>,<plen>) . . . . make sure a plain list is large enough
**
*/
Int GrowPlist (
void GrowPlist (
Obj list,
UInt need )
{
Expand All @@ -83,9 +83,6 @@ Int GrowPlist (

/* resize the plain list */
ResizeBag( list, ((plen)+1)*sizeof(Obj) );

/* return something (to please some C compilers) */
return 0L;
}


Expand Down
2 changes: 1 addition & 1 deletion src/plist.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static inline Int CAPACITY_PLIST(Obj list)
return SIZE_OBJ(list) / sizeof(Obj) - 1;
}

extern Int GrowPlist (
extern void GrowPlist (
Obj list,
UInt need );

Expand Down
3 changes: 3 additions & 0 deletions src/saveload.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#include "compstat.h"
#include "error.h"
#include "finfield.h"
#ifdef USE_GASMAN
#include "gasman_intern.h"
#endif
#include "gvars.h"
#include "io.h"
#include "modules.h"
Expand Down
Loading