Skip to content

Commit

Permalink
kernel: change pcp collector to use their own stacks
Browse files Browse the repository at this point in the history
... instead of using the stack objects in the pcp collector objects provided
by the polycyclic package. This will make it possible to remove the latter in
a future version of polycyclic, thus reducing the size of these objects
considerably.
  • Loading branch information
fingolfin committed May 13, 2018
1 parent 747105a commit 6c1410f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
35 changes: 29 additions & 6 deletions src/objcftl.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,28 @@

#include <src/ariths.h>
#include <src/error.h>
#include <src/gapstate.h>
#include <src/gvars.h>
#include <src/integer.h>
#include <src/modules.h>
#include <src/plist.h>


static ModuleStateOffset CFTLStateOffset = -1;

struct CFTLModuleState {
Obj WORD_STACK;
Obj WORD_EXPONENT_STACK;
Obj SYLLABLE_STACK;
Obj EXPONENT_STACK;
};

extern inline struct CFTLModuleState *CFTLState(void)
{
return (struct CFTLModuleState *)StateSlotsAtOffset(CFTLStateOffset);
}


#define IS_INT_ZERO( n ) ((n) == INTOBJ_INT(0))

#define GET_COMMUTE( g ) INT_INTOBJ(ELM_PLIST(commute,(g)))
Expand Down Expand Up @@ -87,14 +103,14 @@ Obj CollectPolycyc (
Obj ipow = ADDR_OBJ(pcp)[ PC_INVERSEPOWERS ];
Obj exp = ADDR_OBJ(pcp)[ PC_EXPONENTS ];

Obj wst = ADDR_OBJ(pcp)[ PC_WORD_STACK ];
Obj west = ADDR_OBJ(pcp)[ PC_WORD_EXPONENT_STACK ];
Obj sst = ADDR_OBJ(pcp)[ PC_SYLLABLE_STACK ];
Obj est = ADDR_OBJ(pcp)[ PC_EXPONENT_STACK ];
Obj wst = CFTLState()->WORD_STACK;
Obj west = CFTLState()->WORD_EXPONENT_STACK;
Obj sst = CFTLState()->SYLLABLE_STACK;
Obj est = CFTLState()->EXPONENT_STACK;

Obj conj=0, iconj=0; /*QQ initialize to please compiler */

Int st, bottom = INT_INTOBJ( ADDR_OBJ(pcp)[ PC_STACK_POINTER ] );
Int st, bottom = 0;

Int g, syl, h, hh;

Expand Down Expand Up @@ -296,7 +312,6 @@ Obj CollectPolycyc (
}
}

ADDR_OBJ(pcp)[ PC_STACK_POINTER ] = INTOBJ_INT( bottom );
return (Obj)0;
}

Expand Down Expand Up @@ -394,6 +409,13 @@ static Int InitLibrary (
return 0;
}

static void InitModuleState(ModuleStateOffset offset)
{
CFTLState()->WORD_STACK = NEW_PLIST( T_PLIST, 4096 );
CFTLState()->WORD_EXPONENT_STACK = NEW_PLIST( T_PLIST, 4096 );
CFTLState()->SYLLABLE_STACK = NEW_PLIST( T_PLIST, 4096 );
CFTLState()->EXPONENT_STACK = NEW_PLIST( T_PLIST, 4096 );
}

/****************************************************************************
**
Expand All @@ -411,5 +433,6 @@ static StructInitInfo module = {

StructInitInfo * InitInfoPcc ( void )
{
CFTLStateOffset = RegisterModuleState(sizeof(struct CFTLModuleState), InitModuleState, 0);
return &module;
}
21 changes: 21 additions & 0 deletions src/objcftl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,35 @@
#define PC_DEEP_THOUGHT_BOUND 13
#define PC_ORDERS 14

// TODO: the following stack related positions are not
// used anymore by CollectPolycyc, and will not be used
// anymore in future releases of the polycyclic package.
// We should phase them out for GAP 4.10.
#define PC_WORD_STACK 15
#define PC_STACK_SIZE 16
#define PC_WORD_EXPONENT_STACK 17
#define PC_SYLLABLE_STACK 18
#define PC_EXPONENT_STACK 19
#define PC_STACK_POINTER 20
// TODO: end obsolete

#define PC_DEFAULT_TYPE 21

/* the following are defined in polycyclic:
#define PC_PCP_ELEMENTS_FAMILY 22
#define PC_PCP_ELEMENTS_TYPE 23
#define PC_COMMUTATORS 24
#define PC_INVERSECOMMUTATORS 25
#define PC_COMMUTATORSINVERSE 26
#define PC_INVERSECOMMUTATORSINVERSE 27
#define PC_NILPOTENT_COMMUTE 28
#define PC_WEIGHTS 29
#define PC_ABELIAN_START 30
*/

/****************************************************************************
**
*F * * * * * * * * * * * * * initialize module * * * * * * * * * * * * * * *
Expand Down

0 comments on commit 6c1410f

Please sign in to comment.