Skip to content

Commit

Permalink
kernel: remove some unused blist/plist code
Browse files Browse the repository at this point in the history
* remove PLEN_SIZE_BLIST (unused)
* remove IS_BLIST_REP_WITH_COPYING (use IS_BLIST_REP instead)
* change IS_PLIST_OR_POSOBJ to not support COPYING flag

For the latter two, it is unclear to me why they ever dealt with COPYING
objects: as far as I can tell, such objects are never accessed with
anything but raw (CONST_)ADDR_OBJ() calls.
  • Loading branch information
fingolfin committed Aug 13, 2018
1 parent bd836cb commit 9b15b10
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/blister.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
** This package consists of three parts.
**
** The first part consists of the macros 'BIPEB', 'SIZE_PLEN_BLIST',
** 'PLEN_SIZE_BLIST', 'LEN_BLIST', 'SET_LEN_BLIST', 'ELM_BLIST', and
** 'SET_ELM_BLIST'. They determine the representation of boolean lists.
** 'LEN_BLIST', 'SET_LEN_BLIST', 'ELM_BLIST', and 'SET_ELM_BLIST'. They
** determine the representation of boolean lists.
** The rest of the {\GAP} kernel uses those macros to access and modify
** boolean lists.
**
Expand Down
40 changes: 3 additions & 37 deletions src/blister.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,6 @@ static inline Int IS_BLIST_REP(Obj list)
TNUM_OBJ(list) <= T_BLIST_SSORT + IMMUTABLE;
}

/****************************************************************************
**
*F IS_BLIST_REP_WITH_COPYING( <list> ) . . . . .check if <list> is a blist
**
** This version of IS_PLIST also checks if 'COPYING' is set, which happens
** during copying of object. This is only used in assertion checks, as it is
** a (little) slower.
*/

static inline Int IS_BLIST_REP_WITH_COPYING(Obj list)
{
UInt tnum = TNUM_OBJ(list);
#if !defined(USE_THREADSAFE_COPYING)
if (tnum > COPYING)
tnum -= COPYING;
#endif
return T_BLIST <= tnum && tnum <= T_BLIST_SSORT + IMMUTABLE;
}

/****************************************************************************
**
*F PLEN_SIZE_BLIST( <size> ) . physical length from size for a boolean list
**
** 'PLEN_SIZE_BLIST' computes the physical length (e.g. the number of
** elements that could be stored in a list) from the <size> (as reported by
** 'SIZE') for a boolean list.
**
*/
static inline Int PLEN_SIZE_BLIST(Int size)
{
GAP_ASSERT(size >= 0);
return ((size - sizeof(Obj)) / sizeof(UInt)) * BIPEB;
}


/****************************************************************************
**
Expand All @@ -92,7 +58,7 @@ static inline Int SIZE_PLEN_BLIST(Int plen)
*/
static inline Int LEN_BLIST(Obj list)
{
GAP_ASSERT(IS_BLIST_REP_WITH_COPYING(list));
GAP_ASSERT(IS_BLIST_REP(list));
return INT_INTOBJ(CONST_ADDR_OBJ(list)[0]);
}

Expand All @@ -104,7 +70,7 @@ static inline Int LEN_BLIST(Obj list)
*/
static inline Int NUMBER_BLOCKS_BLIST(Obj blist)
{
GAP_ASSERT(IS_BLIST_REP_WITH_COPYING(blist));
GAP_ASSERT(IS_BLIST_REP(blist));
return (LEN_BLIST(blist) + BIPEB - 1) / BIPEB;
}

Expand All @@ -119,7 +85,7 @@ static inline Int NUMBER_BLOCKS_BLIST(Obj blist)
*/
static inline void SET_LEN_BLIST(Obj list, Int len)
{
GAP_ASSERT(IS_BLIST_REP_WITH_COPYING(list));
GAP_ASSERT(IS_BLIST_REP(list));
GAP_ASSERT(len >= 0);
ADDR_OBJ(list)[0] = INTOBJ_INT(len);
}
Expand Down
2 changes: 0 additions & 2 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ VoidFunc debug_func_pointers[] = {
(VoidFunc)INT_INTOBJ,
(VoidFunc)INTOBJ_INT,
(VoidFunc)IS_BLIST_REP,
(VoidFunc)IS_BLIST_REP_WITH_COPYING,
(VoidFunc)IS_DENSE_LIST,
(VoidFunc)IS_DENSE_PLIST,
(VoidFunc)IS_FFE,
Expand Down Expand Up @@ -192,7 +191,6 @@ VoidFunc debug_func_pointers[] = {
(VoidFunc)NUM_RAT,
(VoidFunc)NUMBER_BLOCKS_BLIST,
(VoidFunc)PLAIN_LIST,
(VoidFunc)PLEN_SIZE_BLIST,
(VoidFunc)PopPlist,
(VoidFunc)POS_LIST,
(VoidFunc)PROF_FUNC,
Expand Down
7 changes: 1 addition & 6 deletions src/plist.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,13 @@ static inline Int IS_PLIST(Obj list)
** This function is used in a GAP_ASSERT checking if calling functions like
** SET_ELM_PLIST is acceptable on an Obj.
**
** Unlike IS_PLIST, this function also accepts plists which are being copied
** (and hence have the COPYING flag set), as well as positional objects
** Unlike IS_PLIST, this function also accepts positional objects
** (which have the same memory layout as plists), as the plist APIs using it
** for assertion checks are in practice invoked on such objects, too.
*/
static inline Int IS_PLIST_OR_POSOBJ(Obj list)
{
UInt tnum = TNUM_OBJ(list);
#if !defined(USE_THREADSAFE_COPYING)
if (tnum > COPYING)
tnum -= COPYING;
#endif
return (FIRST_PLIST_TNUM <= tnum && tnum <= LAST_PLIST_TNUM) ||
tnum == T_POSOBJ;
}
Expand Down

0 comments on commit 9b15b10

Please sign in to comment.