Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move MarkBag* funcs into GCs so they can inline MarkBag #3840

Merged
merged 1 commit into from
Jan 10, 2020
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
47 changes: 0 additions & 47 deletions src/bags.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,50 +52,3 @@ void RetypeBagSMIfWritable(Bag bag, UInt new_type)
RetypeBagIfWritable(bag, new_type);
}
#endif


inline void MarkArrayOfBags(const Bag array[], UInt count)
{
for (UInt i = 0; i < count; i++) {
MarkBag(array[i]);
}
}

void MarkNoSubBags(Bag bag)
{
}

void MarkOneSubBags(Bag bag)
{
MarkArrayOfBags(CONST_PTR_BAG(bag), 1);
}

void MarkTwoSubBags(Bag bag)
{
MarkArrayOfBags(CONST_PTR_BAG(bag), 2);
}

void MarkThreeSubBags(Bag bag)
{
MarkArrayOfBags(CONST_PTR_BAG(bag), 3);
}

void MarkFourSubBags(Bag bag)
{
MarkArrayOfBags(CONST_PTR_BAG(bag), 4);
}

void MarkAllSubBags(Bag bag)
{
MarkArrayOfBags(CONST_PTR_BAG(bag), SIZE_BAG(bag) / sizeof(Bag));
}

void MarkAllButFirstSubBags(Bag bag)
{
MarkArrayOfBags(CONST_PTR_BAG(bag) + 1, SIZE_BAG(bag) / sizeof(Bag) - 1);
}

void MarkAllSubBagsDefault(Bag bag)
{
MarkArrayOfBags(CONST_PTR_BAG(bag), SIZE_BAG(bag) / sizeof(Bag));
}
62 changes: 62 additions & 0 deletions src/bags.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/****************************************************************************
**
** This file is part of GAP, a system for computational discrete algebra.
**
** Copyright of GAP belongs to its developers, whose names are too numerous
** to list here. Please refer to the COPYRIGHT file for details.
**
** SPDX-License-Identifier: GPL-2.0-or-later
**
** This file includes functions which are required by all GCs. For efficiency
** it is important these are defined in the same file as "MarkBag", so
** this file should be #included in each GC implementation.
*/

#include "error.h"
#include "gasman.h"

void MarkArrayOfBags(const Bag array[], UInt count)
{
for (UInt i = 0; i < count; i++) {
MarkBag(array[i]);
}
}

void MarkNoSubBags(Bag bag)
{
}

void MarkOneSubBags(Bag bag)
{
MarkArrayOfBags(CONST_PTR_BAG(bag), 1);
}

void MarkTwoSubBags(Bag bag)
{
MarkArrayOfBags(CONST_PTR_BAG(bag), 2);
}

void MarkThreeSubBags(Bag bag)
{
MarkArrayOfBags(CONST_PTR_BAG(bag), 3);
}

void MarkFourSubBags(Bag bag)
{
MarkArrayOfBags(CONST_PTR_BAG(bag), 4);
}

void MarkAllSubBags(Bag bag)
{
MarkArrayOfBags(CONST_PTR_BAG(bag), SIZE_BAG(bag) / sizeof(Bag));
}

void MarkAllButFirstSubBags(Bag bag)
{
MarkArrayOfBags(CONST_PTR_BAG(bag) + 1, SIZE_BAG(bag) / sizeof(Bag) - 1);
}

void MarkAllSubBagsDefault(Bag bag)
{
MarkArrayOfBags(CONST_PTR_BAG(bag), SIZE_BAG(bag) / sizeof(Bag));
}
2 changes: 2 additions & 0 deletions src/boehm_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "objects.h"
#include "sysmem.h"

#include "bags.inc"

#ifdef TRACK_CREATOR
#include "calls.h"
#include "vars.h"
Expand Down
2 changes: 2 additions & 0 deletions src/gasman.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@
#include "sysjmp.h"
#include "sysmem.h"

#include "bags.inc"

#ifdef GAP_MEM_CHECK
#include <sys/mman.h>
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/julia_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "sysmem.h"
#include "vars.h"

#include "bags.inc"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down