diff options
| author | Keith Packard <keithp@keithp.com> | 2017-12-14 23:04:39 -0800 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2017-12-14 23:04:39 -0800 | 
| commit | 32f6877288ea6b7eb1cae9a42fbe8e2c5dbb2f08 (patch) | |
| tree | 4e23989a62ae144b8cbf1d2fd135ca8a6bd743dc /src/scheme/ao_scheme_mem.c | |
| parent | 2e11cae044cd2c053049effd76df9c5adecb84d7 (diff) | |
altos/scheme: swap BIGINT and STRING types
This lets BIGINT be a primitive type, allowing it to use all 32 bits
for storage. This does make strings another byte longer, and also
slightly harder to deal with. It's a trade off.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/scheme/ao_scheme_mem.c')
| -rw-r--r-- | src/scheme/ao_scheme_mem.c | 25 | 
1 files changed, 17 insertions, 8 deletions
| diff --git a/src/scheme/ao_scheme_mem.c b/src/scheme/ao_scheme_mem.c index afa06d54..e7e89b89 100644 --- a/src/scheme/ao_scheme_mem.c +++ b/src/scheme/ao_scheme_mem.c @@ -178,7 +178,7 @@ struct ao_scheme_root {  };  static struct ao_scheme_cons 	*save_cons[2]; -static char			*save_string[2]; +static struct ao_scheme_string	*save_string[2];  static struct ao_scheme_frame	*save_frame[1];  static ao_poly			save_poly[3]; @@ -488,7 +488,9 @@ dump_busy(void)  static const struct ao_scheme_type * const ao_scheme_types[AO_SCHEME_NUM_TYPE] = {  	[AO_SCHEME_CONS] = &ao_scheme_cons_type,  	[AO_SCHEME_INT] = NULL, -	[AO_SCHEME_STRING] = &ao_scheme_string_type, +#ifdef AO_SCHEME_FEATURE_BIGINT +	[AO_SCHEME_BIGINT] = &ao_scheme_bigint_type, +#endif  	[AO_SCHEME_OTHER] = (void *) 0x1,  	[AO_SCHEME_ATOM] = &ao_scheme_atom_type,  	[AO_SCHEME_BUILTIN] = &ao_scheme_builtin_type, @@ -497,9 +499,7 @@ static const struct ao_scheme_type * const ao_scheme_types[AO_SCHEME_NUM_TYPE] =  	[AO_SCHEME_LAMBDA] = &ao_scheme_lambda_type,  	[AO_SCHEME_STACK] = &ao_scheme_stack_type,  	[AO_SCHEME_BOOL] = &ao_scheme_bool_type, -#ifdef AO_SCHEME_FEATURE_BIGINT -	[AO_SCHEME_BIGINT] = &ao_scheme_bigint_type, -#endif +	[AO_SCHEME_STRING] = &ao_scheme_string_type,  #ifdef AO_SCHEME_FEATURE_FLOAT  	[AO_SCHEME_FLOAT] = &ao_scheme_float_type,  #endif @@ -533,6 +533,7 @@ uint64_t ao_scheme_loops[2];  #endif  int ao_scheme_last_top; +int ao_scheme_collect_counts;  int  ao_scheme_collect(uint8_t style) @@ -556,6 +557,14 @@ ao_scheme_collect(uint8_t style)  	if (ao_scheme_last_top == 0)  		style = AO_SCHEME_COLLECT_FULL; +	/* One in a while, just do a full collect */ + +	if (ao_scheme_collect_counts >= 128) +		style = AO_SCHEME_COLLECT_FULL; + +	if (style == AO_SCHEME_COLLECT_FULL) +		ao_scheme_collect_counts = 0; +  	/* Clear references to all caches */  	for (i = 0; i < (int) AO_SCHEME_CACHE; i++)  		*ao_scheme_cache[i] = NULL; @@ -984,16 +993,16 @@ ao_scheme_poly_fetch(int id)  }  void -ao_scheme_string_stash(int id, char *string) +ao_scheme_string_stash(int id, struct ao_scheme_string *string)  {  	assert(save_string[id] == NULL);  	save_string[id] = string;  } -char * +struct ao_scheme_string *  ao_scheme_string_fetch(int id)  { -	char *string = save_string[id]; +	struct ao_scheme_string *string = save_string[id];  	save_string[id] = NULL;  	return string;  } | 
