Date: Thu, 23 Jul 2015 19:20:00 GMT From: clord@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r288708 - soc2015/clord/head/sys/contrib/ficl Message-ID: <201507231920.t6NJK02i052018@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: clord Date: Thu Jul 23 19:19:59 2015 New Revision: 288708 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=288708 Log: Add the ficlDictionaryCheckThreshold function into Ficl 4 source. Was previously named dictCheckThreshold, but the name, as well as some of the types, were renamed to match the Ficl 4 sources better. Modified: soc2015/clord/head/sys/contrib/ficl/dictionary.c soc2015/clord/head/sys/contrib/ficl/ficl.h soc2015/clord/head/sys/contrib/ficl/ficlcompatibility.h soc2015/clord/head/sys/contrib/ficl/primitives.c Modified: soc2015/clord/head/sys/contrib/ficl/dictionary.c ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/dictionary.c Thu Jul 23 19:14:32 2015 (r288707) +++ soc2015/clord/head/sys/contrib/ficl/dictionary.c Thu Jul 23 19:19:59 2015 (r288708) @@ -64,6 +64,10 @@ #define FICL_SAFE_SYSTEM_FROM_DICTIONARY(dictionary) (((dictionary) != NULL) ? (dictionary)->system : NULL) #define FICL_DICTIONARY_ASSERT(dictionary, expression) FICL_SYSTEM_ASSERT(FICL_SAFE_SYSTEM_FROM_DICTIONARY(dictionary), expression) +/* Dictionary on-demand resizing control variables */ +CELL dictThreshold; +CELL dictIncrease; + /************************************************************************** d i c t A b o r t D e f i n i t i o n ** Abort a definition in process: reclaim its memory and unlink it @@ -627,6 +631,24 @@ /************************************************************************** + d i c t C h e c k T h r e s h o l d +** Verify if an increase in the dictionary size is warranted, and do it if +** so. +**************************************************************************/ + +void ficlDictionaryCheckThreshold(ficlDictionary *dictionary) +{ + if( dictCellsAvail(dictionary) < dictThreshold.u ) { + dictionary->base = ficlMalloc( dictIncrease.u * sizeof (CELL) ); + assert(dictionary->base); + dictionary->here = dictionary->base; + dictionary->size = dictIncrease.u; + dictAlign(dictionary); + } +} + + +/************************************************************************** s e e ** TOOLS ( "<spaces>name" -- ) ** Display a human-readable representation of the named word's definition. Modified: soc2015/clord/head/sys/contrib/ficl/ficl.h ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/ficl.h Thu Jul 23 19:14:32 2015 (r288707) +++ soc2015/clord/head/sys/contrib/ficl/ficl.h Thu Jul 23 19:19:59 2015 (r288708) @@ -1423,7 +1423,7 @@ int wordlistCount; unsigned size; /* Number of cells in dictionary (total)*/ ficlSystem *system; /* used for debugging */ - ficlCell base[1]; /* Base of dictionary memory */ + ficlCell *base; /* Base of dictionary memory */ }; FICL_PLATFORM_EXTERN void ficlDictionaryAbortDefinition(ficlDictionary *dictionary); @@ -1484,6 +1484,7 @@ FICL_PLATFORM_EXTERN int ficlDictionaryCellsAvailable (ficlDictionary *dictionary); FICL_PLATFORM_EXTERN int ficlDictionaryCellsUsed (ficlDictionary *dictionary); +FICL_PLATFORM_EXTERN void ficlDictionaryCheckThreshold(ficlDictionary *dictionary); FICL_PLATFORM_EXTERN ficlDictionary *ficlDictionaryCreate(ficlSystem *system, unsigned nCELLS); FICL_PLATFORM_EXTERN ficlDictionary *ficlDictionaryCreateHashed(ficlSystem *system, unsigned nCells, unsigned nHash); FICL_PLATFORM_EXTERN ficlHash *ficlDictionaryCreateWordlist(ficlDictionary *dictionary, int nBuckets); Modified: soc2015/clord/head/sys/contrib/ficl/ficlcompatibility.h ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/ficlcompatibility.h Thu Jul 23 19:14:32 2015 (r288707) +++ soc2015/clord/head/sys/contrib/ficl/ficlcompatibility.h Thu Jul 23 19:19:59 2015 (r288708) @@ -312,7 +312,7 @@ int nLists; unsigned size; /* Number of cells in dict (total)*/ ficlSystem *system; - CELL dict[1]; /* Base of dictionary memory */ + CELL *dict; /* Base of dictionary memory */ }; void *alignPtr(void *ptr); Modified: soc2015/clord/head/sys/contrib/ficl/primitives.c ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/primitives.c Thu Jul 23 19:14:32 2015 (r288707) +++ soc2015/clord/head/sys/contrib/ficl/primitives.c Thu Jul 23 19:19:59 2015 (r288708) @@ -189,6 +189,8 @@ ficlDictionary *dictionary = ficlVmGetDictionary(vm); ficlString name = ficlVmGetWord(vm); + ficlDictionaryCheckThreshold(dictionary); + vm->state = FICL_VM_STATE_COMPILE; markControlTag(vm, colonTag); ficlDictionaryAppendWord(dictionary, name, (ficlPrimitive)ficlInstructionColonParen, FICL_WORD_DEFAULT | FICL_WORD_SMUDGED); @@ -1493,6 +1495,8 @@ ficlDictionary *dictionary = ficlVmGetDictionary(vm); ficlString name = ficlVmGetWord(vm); + ficlDictionaryCheckThreshold(dictionary); + ficlDictionaryAppendWord(dictionary, name, (ficlPrimitive)ficlInstructionCreateParen, FICL_WORD_DEFAULT); ficlVmDictionaryAllotCells(vm, dictionary, 1); return;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507231920.t6NJK02i052018>