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

A bunch of HPC-GAP fixes by Reimer #3742

Merged
merged 6 commits into from
Nov 14, 2019
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
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,10 @@ AS_IF([test "x$enable_hpcgap" = xyes],[
AC_DEFINE([GAP_PRINT_BACKTRACE], [1], [to enable backtraces upon crashes])
])

AS_IF([test "x$enable_macos_tls_asm" = xno],[
AS_BOX([WARNING: macOS fast thread-local storage not available])
])

dnl
dnl Output everything
dnl
Expand Down
2 changes: 1 addition & 1 deletion lib/info.gi
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ end );
SHOWN_USED_INFO_CLASSES := [];

if IsHPCGAP then
ShareInternalObj(INFO_CLASSES);
ShareInternalObj(SHOWN_USED_INFO_CLASSES);
fi;


Expand Down
31 changes: 4 additions & 27 deletions src/boehm_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "hpc/thread.h"
#endif

#ifndef WARD_ENABLED

static inline Bag * DATA(BagHeader * bag)
{
return (Bag *)(((char *)bag) + sizeof(BagHeader));
Expand All @@ -54,20 +56,6 @@ void MakeBagTypePublic(int type)
DSInfoBags[type] = DSI_PUBLIC;
}

Bag MakeBagPublic(Bag bag)
{
MEMBAR_WRITE();
SET_REGION(bag, 0);
return bag;
}

Bag MakeBagReadOnly(Bag bag)
{
MEMBAR_WRITE();
SET_REGION(bag, ReadOnlyRegion);
return bag;
}

#endif // HPCGAP


Expand All @@ -83,8 +71,6 @@ void InitFreeFuncBag(UInt type, TNumFreeFuncBags finalizer_func)
TabFreeFuncBags[type] = finalizer_func;
}

#ifndef WARD_ENABLED

static void StandardFinalizer(void * bagContents, void * data)
{
Bag bag;
Expand All @@ -94,9 +80,6 @@ static void StandardFinalizer(void * bagContents, void * data)
TabFreeFuncBags[TNUM_BAG(bag)](bag);
}

#endif


static GC_descr GCDesc[MAX_GC_PREFIX_DESC + 1];
static unsigned GCKind[MAX_GC_PREFIX_DESC + 1];
static GC_descr GCMDesc[MAX_GC_PREFIX_DESC + 1];
Expand Down Expand Up @@ -335,14 +318,6 @@ UInt CollectBags(UInt size, UInt full)
return 1;
}

#ifdef HPCGAP
void RetypeBagIfWritable(Obj obj, UInt new_type)
{
if (CheckWriteAccess(obj))
RetypeBag(obj, new_type);
}
#endif

void RetypeBag(Bag bag, UInt new_type)
{
BagHeader * header = BAG_HEADER(bag);
Expand Down Expand Up @@ -551,3 +526,5 @@ void SwapMasterPoint(Bag bag1, Bag bag2)
SET_PTR_BAG(bag1, ptr2);
SET_PTR_BAG(bag2, ptr1);
}

#endif // WARD_ENABLED
22 changes: 21 additions & 1 deletion src/hpc/region.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

// #include "hpc/misc.h"
#include "hpc/thread.h"
// #include "hpc/guards.h"
#include "hpc/guards.h"


#include <pthread.h>
Expand Down Expand Up @@ -59,3 +59,23 @@ Region * RegionBag(Bag bag)
MEMBAR_READ();
return result;
}

Bag MakeBagPublic(Bag bag)
{
MEMBAR_WRITE();
SET_REGION(bag, 0);
return bag;
}

Bag MakeBagReadOnly(Bag bag)
{
MEMBAR_WRITE();
SET_REGION(bag, ReadOnlyRegion);
return bag;
}

void RetypeBagIfWritable(Obj obj, UInt new_type)
{
if (CheckWriteAccess(obj))
RetypeBag(obj, new_type);
}
12 changes: 10 additions & 2 deletions src/hpc/threadapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "modules.h"
#include "objects.h"
#include "plist.h"
#include "precord.h"
#include "read.h"
#include "records.h"
#include "set.h"
Expand Down Expand Up @@ -2008,8 +2009,15 @@ MigrateObjects(int count, Obj * objects, Region * target, int retype)
return 0;
}
}
for (i = 0; i < count; i++)
SET_REGION(objects[i], target);
// If we are migrating records to a region where they become immutable,
// they need to be sorted, as sorting upon access may prove impossible.
for (i = 0; i < count; i++) {
Obj obj = objects[i];
if (TNUM_OBJ(obj) == T_PREC) {
SortPRecRNam(obj, 0);
}
SET_REGION(obj, target);
}
return 1;
}

Expand Down
3 changes: 3 additions & 0 deletions src/opers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,7 @@ static inline Obj CacheOper(Obj oper, UInt i)
cache = NEW_PLIST(T_PLIST, len);
SET_LEN_PLIST(cache, len);
#ifdef HPCGAP
MakeBagPublic(cache);
SET_ELM_PLIST(STATE(MethodCache), cacheIndex, cache);
CHANGED_BAG(STATE(MethodCache));
#else
Expand All @@ -1599,6 +1600,7 @@ static UInt CacheMissStatistics[CACHE_SIZE + 1][7];
#endif


#ifndef WARD_ENABLED
// This function actually searches the cache. Normally it should be
// called with n a compile-time constant to allow the optimiser to tidy
// things up.
Expand Down Expand Up @@ -1684,6 +1686,7 @@ CacheMethod(Obj cacheBag, UInt n, Int prec, Obj * ids, Obj method)
cache[2 + i] = ids[i];
CHANGED_BAG(cacheBag);
}
#endif // WARD_ENABLED

static Obj ReturnTrue;
static Obj VMETHOD_PRINT_INFO;
Expand Down
8 changes: 8 additions & 0 deletions src/precord.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

#ifdef HPCGAP
#include "hpc/aobjects.h"
#include "hpc/guards.h"
#include "hpc/traverse.h"
#endif

Expand Down Expand Up @@ -238,7 +239,14 @@ UInt PositionPRec(Obj rec, UInt rnam, int cleanup)
UInt high = LEN_PREC(rec);
if (high > 0 && GET_RNAM_PREC(rec, high) > 0) {
/* DIRTY! Not everything sorted! */
#ifdef HPCGAP
// FIXME: Need to sort records before making them
// readonly or sharing them. This can be done in
// the traversal routines (in principle).
if (cleanup && CheckExclusiveWriteAccess(rec)) {
#else
if (cleanup) {
#endif
SortPRecRNam(rec,0);
} else {
/* We are not allowed to cleanup, so we live with it, we
Expand Down