// install the marking functions for (i = 0; i < NUM_TYPES; i++) {
TabMarkTypeBags[i] = -1;
} #ifndef DISABLE_GC #ifdef HPCGAP if (!getenv("GC_MARKERS")) { /* The Boehm GC does not have an API to set the number of *markersfortheparallelmarkandsweepimplementation, *soweusethedocumentedenvironmentvariableGC_MARKERS *instead.However,wedonotoverrideitifit'salready *set.
*/ staticchar marker_env_str[32]; unsigned num_markers = 2; if (!SyNumGCThreads)
SyNumGCThreads = SyNumProcessors; if (SyNumGCThreads) { if (SyNumGCThreads <= MAX_GC_THREADS)
num_markers = (unsigned)SyNumProcessors; else
num_markers = MAX_GC_THREADS;
}
sprintf(marker_env_str, "GC_MARKERS=%u", num_markers);
putenv(marker_env_str);
} #endif
GC_set_all_interior_pointers(0);
GC_set_handle_fork(1);
GC_init();
GC_set_free_space_divisor(1);
TLAllocatorInit();
GC_register_displacement(0);
GC_register_displacement(sizeof(BagHeader));
initial_size *= 1024; if (GC_get_heap_size() < initial_size)
GC_expand_hp(initial_size - GC_get_heap_size()); if (SyStorKill)
GC_set_max_heap_size(SyStorKill * 1024); #ifdef HPCGAP
AddGCRoots();
CreateMainRegion(); #else void * p = ActiveGAPState();
GC_add_roots(p, (char *)p + sizeof(GAPState)); #endif for (i = 0; i <= MAX_GC_PREFIX_DESC; i++) {
BuildPrefixGCDescriptor(i); /* This is necessary to initialize some internal structures
* in the garbage collector: */
GC_generic_malloc(sizeof(BagHeader) + i * sizeof(Bag), GCMKind[i]);
} #endif// DISABLE_GC
}
UInt TotalGCTime(void)
{ // TODO: implement this? However, this is non-trivial: while we can of // course measure how much time is spent in CollectBags(), I am not // aware of a way to decide whether an allocation registered trigger a // collection, and how long that took. return0;
}
/* If the size of an object is zero (such as an empty permutation), *andtheheadersizeisamultipleoftwicethewordsizeofthe *architecture,thenthemasterpointerwillactuallypointpast *theallocatedarea.Becausethiswouldresultintheobject *beingfreedprematurely,wewillallocateatleastoneextra *bytesothatthemasterpointeractuallypointstowithinan *allocatedmemoryarea.
*/ if (size == 0)
alloc_size++; /* While we use the Boehm GC without the "all interior pointers" *option,stackreferencestotheinteriorofanobjectwill *stillbevalidfromanyreferenceonthestack.Thiscanlead, *forexample,toa1GBstringneverbeingfreedifthere'san *integeronthestackthathappenstoalsobeareferenceto *anycharacterinsidethatstring.Thegarbagecollectordoes *thisbecauseaftercompileroptimizations(especiallyreduction *instrength)referencestothebeginningofanobjectmaybe *lost. * *However,thisisnotgenerallyariskwithGAPobjects,because *masterpointersontheheapwillalwaysretainareferenceto *thestartoftheobject(or,moreprecisely,tothefirstbyte *pasttheheaderarea).Hence,compileroptimizationsposeno *actualriskunlessthemasterpointerisdestroyedalso. * *Toavoidthescenariowherelargeobjectsdonotgetdeallocated, *wethereforeusethe_ignore_off_page()calls.Onecaveathere *isthatthesecallsdonotusethread-localallocation,making *themsomewhatslower.Hence,weonlyusethemforsufficiently *largeobjects.
*/
BagHeader * header =
AllocateBagMemory(TabMarkTypeBags[type], type, alloc_size); #else
bag = malloc(sizeof(struct OpaqueBag));
BagHeader * header = calloc(1, alloc_size); #endif// DISABLE_GC
// set the masterpointer
SET_PTR_BAG(bag, DATA(header)); #ifdef HPCGAP switch (DSInfoBags[type]) { case DSI_TL:
SET_REGION(bag, CurrentRegion()); break; case DSI_PUBLIC:
SET_REGION(bag, NULL); break;
} #endif
// return the identifier of the new bag return bag;
}
UInt ResizeBag(Bag bag, UInt new_size)
{
UInt type; // type of the bag
UInt flags;
UInt old_size; // old size of the bag
Bag * src; // source in copying
UInt alloc_size;
// check the size
#ifdef TREMBLE_HEAP
CollectBags(0, 0); #endif
BagHeader * header = BAG_HEADER(bag);
// get type and old size of the bag
type = header->type;
flags = header->flags;
old_size = header->size;
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.16Bemerkung:
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.