Factor 0.76:
------------
-+ Core language
++ Runtime and core library:
+
+- The number of generations used for garbage collection can now be set
+ with the +G command line switch; eg, +G3 is the default. You must
+ specify at least 2 generations.
- New words:
void collect_cards(CELL gen)
{
int i;
- for(i = gen + 1; i < GC_GENERATIONS; i++)
+ for(i = gen + 1; i < gc_generations; i++)
collect_gen_cards(i);
}
void dump_generations(void)
{
int i;
- for(i = 0; i < GC_GENERATIONS; i++)
+ for(i = 0; i < gc_generations; i++)
{
fprintf(stderr,"Generation %d: ",i);
dump_generation(&generations[i]);
#include "factor.h"
void init_factor(char* image, CELL ds_size, CELL cs_size,
+ CELL generations,
CELL young_size, CELL aging_size,
CELL code_size, CELL literal_size)
{
/* initialize random number generator */
srand((unsigned)time(NULL));
init_ffi();
- init_arena(young_size,aging_size);
+ init_arena(generations,young_size,aging_size);
init_compiler(code_size);
load_image(image,literal_size);
init_stacks(ds_size,cs_size);
init_errors();
userenv[CPU_ENV] = tag_object(from_c_string(FACTOR_CPU_STRING));
userenv[OS_ENV] = tag_object(from_c_string(FACTOR_OS_STRING));
- userenv[GEN_ENV] = tag_fixnum(GC_GENERATIONS);
+ userenv[GEN_ENV] = tag_fixnum(gc_generations);
userenv[CARD_OFF_ENV] = tag_cell(cards_offset);
}
{
CELL ds_size = 2048;
CELL cs_size = 2048;
+ CELL generations = 3;
CELL young_size = 8;
CELL aging_size = 16;
CELL code_size = 2;
printf("Runtime options -- n is a number:\n");
printf(" +Dn Data stack size, kilobytes\n");
printf(" +Cn Call stack size, kilobytes\n");
- printf(" +Yn Size of %d youngest generations, megabytes\n",
- GC_GENERATIONS-1);
+ printf(" +Gn Number of generations, must be >= 2\n");
+ printf(" +Yn Size of n-1 youngest generations, megabytes\n");
printf(" +An Size of tenured and semi-spaces, megabytes\n");
printf(" +Xn Code heap size, megabytes\n");
printf(" +Ln Literal table size, kilobytes. Only for bootstrapping\n");
{
if(factor_arg(argv[i],"+D%d",&ds_size)) continue;
if(factor_arg(argv[i],"+C%d",&cs_size)) continue;
+ if(factor_arg(argv[i],"+G%d",&generations)) continue;
if(factor_arg(argv[i],"+Y%d",&young_size)) continue;
if(factor_arg(argv[i],"+A%d",&aging_size)) continue;
if(factor_arg(argv[i],"+X%d",&code_size)) continue;
init_factor(argv[1],
ds_size * 1024,
cs_size * 1024,
+ generations,
young_size * 1024 * 1024,
aging_size * 1024 * 1024,
code_size * 1024 * 1024,
- the nursery grows into the guard page, so allot() does not have to
check for out of memory, whereas allot_zone() (used by the GC) longjmp()s
back to collecting a higher generation */
-void init_arena(CELL young_size, CELL aging_size)
+void init_arena(CELL gen_count, CELL young_size, CELL aging_size)
{
int i;
CELL alloter;
- CELL total_size = (GC_GENERATIONS - 1) * young_size + 2 * aging_size;
+ CELL total_size = (gc_generations - 1) * young_size + 2 * aging_size;
CELL cards_size = total_size / CARD_SIZE;
+ gc_generations = gen_count;
+ generations = malloc(sizeof(ZONE) * gen_count);
+
heap_start = (CELL)alloc_guarded(total_size);
heap_end = heap_start + total_size;
alloter = init_zone(&tenured,aging_size,alloter);
alloter = init_zone(&prior,aging_size,alloter);
- for(i = GC_GENERATIONS - 2; i >= 0; i--)
+ for(i = gc_generations - 2; i >= 0; i--)
alloter = init_zone(&generations[i],young_size,alloter);
clear_cards(NURSERY,TENURED);
} ZONE;
/* total number of generations. */
-#define GC_GENERATIONS 3
+CELL gc_generations;
+
/* the 0th generation is where new objects are allocated. */
#define NURSERY 0
/* the oldest generation */
-#define TENURED (GC_GENERATIONS-1)
+#define TENURED (gc_generations-1)
-ZONE generations[GC_GENERATIONS];
+ZONE *generations;
/* used during garbage collection only */
ZONE *newspace;
CELL init_zone(ZONE *z, CELL size, CELL base);
-void init_arena(CELL young_size, CELL aging_size);
+void init_arena(CELL gen_count, CELL young_size, CELL aging_size);
/* statistics */
s64 gc_time;
box_signed_cell(compiling.limit - compiling.base);
box_signed_cell(cards_end - cards);
box_signed_cell(prior.limit - prior.base);
- for(gen = GC_GENERATIONS - 1; gen >= 0; gen--)
+ for(gen = gc_generations - 1; gen >= 0; gen--)
{
ZONE *z = &generations[gen];
list = cons(cons(
#define ERROR_ENV 12 /* a marker consed onto kernel errors */
#define IN_ENV 13
#define OUT_ENV 14
-#define GEN_ENV 15 /* set to GC_GENERATIONS constant */
+#define GEN_ENV 15 /* set to gc_generations */
/* TAGGED user environment data; see getenv/setenv prims */
DLLEXPORT CELL userenv[USER_ENV];