Exemple #1
0
static void load_code_heap(FILE *file, image_header *h, vm_parameters *p)
{
	cell good_size = h->code_size + (1 << 19);

	if(good_size > p->code_size)
		p->code_size = good_size;

	init_code_heap(p->code_size);

	if(h->code_size != 0)
	{
		size_t bytes_read = fread(first_block(&code),1,h->code_size,file);
		if(bytes_read != h->code_size)
		{
			print_string("truncated image: ");
			print_fixnum(bytes_read);
			print_string(" bytes read, ");
			print_cell(h->code_size);
			print_string(" bytes expected\n");
			fatal_error("load_code_heap failed",0);
		}
	}

	code_relocation_base = h->code_relocation_base;
	build_free_list(&code,h->code_size);
}
Exemple #2
0
int
bullet_start()
{
    long	free;		/* # units of resource still free */

    /* Now that we can start ... */
    message("BULLET SERVER STARTUP");

    if (a_begin(A_DISKBLOCKS, (Res_addr) Superblock.s_inodetop + 1,
				    (Res_addr) Superblock.s_numblocks) < 0)
    {
	bpanic("Cannot begin resource allocator for disk blocks.\n");
    }

    /* Convert file get-port to put-port */
    priv2pub(&Superblock.s_fileport,&FilePutPort) ;

    /* Get the inode table and start inode allocator */
    /* Could have been done by setinodes() as a result of a welcome */
    if ( !Inode_table) inode_init();

    /* Work out which inodes and disk blocks are in use. */
    build_free_list();

    message("%ld inodes free, %ld inodes used",
				bs_local_inodes_free,
				- 1);
    if ((free = a_notused(A_DISKBLOCKS)) < 0) {
	bpanic("Defective diskblock free list\n");
    }
    message("%ld disk blocks free, %ld disk blocks used",
				free, Superblock.s_numblocks - free);
    return 1 ;
}
Exemple #3
0
/* After code GC, all referenced code blocks have status set to B_MARKED, so any
which are allocated and not marked can be reclaimed. */
void free_unmarked(F_HEAP *heap)
{
	F_BLOCK *prev = NULL;
	F_BLOCK *scan = first_block(heap);

	while(scan)
	{
		switch(scan->status)
		{
		case B_ALLOCATED:
			if(prev && prev->status == B_FREE)
				prev->size += scan->size;
			else
			{
				scan->status = B_FREE;
				prev = scan;
			}
			break;
		case B_FREE:
			if(prev && prev->status == B_FREE)
				prev->size += scan->size;
			break;
		case B_MARKED:
			scan->status = B_ALLOCATED;
			prev = scan;
			break;
		default:
			critical_error("Invalid scan->status",(CELL)scan);
		}

		scan = next_block(heap,scan);
	}

	build_free_list(heap,heap->segment->size);
}
Exemple #4
0
INLINE void load_code_heap(FILE *file, F_HEADER *h, F_PARAMETERS *p)
{
	CELL good_size = h->code_size + (1 << 19);

	if(good_size > p->code_size)
		p->code_size = good_size;

	init_code_heap(p->code_size);

	if(h->code_size != 0
		&& fread(first_block(&code_heap),h->code_size,1,file) != 1)
		fatal_error("load_code_heap failed",0);

	code_relocation_base = h->code_relocation_base;
	build_free_list(&code_heap,h->code_size);
}
Exemple #5
0
/* Move all free space to the end of the code heap. This is not very efficient,
since it makes several passes over the code and data heaps, but we only ever
do this before saving a deployed image and exiting, so performaance is not
critical here */
void compact_code_heap(void)
{
	/* Free all unreachable code blocks */
	gc();

	/* Figure out where the code heap blocks are going to end up */
	CELL size = compute_heap_forwarding(&code_heap);

	/* Update word and quotation code pointers */
	forward_object_xts();

	/* Actually perform the compaction */
	compact_heap(&code_heap);

	/* Update word and quotation XTs */
	fixup_object_xts();

	/* Now update the free list; there will be a single free block at
	the end */
	build_free_list(&code_heap,size);
}
Exemple #6
0
INLINE void load_code_heap(FILE *file, F_HEADER *h, F_PARAMETERS *p)
{
	CELL good_size = h->code_size + (1 << 19);

	if(good_size > p->code_size)
		p->code_size = good_size;

	init_code_heap(p->code_size);

	if(h->code_size != 0)
	{
		long int bytes_read = fread(first_block(&code_heap),1,h->code_size,file);
		if(bytes_read != h->code_size)
		{
			fprintf(stderr,"truncated image: %ld bytes read, %ld bytes expected\n",
				bytes_read,h->code_size);
			fatal_error("load_code_heap failed",0);
		}
	}

	code_relocation_base = h->code_relocation_base;
	build_free_list(&code_heap,h->code_size);
}