예제 #1
0
파일: image.cpp 프로젝트: leto/factor
static void fixup_code_block(code_block *compiled)
{
	/* relocate literal table data */
	data_fixup(&compiled->relocation);
	data_fixup(&compiled->literals);

	relocate_code_block(compiled);
}
예제 #2
0
파일: image.cpp 프로젝트: harold/factor
void factor_vm::fixup_code_block(code_block *compiled, cell data_relocation_base)
{
	/* relocate literal table data */
	data_fixup(&compiled->owner,data_relocation_base);
	data_fixup(&compiled->literals,data_relocation_base);
	data_fixup(&compiled->relocation,data_relocation_base);

	relocate_code_block(compiled);
}
예제 #3
0
파일: image.c 프로젝트: glguy/factor
void fixup_code_block(F_COMPILED *compiled, CELL code_start, CELL literals_start)
{
	/* relocate literal table data */
	CELL scan;
	CELL literal_end = literals_start + compiled->literals_length;

	data_fixup(&compiled->relocation);

	for(scan = literals_start; scan < literal_end; scan += CELLS)
		data_fixup((CELL*)scan);

	relocate_code_block(compiled,code_start,literals_start);
}
예제 #4
0
파일: image.cpp 프로젝트: harold/factor
/* Initialize an object in a newly-loaded image */
void factor_vm::relocate_object(object *object,
	cell data_relocation_base,
	cell code_relocation_base)
{
	cell hi_tag = object->h.hi_tag();
	
	/* Tuple relocation is a bit trickier; we have to fix up the
	layout object before we can get the tuple size, so do_slots is
	out of the question */
	if(hi_tag == TUPLE_TYPE)
	{
		tuple *t = (tuple *)object;
		data_fixup(&t->layout,data_relocation_base);

		cell *scan = t->data();
		cell *end = (cell *)((cell)object + untagged_object_size(object));

		for(; scan < end; scan++)
			data_fixup(scan,data_relocation_base);
	}
	else
	{
		object_fixupper fixupper(this,data_relocation_base);
		do_slots((cell)object,fixupper);

		switch(hi_tag)
		{
		case WORD_TYPE:
			fixup_word((word *)object,code_relocation_base);
			break;
		case QUOTATION_TYPE:
			fixup_quotation((quotation *)object,code_relocation_base);
			break;
		case DLL_TYPE:
			ffi_dlopen((dll *)object);
			break;
		case ALIEN_TYPE:
			fixup_alien((alien *)object);
			break;
		case CALLSTACK_TYPE:
			fixup_callstack_object((callstack *)object,code_relocation_base);
			break;
		}
	}
}
예제 #5
0
파일: image.c 프로젝트: glguy/factor
/* Initialize an object in a newly-loaded image */
void relocate_object(CELL relocating)
{
	/* Tuple relocation is a bit trickier; we have to fix up the
	fixup object before we can get the tuple size, so do_slots is
	out of the question */
	if(untag_header(get(relocating)) == TUPLE_TYPE)
	{
		data_fixup((CELL *)relocating + 1);

		CELL scan = relocating + 2 * CELLS;
		CELL size = untagged_object_size(relocating);
		CELL end = relocating + size;

		while(scan < end)
		{
			data_fixup((CELL *)scan);
			scan += CELLS;
		}
	}
	else
	{
		do_slots(relocating,data_fixup);

		switch(untag_header(get(relocating)))
		{
		case WORD_TYPE:
			fixup_word((F_WORD *)relocating);
			break;
		case QUOTATION_TYPE:
			fixup_quotation((F_QUOTATION *)relocating);
			break;
		case DLL_TYPE:
			ffi_dlopen((F_DLL *)relocating);
			break;
		case ALIEN_TYPE:
			fixup_alien((F_ALIEN *)relocating);
			break;
		case CALLSTACK_TYPE:
			fixup_callstack_object((F_CALLSTACK *)relocating);
			break;
		}
	}
}
예제 #6
0
파일: image.cpp 프로젝트: harold/factor
/* Since the image might have been saved with a different base address than
where it is loaded, we need to fix up pointers in the image. */
void factor_vm::relocate_data(cell data_relocation_base, cell code_relocation_base)
{
	for(cell i = 0; i < USER_ENV; i++)
		data_fixup(&userenv[i],data_relocation_base);

	data_fixup(&T,data_relocation_base);
	data_fixup(&bignum_zero,data_relocation_base);
	data_fixup(&bignum_pos_one,data_relocation_base);
	data_fixup(&bignum_neg_one,data_relocation_base);

	cell obj = data->tenured->start;

	while(obj)
	{
		relocate_object((object *)obj,data_relocation_base,code_relocation_base);
		data->tenured->record_object_start_offset((object *)obj);
		obj = data->tenured->next_object_after(this,obj);
	}
}
예제 #7
0
파일: image.c 프로젝트: GunioRobot/factor
void fixup_code_block(F_COMPILED *relocating, CELL code_start,
	CELL reloc_start, CELL literals_start)
{
	/* relocate literal table data */
	CELL scan;
	CELL literal_end = literals_start + relocating->literals_length;

	for(scan = literals_start; scan < literal_end; scan += CELLS)
		data_fixup((CELL*)scan);

	if(reloc_start != literals_start)
		relocate_code_block(relocating,code_start,reloc_start,literals_start);
}
예제 #8
0
파일: image.c 프로젝트: glguy/factor
/* Since the image might have been saved with a different base address than
where it is loaded, we need to fix up pointers in the image. */
void relocate_data()
{
	CELL relocating;

	CELL i;
	for(i = 0; i < USER_ENV; i++)
		data_fixup(&userenv[i]);

	data_fixup(&T);
	data_fixup(&bignum_zero);
	data_fixup(&bignum_pos_one);
	data_fixup(&bignum_neg_one);

	F_ZONE *tenured = &data_heap->generations[TENURED];

	for(relocating = tenured->start;
		relocating < tenured->here;
		relocating += untagged_object_size(relocating))
	{
		allot_barrier(relocating);
		relocate_object(relocating);
	}
}
예제 #9
0
파일: image.cpp 프로젝트: leto/factor
/* Since the image might have been saved with a different base address than
where it is loaded, we need to fix up pointers in the image. */
void relocate_data()
{
	cell relocating;

	cell i;
	for(i = 0; i < USER_ENV; i++)
		data_fixup(&userenv[i]);

	data_fixup(&T);
	data_fixup(&bignum_zero);
	data_fixup(&bignum_pos_one);
	data_fixup(&bignum_neg_one);

	zone *tenured = &data->generations[data->tenured()];

	for(relocating = tenured->start;
		relocating < tenured->here;
		relocating += untagged_object_size((object *)relocating))
	{
		object *obj = (object *)relocating;
		allot_barrier(obj);
		relocate_object(obj);
	}
}