Merge branch 'master' into new_gc

db4
Slava Pestov 2009-10-06 01:31:50 -05:00
commit e2fcec6a99
3 changed files with 37 additions and 18 deletions

View File

@ -445,9 +445,13 @@ code_block *factor_vm::add_code_block(cell type, cell code_, cell labels_, cell
compiled->type = type; compiled->type = type;
compiled->last_scan = data->nursery(); compiled->last_scan = data->nursery();
compiled->needs_fixup = true; compiled->needs_fixup = true;
compiled->relocation = relocation.value();
/* slight space optimization */ /* slight space optimization */
if(relocation.type() == BYTE_ARRAY_TYPE && array_capacity(relocation.untagged()) == 0)
compiled->relocation = F;
else
compiled->relocation = relocation.value();
if(literals.type() == ARRAY_TYPE && array_capacity(literals.untagged()) == 0) if(literals.type() == ARRAY_TYPE && array_capacity(literals.untagged()) == 0)
compiled->literals = F; compiled->literals = F;
else else

View File

@ -103,6 +103,28 @@ bool quotation_jit::stack_frame_p()
return false; return false;
} }
bool quotation_jit::trivial_quotation_p(array *elements)
{
return array_capacity(elements) == 1 && tagged<object>(array_nth(elements,0)).type_p(WORD_TYPE);
}
void quotation_jit::emit_quot(cell quot_)
{
gc_root<quotation> quot(quot_,parent_vm);
array *elements = parent_vm->untag<array>(quot->array);
/* If the quotation consists of a single word, compile a direct call
to the word. */
if(trivial_quotation_p(elements))
literal(array_nth(elements,0));
else
{
if(compiling) parent_vm->jit_compile(quot.value(),relocate);
literal(quot.value());
}
}
/* Allocates memory */ /* Allocates memory */
void quotation_jit::iterate_quotation() void quotation_jit::iterate_quotation()
{ {
@ -194,14 +216,8 @@ void quotation_jit::iterate_quotation()
if(stack_frame) emit(parent_vm->userenv[JIT_EPILOG]); if(stack_frame) emit(parent_vm->userenv[JIT_EPILOG]);
tail_call = true; tail_call = true;
if(compiling) emit_quot(array_nth(elements.untagged(),i));
{ emit_quot(array_nth(elements.untagged(),i + 1));
parent_vm->jit_compile(array_nth(elements.untagged(),i),relocate);
parent_vm->jit_compile(array_nth(elements.untagged(),i + 1),relocate);
}
literal(array_nth(elements.untagged(),i));
literal(array_nth(elements.untagged(),i + 1));
emit(parent_vm->userenv[JIT_IF]); emit(parent_vm->userenv[JIT_IF]);
i += 2; i += 2;
@ -209,25 +225,22 @@ void quotation_jit::iterate_quotation()
/* dip */ /* dip */
else if(fast_dip_p(i,length)) else if(fast_dip_p(i,length))
{ {
if(compiling) emit_quot(obj.value());
parent_vm->jit_compile(obj.value(),relocate); emit(parent_vm->userenv[JIT_DIP]);
emit_with(parent_vm->userenv[JIT_DIP],obj.value());
i++; i++;
} }
/* 2dip */ /* 2dip */
else if(fast_2dip_p(i,length)) else if(fast_2dip_p(i,length))
{ {
if(compiling) emit_quot(obj.value());
parent_vm->jit_compile(obj.value(),relocate); emit(parent_vm->userenv[JIT_2DIP]);
emit_with(parent_vm->userenv[JIT_2DIP],obj.value());
i++; i++;
} }
/* 3dip */ /* 3dip */
else if(fast_3dip_p(i,length)) else if(fast_3dip_p(i,length))
{ {
if(compiling) emit_quot(obj.value());
parent_vm->jit_compile(obj.value(),relocate); emit(parent_vm->userenv[JIT_3DIP]);
emit_with(parent_vm->userenv[JIT_3DIP],obj.value());
i++; i++;
} }
else else

View File

@ -13,6 +13,8 @@ struct quotation_jit : public jit {
void emit_mega_cache_lookup(cell methods, fixnum index, cell cache); void emit_mega_cache_lookup(cell methods, fixnum index, cell cache);
bool primitive_call_p(cell i, cell length); bool primitive_call_p(cell i, cell length);
bool trivial_quotation_p(array *elements);
void emit_quot(cell quot);
bool fast_if_p(cell i, cell length); bool fast_if_p(cell i, cell length);
bool fast_dip_p(cell i, cell length); bool fast_dip_p(cell i, cell length);
bool fast_2dip_p(cell i, cell length); bool fast_2dip_p(cell i, cell length);