vm: rename myvm and parent_vm instance variables to parent, clean up casts in primitive definitions
parent
236588208b
commit
2e65366c6b
|
@ -2,13 +2,13 @@ namespace factor
|
|||
{
|
||||
|
||||
struct aging_policy {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
zone *aging, *tenured;
|
||||
|
||||
aging_policy(factor_vm *myvm_) :
|
||||
myvm(myvm_),
|
||||
aging(myvm->data->aging),
|
||||
tenured(myvm->data->tenured) {}
|
||||
aging_policy(factor_vm *parent_) :
|
||||
parent(parent_),
|
||||
aging(parent->data->aging),
|
||||
tenured(parent->data->tenured) {}
|
||||
|
||||
bool should_copy_p(object *untagged)
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ struct aging_policy {
|
|||
};
|
||||
|
||||
struct aging_collector : copying_collector<aging_space,aging_policy> {
|
||||
aging_collector(factor_vm *myvm_);
|
||||
aging_collector(factor_vm *parent_);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
34
vm/alien.cpp
34
vm/alien.cpp
|
@ -87,12 +87,12 @@ void *factor_vm::alien_pointer()
|
|||
#define DEFINE_ALIEN_ACCESSOR(name,type,boxer,to) \
|
||||
PRIMITIVE(alien_##name) \
|
||||
{ \
|
||||
((factor_vm*)myvm)->boxer(*(type*)((factor_vm*)myvm)->alien_pointer()); \
|
||||
parent->boxer(*(type*)(parent->alien_pointer())); \
|
||||
} \
|
||||
PRIMITIVE(set_alien_##name) \
|
||||
{ \
|
||||
type *ptr = (type *)((factor_vm*)myvm)->alien_pointer(); \
|
||||
type value = ((factor_vm*)myvm)->to(dpop()); \
|
||||
type *ptr = (type *)parent->alien_pointer(); \
|
||||
type value = parent->to(dpop()); \
|
||||
*ptr = value; \
|
||||
}
|
||||
|
||||
|
@ -182,9 +182,9 @@ char *factor_vm::alien_offset(cell obj)
|
|||
}
|
||||
}
|
||||
|
||||
VM_C_API char *alien_offset(cell obj, factor_vm *myvm)
|
||||
VM_C_API char *alien_offset(cell obj, factor_vm *parent)
|
||||
{
|
||||
return myvm->alien_offset(obj);
|
||||
return parent->alien_offset(obj);
|
||||
}
|
||||
|
||||
/* pop an object representing a C pointer */
|
||||
|
@ -193,9 +193,9 @@ char *factor_vm::unbox_alien()
|
|||
return alien_offset(dpop());
|
||||
}
|
||||
|
||||
VM_C_API char *unbox_alien(factor_vm *myvm)
|
||||
VM_C_API char *unbox_alien(factor_vm *parent)
|
||||
{
|
||||
return myvm->unbox_alien();
|
||||
return parent->unbox_alien();
|
||||
}
|
||||
|
||||
/* make an alien and push */
|
||||
|
@ -207,9 +207,9 @@ void factor_vm::box_alien(void *ptr)
|
|||
dpush(allot_alien(false_object,(cell)ptr));
|
||||
}
|
||||
|
||||
VM_C_API void box_alien(void *ptr, factor_vm *myvm)
|
||||
VM_C_API void box_alien(void *ptr, factor_vm *parent)
|
||||
{
|
||||
return myvm->box_alien(ptr);
|
||||
return parent->box_alien(ptr);
|
||||
}
|
||||
|
||||
/* for FFI calls passing structs by value */
|
||||
|
@ -218,9 +218,9 @@ void factor_vm::to_value_struct(cell src, void *dest, cell size)
|
|||
memcpy(dest,alien_offset(src),size);
|
||||
}
|
||||
|
||||
VM_C_API void to_value_struct(cell src, void *dest, cell size, factor_vm *myvm)
|
||||
VM_C_API void to_value_struct(cell src, void *dest, cell size, factor_vm *parent)
|
||||
{
|
||||
return myvm->to_value_struct(src,dest,size);
|
||||
return parent->to_value_struct(src,dest,size);
|
||||
}
|
||||
|
||||
/* for FFI callbacks receiving structs by value */
|
||||
|
@ -231,9 +231,9 @@ void factor_vm::box_value_struct(void *src, cell size)
|
|||
dpush(tag<byte_array>(bytes));
|
||||
}
|
||||
|
||||
VM_C_API void box_value_struct(void *src, cell size,factor_vm *myvm)
|
||||
VM_C_API void box_value_struct(void *src, cell size,factor_vm *parent)
|
||||
{
|
||||
return myvm->box_value_struct(src,size);
|
||||
return parent->box_value_struct(src,size);
|
||||
}
|
||||
|
||||
/* On some x86 OSes, structs <= 8 bytes are returned in registers. */
|
||||
|
@ -245,9 +245,9 @@ void factor_vm::box_small_struct(cell x, cell y, cell size)
|
|||
box_value_struct(data,size);
|
||||
}
|
||||
|
||||
VM_C_API void box_small_struct(cell x, cell y, cell size, factor_vm *myvm)
|
||||
VM_C_API void box_small_struct(cell x, cell y, cell size, factor_vm *parent)
|
||||
{
|
||||
return myvm->box_small_struct(x,y,size);
|
||||
return parent->box_small_struct(x,y,size);
|
||||
}
|
||||
|
||||
/* On OS X/PPC, complex numbers are returned in registers. */
|
||||
|
@ -261,9 +261,9 @@ void factor_vm::box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size)
|
|||
box_value_struct(data,size);
|
||||
}
|
||||
|
||||
VM_C_API void box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size, factor_vm *myvm)
|
||||
VM_C_API void box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size, factor_vm *parent)
|
||||
{
|
||||
return myvm->box_medium_struct(x1, x2, x3, x4, size);
|
||||
return parent->box_medium_struct(x1, x2, x3, x4, size);
|
||||
}
|
||||
|
||||
void factor_vm::primitive_vm_ptr()
|
||||
|
|
|
@ -71,33 +71,33 @@ void factor_vm::primitive_resize_array()
|
|||
|
||||
void growable_array::add(cell elt_)
|
||||
{
|
||||
factor_vm *parent_vm = elements.parent_vm;
|
||||
gc_root<object> elt(elt_,parent_vm);
|
||||
factor_vm *parent = elements.parent;
|
||||
gc_root<object> elt(elt_,parent);
|
||||
if(count == array_capacity(elements.untagged()))
|
||||
elements = parent_vm->reallot_array(elements.untagged(),count * 2);
|
||||
elements = parent->reallot_array(elements.untagged(),count * 2);
|
||||
|
||||
parent_vm->set_array_nth(elements.untagged(),count++,elt.value());
|
||||
parent->set_array_nth(elements.untagged(),count++,elt.value());
|
||||
}
|
||||
|
||||
void growable_array::append(array *elts_)
|
||||
{
|
||||
factor_vm *parent_vm = elements.parent_vm;
|
||||
gc_root<array> elts(elts_,parent_vm);
|
||||
factor_vm *parent = elements.parent;
|
||||
gc_root<array> elts(elts_,parent);
|
||||
cell capacity = array_capacity(elts.untagged());
|
||||
if(count + capacity > array_capacity(elements.untagged()))
|
||||
{
|
||||
elements = parent_vm->reallot_array(elements.untagged(),
|
||||
elements = parent->reallot_array(elements.untagged(),
|
||||
(count + capacity) * 2);
|
||||
}
|
||||
|
||||
for(cell index = 0; index < capacity; index++)
|
||||
parent_vm->set_array_nth(elements.untagged(),count++,array_nth(elts.untagged(),index));
|
||||
parent->set_array_nth(elements.untagged(),count++,array_nth(elts.untagged(),index));
|
||||
}
|
||||
|
||||
void growable_array::trim()
|
||||
{
|
||||
factor_vm *parent_vm = elements.parent_vm;
|
||||
elements = parent_vm->reallot_array(elements.untagged(),count);
|
||||
factor_vm *parent = elements.parent;
|
||||
elements = parent->reallot_array(elements.untagged(),count);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ struct growable_array {
|
|||
cell count;
|
||||
gc_root<array> elements;
|
||||
|
||||
explicit growable_array(factor_vm *myvm, cell capacity = 10) :
|
||||
count(0), elements(myvm->allot_array(capacity,false_object),myvm) {}
|
||||
explicit growable_array(factor_vm *parent, cell capacity = 10) :
|
||||
count(0), elements(parent->allot_array(capacity,false_object),parent) {}
|
||||
|
||||
void add(cell elt);
|
||||
void append(array *elts);
|
||||
|
|
|
@ -8,14 +8,14 @@ void factor_vm::box_boolean(bool value)
|
|||
dpush(tag_boolean(value));
|
||||
}
|
||||
|
||||
VM_C_API void box_boolean(bool value, factor_vm *myvm)
|
||||
VM_C_API void box_boolean(bool value, factor_vm *parent)
|
||||
{
|
||||
return myvm->box_boolean(value);
|
||||
return parent->box_boolean(value);
|
||||
}
|
||||
|
||||
VM_C_API bool to_boolean(cell value, factor_vm *myvm)
|
||||
VM_C_API bool to_boolean(cell value, factor_vm *parent)
|
||||
{
|
||||
return myvm->to_boolean(value);
|
||||
return parent->to_boolean(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ void factor_vm::primitive_resize_byte_array()
|
|||
void growable_byte_array::append_bytes(void *elts, cell len)
|
||||
{
|
||||
cell new_size = count + len;
|
||||
factor_vm *parent_vm = elements.parent_vm;
|
||||
factor_vm *parent = elements.parent;
|
||||
if(new_size >= array_capacity(elements.untagged()))
|
||||
elements = parent_vm->reallot_array(elements.untagged(),new_size * 2);
|
||||
elements = parent->reallot_array(elements.untagged(),new_size * 2);
|
||||
|
||||
memcpy(&elements->data<u8>()[count],elts,len);
|
||||
|
||||
|
@ -43,13 +43,13 @@ void growable_byte_array::append_bytes(void *elts, cell len)
|
|||
|
||||
void growable_byte_array::append_byte_array(cell byte_array_)
|
||||
{
|
||||
gc_root<byte_array> byte_array(byte_array_,elements.parent_vm);
|
||||
gc_root<byte_array> byte_array(byte_array_,elements.parent);
|
||||
|
||||
cell len = array_capacity(byte_array.untagged());
|
||||
cell new_size = count + len;
|
||||
factor_vm *parent_vm = elements.parent_vm;
|
||||
factor_vm *parent = elements.parent;
|
||||
if(new_size >= array_capacity(elements.untagged()))
|
||||
elements = parent_vm->reallot_array(elements.untagged(),new_size * 2);
|
||||
elements = parent->reallot_array(elements.untagged(),new_size * 2);
|
||||
|
||||
memcpy(&elements->data<u8>()[count],byte_array->data<u8>(),len);
|
||||
|
||||
|
@ -58,8 +58,8 @@ void growable_byte_array::append_byte_array(cell byte_array_)
|
|||
|
||||
void growable_byte_array::trim()
|
||||
{
|
||||
factor_vm *parent_vm = elements.parent_vm;
|
||||
elements = parent_vm->reallot_array(elements.untagged(),count);
|
||||
factor_vm *parent = elements.parent;
|
||||
elements = parent->reallot_array(elements.untagged(),count);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ struct growable_byte_array {
|
|||
cell count;
|
||||
gc_root<byte_array> elements;
|
||||
|
||||
explicit growable_byte_array(factor_vm *myvm,cell capacity = 40) : count(0), elements(myvm->allot_byte_array(capacity),myvm) { }
|
||||
explicit growable_byte_array(factor_vm *parent,cell capacity = 40) : count(0), elements(parent->allot_byte_array(capacity),parent) { }
|
||||
|
||||
void append_bytes(void *elts, cell len);
|
||||
void append_byte_array(cell elts);
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
namespace factor
|
||||
{
|
||||
|
||||
callback_heap::callback_heap(cell size, factor_vm *myvm_) :
|
||||
callback_heap::callback_heap(cell size, factor_vm *parent_) :
|
||||
seg(new segment(size,true)),
|
||||
here(seg->start),
|
||||
myvm(myvm_) {}
|
||||
parent(parent_) {}
|
||||
|
||||
callback_heap::~callback_heap()
|
||||
{
|
||||
|
@ -21,12 +21,12 @@ void factor_vm::init_callbacks(cell size)
|
|||
|
||||
void callback_heap::update(callback *stub)
|
||||
{
|
||||
tagged<array> code_template(myvm->userenv[CALLBACK_STUB]);
|
||||
tagged<array> code_template(parent->userenv[CALLBACK_STUB]);
|
||||
|
||||
cell rel_class = untag_fixnum(array_nth(code_template.untagged(),1));
|
||||
cell offset = untag_fixnum(array_nth(code_template.untagged(),3));
|
||||
|
||||
myvm->store_address_in_code_block(rel_class,
|
||||
parent->store_address_in_code_block(rel_class,
|
||||
(cell)(stub + 1) + offset,
|
||||
(cell)(stub->compiled + 1));
|
||||
|
||||
|
@ -35,7 +35,7 @@ void callback_heap::update(callback *stub)
|
|||
|
||||
callback *callback_heap::add(code_block *compiled)
|
||||
{
|
||||
tagged<array> code_template(myvm->userenv[CALLBACK_STUB]);
|
||||
tagged<array> code_template(parent->userenv[CALLBACK_STUB]);
|
||||
tagged<byte_array> insns(array_nth(code_template.untagged(),0));
|
||||
cell size = array_capacity(insns.untagged());
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ struct callback {
|
|||
struct callback_heap {
|
||||
segment *seg;
|
||||
cell here;
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
|
||||
explicit callback_heap(cell size, factor_vm *myvm);
|
||||
explicit callback_heap(cell size, factor_vm *parent);
|
||||
~callback_heap();
|
||||
|
||||
callback *add(code_block *compiled);
|
||||
|
|
|
@ -123,15 +123,15 @@ namespace
|
|||
{
|
||||
|
||||
struct stack_frame_accumulator {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
growable_array frames;
|
||||
|
||||
explicit stack_frame_accumulator(factor_vm *myvm_) : myvm(myvm_), frames(myvm_) {}
|
||||
explicit stack_frame_accumulator(factor_vm *parent_) : parent(parent_), frames(parent_) {}
|
||||
|
||||
void operator()(stack_frame *frame)
|
||||
{
|
||||
gc_root<object> executing(myvm->frame_executing(frame),myvm);
|
||||
gc_root<object> scan(myvm->frame_scan(frame),myvm);
|
||||
gc_root<object> executing(parent->frame_executing(frame),parent);
|
||||
gc_root<object> scan(parent->frame_scan(frame),parent);
|
||||
|
||||
frames.add(executing.value());
|
||||
frames.add(scan.value());
|
||||
|
@ -204,9 +204,9 @@ void factor_vm::save_callstack_bottom(stack_frame *callstack_bottom)
|
|||
ctx->callstack_bottom = callstack_bottom;
|
||||
}
|
||||
|
||||
VM_ASM_API void save_callstack_bottom(stack_frame *callstack_bottom, factor_vm *myvm)
|
||||
VM_ASM_API void save_callstack_bottom(stack_frame *callstack_bottom, factor_vm *parent)
|
||||
{
|
||||
return myvm->save_callstack_bottom(callstack_bottom);
|
||||
return parent->save_callstack_bottom(callstack_bottom);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -277,18 +277,18 @@ void factor_vm::store_address_in_code_block(cell klass, cell offset, fixnum abso
|
|||
}
|
||||
|
||||
struct literal_references_updater {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
|
||||
explicit literal_references_updater(factor_vm *myvm_) : myvm(myvm_) {}
|
||||
explicit literal_references_updater(factor_vm *parent_) : parent(parent_) {}
|
||||
|
||||
void operator()(relocation_entry rel, cell index, code_block *compiled)
|
||||
{
|
||||
if(myvm->relocation_type_of(rel) == RT_IMMEDIATE)
|
||||
if(parent->relocation_type_of(rel) == RT_IMMEDIATE)
|
||||
{
|
||||
cell offset = myvm->relocation_offset_of(rel) + (cell)(compiled + 1);
|
||||
array *literals = myvm->untag<array>(compiled->literals);
|
||||
cell offset = parent->relocation_offset_of(rel) + (cell)(compiled + 1);
|
||||
array *literals = parent->untag<array>(compiled->literals);
|
||||
fixnum absolute_value = array_nth(literals,index);
|
||||
myvm->store_address_in_code_block(myvm->relocation_class_of(rel),offset,absolute_value);
|
||||
parent->store_address_in_code_block(parent->relocation_class_of(rel),offset,absolute_value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -320,14 +320,14 @@ void factor_vm::relocate_code_block_step(relocation_entry rel, cell index, code_
|
|||
}
|
||||
|
||||
struct word_references_updater {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
|
||||
explicit word_references_updater(factor_vm *myvm_) : myvm(myvm_) {}
|
||||
explicit word_references_updater(factor_vm *parent_) : parent(parent_) {}
|
||||
void operator()(relocation_entry rel, cell index, code_block *compiled)
|
||||
{
|
||||
relocation_type type = myvm->relocation_type_of(rel);
|
||||
relocation_type type = parent->relocation_type_of(rel);
|
||||
if(type == RT_XT || type == RT_XT_PIC || type == RT_XT_PIC_TAIL)
|
||||
myvm->relocate_code_block_step(rel,index,compiled);
|
||||
parent->relocate_code_block_step(rel,index,compiled);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -358,20 +358,20 @@ void factor_vm::update_word_references(code_block *compiled)
|
|||
|
||||
/* This runs after a full collection */
|
||||
struct literal_and_word_references_updater {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
|
||||
explicit literal_and_word_references_updater(factor_vm *myvm_) : myvm(myvm_) {}
|
||||
explicit literal_and_word_references_updater(factor_vm *parent_) : parent(parent_) {}
|
||||
|
||||
void operator()(relocation_entry rel, cell index, code_block *compiled)
|
||||
{
|
||||
relocation_type type = myvm->relocation_type_of(rel);
|
||||
relocation_type type = parent->relocation_type_of(rel);
|
||||
switch(type)
|
||||
{
|
||||
case RT_IMMEDIATE:
|
||||
case RT_XT:
|
||||
case RT_XT_PIC:
|
||||
case RT_XT_PIC_TAIL:
|
||||
myvm->relocate_code_block_step(rel,index,compiled);
|
||||
parent->relocate_code_block_step(rel,index,compiled);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -399,13 +399,13 @@ void factor_vm::check_code_address(cell address)
|
|||
}
|
||||
|
||||
struct code_block_relocator {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
|
||||
explicit code_block_relocator(factor_vm *myvm_) : myvm(myvm_) {}
|
||||
explicit code_block_relocator(factor_vm *parent_) : parent(parent_) {}
|
||||
|
||||
void operator()(relocation_entry rel, cell index, code_block *compiled)
|
||||
{
|
||||
myvm->relocate_code_block_step(rel,index,compiled);
|
||||
parent->relocate_code_block_step(rel,index,compiled);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -56,12 +56,12 @@ void factor_vm::jit_compile_word(cell word_, cell def_, bool relocate)
|
|||
}
|
||||
|
||||
struct word_updater {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
|
||||
explicit word_updater(factor_vm *myvm_) : myvm(myvm_) {}
|
||||
explicit word_updater(factor_vm *parent_) : parent(parent_) {}
|
||||
void operator()(code_block *compiled)
|
||||
{
|
||||
myvm->update_word_references(compiled);
|
||||
parent->update_word_references(compiled);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -143,18 +143,18 @@ code_block *code_heap::forward_code_block(code_block *compiled)
|
|||
}
|
||||
|
||||
struct callframe_forwarder {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
|
||||
explicit callframe_forwarder(factor_vm *myvm_) : myvm(myvm_) {}
|
||||
explicit callframe_forwarder(factor_vm *parent_) : parent(parent_) {}
|
||||
|
||||
void operator()(stack_frame *frame)
|
||||
{
|
||||
cell offset = (cell)FRAME_RETURN_ADDRESS(frame,myvm) - (cell)frame->xt;
|
||||
cell offset = (cell)FRAME_RETURN_ADDRESS(frame,parent) - (cell)frame->xt;
|
||||
|
||||
code_block *forwarded = myvm->code->forward_code_block(myvm->frame_code(frame));
|
||||
code_block *forwarded = parent->code->forward_code_block(parent->frame_code(frame));
|
||||
frame->xt = forwarded->xt();
|
||||
|
||||
FRAME_RETURN_ADDRESS(frame,myvm) = (void *)((cell)frame->xt + offset);
|
||||
FRAME_RETURN_ADDRESS(frame,parent) = (void *)((cell)frame->xt + offset);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ namespace factor
|
|||
{
|
||||
|
||||
template<typename TargetGeneration, typename Policy> struct collector {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
data_heap *data;
|
||||
code_heap *code;
|
||||
gc_state *current_gc;
|
||||
|
@ -10,18 +10,18 @@ template<typename TargetGeneration, typename Policy> struct collector {
|
|||
TargetGeneration *target;
|
||||
Policy policy;
|
||||
|
||||
explicit collector(factor_vm *myvm_, generation_statistics *stats_, TargetGeneration *target_, Policy policy_) :
|
||||
myvm(myvm_),
|
||||
data(myvm_->data),
|
||||
code(myvm_->code),
|
||||
current_gc(myvm_->current_gc),
|
||||
explicit collector(factor_vm *parent_, generation_statistics *stats_, TargetGeneration *target_, Policy policy_) :
|
||||
parent(parent_),
|
||||
data(parent_->data),
|
||||
code(parent_->code),
|
||||
current_gc(parent_->current_gc),
|
||||
stats(stats_),
|
||||
target(target_),
|
||||
policy(policy_) {}
|
||||
|
||||
object *resolve_forwarding(object *untagged)
|
||||
{
|
||||
myvm->check_data_pointer(untagged);
|
||||
parent->check_data_pointer(untagged);
|
||||
|
||||
/* is there another forwarding pointer? */
|
||||
while(untagged->h.forwarding_pointer_p())
|
||||
|
@ -38,7 +38,7 @@ template<typename TargetGeneration, typename Policy> struct collector {
|
|||
|
||||
if(immediate_p(pointer)) return;
|
||||
|
||||
object *untagged = myvm->untag<object>(pointer);
|
||||
object *untagged = parent->untag<object>(pointer);
|
||||
if(!policy.should_copy_p(untagged))
|
||||
return;
|
||||
|
||||
|
@ -57,7 +57,7 @@ template<typename TargetGeneration, typename Policy> struct collector {
|
|||
void trace_slots(object *ptr)
|
||||
{
|
||||
cell *slot = (cell *)ptr;
|
||||
cell *end = (cell *)((cell)ptr + myvm->binary_payload_start(ptr));
|
||||
cell *end = (cell *)((cell)ptr + parent->binary_payload_start(ptr));
|
||||
|
||||
if(slot != end)
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ template<typename TargetGeneration, typename Policy> struct collector {
|
|||
|
||||
object *promote_object(object *untagged)
|
||||
{
|
||||
cell size = myvm->untagged_object_size(untagged);
|
||||
cell size = parent->untagged_object_size(untagged);
|
||||
object *newpointer = target->allot(size);
|
||||
/* XXX not exception-safe */
|
||||
if(!newpointer) longjmp(current_gc->gc_unwind,1);
|
||||
|
@ -90,8 +90,8 @@ template<typename TargetGeneration, typename Policy> struct collector {
|
|||
|
||||
void trace_registered_locals()
|
||||
{
|
||||
std::vector<cell>::const_iterator iter = myvm->gc_locals.begin();
|
||||
std::vector<cell>::const_iterator end = myvm->gc_locals.end();
|
||||
std::vector<cell>::const_iterator iter = parent->gc_locals.begin();
|
||||
std::vector<cell>::const_iterator end = parent->gc_locals.end();
|
||||
|
||||
for(; iter < end; iter++)
|
||||
trace_handle((cell *)(*iter));
|
||||
|
@ -99,8 +99,8 @@ template<typename TargetGeneration, typename Policy> struct collector {
|
|||
|
||||
void trace_registered_bignums()
|
||||
{
|
||||
std::vector<cell>::const_iterator iter = myvm->gc_bignums.begin();
|
||||
std::vector<cell>::const_iterator end = myvm->gc_bignums.end();
|
||||
std::vector<cell>::const_iterator iter = parent->gc_bignums.begin();
|
||||
std::vector<cell>::const_iterator end = parent->gc_bignums.end();
|
||||
|
||||
for(; iter < end; iter++)
|
||||
{
|
||||
|
@ -119,20 +119,20 @@ template<typename TargetGeneration, typename Policy> struct collector {
|
|||
the user environment and extra roots registered by local_roots.hpp */
|
||||
void trace_roots()
|
||||
{
|
||||
trace_handle(&myvm->true_object);
|
||||
trace_handle(&myvm->bignum_zero);
|
||||
trace_handle(&myvm->bignum_pos_one);
|
||||
trace_handle(&myvm->bignum_neg_one);
|
||||
trace_handle(&parent->true_object);
|
||||
trace_handle(&parent->bignum_zero);
|
||||
trace_handle(&parent->bignum_pos_one);
|
||||
trace_handle(&parent->bignum_neg_one);
|
||||
|
||||
trace_registered_locals();
|
||||
trace_registered_bignums();
|
||||
|
||||
for(int i = 0; i < USER_ENV; i++) trace_handle(&myvm->userenv[i]);
|
||||
for(int i = 0; i < USER_ENV; i++) trace_handle(&parent->userenv[i]);
|
||||
}
|
||||
|
||||
void trace_contexts()
|
||||
{
|
||||
context *ctx = myvm->ctx;
|
||||
context *ctx = parent->ctx;
|
||||
|
||||
while(ctx)
|
||||
{
|
||||
|
|
|
@ -91,9 +91,9 @@ void factor_vm::nest_stacks(stack_frame *magic_frame)
|
|||
reset_retainstack();
|
||||
}
|
||||
|
||||
void nest_stacks(stack_frame *magic_frame, factor_vm *myvm)
|
||||
void nest_stacks(stack_frame *magic_frame, factor_vm *parent)
|
||||
{
|
||||
return myvm->nest_stacks(magic_frame);
|
||||
return parent->nest_stacks(magic_frame);
|
||||
}
|
||||
|
||||
/* called when leaving a compiled callback */
|
||||
|
@ -111,9 +111,9 @@ void factor_vm::unnest_stacks()
|
|||
dealloc_context(old_ctx);
|
||||
}
|
||||
|
||||
void unnest_stacks(factor_vm *myvm)
|
||||
void unnest_stacks(factor_vm *parent)
|
||||
{
|
||||
return myvm->unnest_stacks();
|
||||
return parent->unnest_stacks();
|
||||
}
|
||||
|
||||
/* called on startup */
|
||||
|
|
|
@ -15,8 +15,8 @@ template<typename TargetGeneration, typename Policy>
|
|||
struct copying_collector : collector<TargetGeneration,Policy> {
|
||||
cell scan;
|
||||
|
||||
explicit copying_collector(factor_vm *myvm_, generation_statistics *stats_, TargetGeneration *target_, Policy policy_) :
|
||||
collector<TargetGeneration,Policy>(myvm_,stats_,target_,policy_), scan(target_->here) {}
|
||||
explicit copying_collector(factor_vm *parent_, generation_statistics *stats_, TargetGeneration *target_, Policy policy_) :
|
||||
collector<TargetGeneration,Policy>(parent_,stats_,target_,policy_), scan(target_->here) {}
|
||||
|
||||
inline cell first_card_in_deck(cell deck)
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ struct copying_collector : collector<TargetGeneration,Policy> {
|
|||
{
|
||||
if(decks[deck_index] & mask)
|
||||
{
|
||||
this->myvm->gc_stats.decks_scanned++;
|
||||
this->parent->gc_stats.decks_scanned++;
|
||||
|
||||
cell first_card = first_card_in_deck(deck_index);
|
||||
cell last_card = last_card_in_deck(deck_index);
|
||||
|
@ -91,13 +91,13 @@ struct copying_collector : collector<TargetGeneration,Policy> {
|
|||
{
|
||||
if(cards[card_index] & mask)
|
||||
{
|
||||
this->myvm->gc_stats.cards_scanned++;
|
||||
this->parent->gc_stats.cards_scanned++;
|
||||
|
||||
if(end < card_start_address(card_index))
|
||||
{
|
||||
start = gen->find_object_containing_card(card_index - gen_start_card);
|
||||
binary_start = start + this->myvm->binary_payload_start((object *)start);
|
||||
end = start + this->myvm->untagged_object_size((object *)start);
|
||||
binary_start = start + this->parent->binary_payload_start((object *)start);
|
||||
end = start + this->parent->untagged_object_size((object *)start);
|
||||
}
|
||||
|
||||
#ifdef FACTOR_DEBUG
|
||||
|
@ -113,11 +113,11 @@ scan_next_object: {
|
|||
card_end_address(card_index));
|
||||
if(end < card_end_address(card_index))
|
||||
{
|
||||
start = gen->next_object_after(this->myvm,start);
|
||||
start = gen->next_object_after(this->parent,start);
|
||||
if(start)
|
||||
{
|
||||
binary_start = start + this->myvm->binary_payload_start((object *)start);
|
||||
end = start + this->myvm->untagged_object_size((object *)start);
|
||||
binary_start = start + this->parent->binary_payload_start((object *)start);
|
||||
end = start + this->parent->untagged_object_size((object *)start);
|
||||
goto scan_next_object;
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ scan_next_object: {
|
|||
}
|
||||
}
|
||||
|
||||
end: this->myvm->gc_stats.card_scan_time += (current_micros() - start_time);
|
||||
end: this->parent->gc_stats.card_scan_time += (current_micros() - start_time);
|
||||
}
|
||||
|
||||
/* Trace all literals referenced from a code block. Only for aging and nursery collections */
|
||||
|
@ -142,7 +142,7 @@ end: this->myvm->gc_stats.card_scan_time += (current_micros() - start_time);
|
|||
this->trace_handle(&compiled->owner);
|
||||
this->trace_handle(&compiled->literals);
|
||||
this->trace_handle(&compiled->relocation);
|
||||
this->myvm->gc_stats.code_blocks_scanned++;
|
||||
this->parent->gc_stats.code_blocks_scanned++;
|
||||
}
|
||||
|
||||
void trace_code_heap_roots(std::set<code_block *> *remembered_set)
|
||||
|
@ -158,7 +158,7 @@ end: this->myvm->gc_stats.card_scan_time += (current_micros() - start_time);
|
|||
while(scan && scan < this->target->here)
|
||||
{
|
||||
this->trace_slots((object *)scan);
|
||||
scan = this->target->next_object_after(this->myvm,scan);
|
||||
scan = this->target->next_object_after(this->parent,scan);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
20
vm/debug.cpp
20
vm/debug.cpp
|
@ -165,23 +165,23 @@ void factor_vm::print_retainstack()
|
|||
}
|
||||
|
||||
struct stack_frame_printer {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
|
||||
explicit stack_frame_printer(factor_vm *myvm_) : myvm(myvm_) {}
|
||||
explicit stack_frame_printer(factor_vm *parent_) : parent(parent_) {}
|
||||
void operator()(stack_frame *frame)
|
||||
{
|
||||
myvm->print_obj(myvm->frame_executing(frame));
|
||||
parent->print_obj(parent->frame_executing(frame));
|
||||
print_string("\n");
|
||||
myvm->print_obj(myvm->frame_scan(frame));
|
||||
parent->print_obj(parent->frame_scan(frame));
|
||||
print_string("\n");
|
||||
print_string("word/quot addr: ");
|
||||
print_cell_hex((cell)myvm->frame_executing(frame));
|
||||
print_cell_hex((cell)parent->frame_executing(frame));
|
||||
print_string("\n");
|
||||
print_string("word/quot xt: ");
|
||||
print_cell_hex((cell)frame->xt);
|
||||
print_string("\n");
|
||||
print_string("return address: ");
|
||||
print_cell_hex((cell)FRAME_RETURN_ADDRESS(frame,myvm));
|
||||
print_cell_hex((cell)FRAME_RETURN_ADDRESS(frame,parent));
|
||||
print_string("\n");
|
||||
}
|
||||
};
|
||||
|
@ -252,10 +252,10 @@ void factor_vm::dump_objects(cell type)
|
|||
|
||||
struct data_references_finder {
|
||||
cell look_for, obj;
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
|
||||
explicit data_references_finder(cell look_for_, cell obj_, factor_vm *myvm_)
|
||||
: look_for(look_for_), obj(obj_), myvm(myvm_) { }
|
||||
explicit data_references_finder(cell look_for_, cell obj_, factor_vm *parent_)
|
||||
: look_for(look_for_), obj(obj_), parent(parent_) { }
|
||||
|
||||
void operator()(cell *scan)
|
||||
{
|
||||
|
@ -263,7 +263,7 @@ struct data_references_finder {
|
|||
{
|
||||
print_cell_hex_pad(obj);
|
||||
print_string(" ");
|
||||
myvm->print_nested_obj(obj,2);
|
||||
parent->print_nested_obj(obj,2);
|
||||
nl();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,28 +180,28 @@ void factor_vm::primitive_dispatch_stats()
|
|||
|
||||
void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index, cell cache_)
|
||||
{
|
||||
gc_root<array> methods(methods_,parent_vm);
|
||||
gc_root<array> cache(cache_,parent_vm);
|
||||
gc_root<array> methods(methods_,parent);
|
||||
gc_root<array> cache(cache_,parent);
|
||||
|
||||
/* Generate machine code to determine the object's class. */
|
||||
emit_class_lookup(index,PIC_HI_TAG_TUPLE);
|
||||
|
||||
/* Do a cache lookup. */
|
||||
emit_with(parent_vm->userenv[MEGA_LOOKUP],cache.value());
|
||||
emit_with(parent->userenv[MEGA_LOOKUP],cache.value());
|
||||
|
||||
/* If we end up here, the cache missed. */
|
||||
emit(parent_vm->userenv[JIT_PROLOG]);
|
||||
emit(parent->userenv[JIT_PROLOG]);
|
||||
|
||||
/* Push index, method table and cache on the stack. */
|
||||
push(methods.value());
|
||||
push(tag_fixnum(index));
|
||||
push(cache.value());
|
||||
word_call(parent_vm->userenv[MEGA_MISS_WORD]);
|
||||
word_call(parent->userenv[MEGA_MISS_WORD]);
|
||||
|
||||
/* Now the new method has been stored into the cache, and its on
|
||||
the stack. */
|
||||
emit(parent_vm->userenv[JIT_EPILOG]);
|
||||
emit(parent_vm->userenv[JIT_EXECUTE_JUMP]);
|
||||
emit(parent->userenv[JIT_EPILOG]);
|
||||
emit(parent->userenv[JIT_EXECUTE_JUMP]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,23 +3,23 @@
|
|||
namespace factor
|
||||
{
|
||||
|
||||
full_collector::full_collector(factor_vm *myvm_) :
|
||||
full_collector::full_collector(factor_vm *parent_) :
|
||||
copying_collector<tenured_space,full_policy>(
|
||||
myvm_,
|
||||
&myvm_->gc_stats.full_stats,
|
||||
myvm_->data->tenured,
|
||||
full_policy(myvm_)) {}
|
||||
parent_,
|
||||
&parent_->gc_stats.full_stats,
|
||||
parent_->data->tenured,
|
||||
full_policy(parent_)) {}
|
||||
|
||||
struct stack_frame_marker {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
full_collector *collector;
|
||||
|
||||
explicit stack_frame_marker(full_collector *collector_) :
|
||||
myvm(collector_->myvm), collector(collector_) {}
|
||||
parent(collector_->parent), collector(collector_) {}
|
||||
|
||||
void operator()(stack_frame *frame)
|
||||
{
|
||||
collector->mark_code_block(myvm->frame_code(frame));
|
||||
collector->mark_code_block(parent->frame_code(frame));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,7 @@ struct stack_frame_marker {
|
|||
void full_collector::mark_active_blocks()
|
||||
{
|
||||
stack_frame_marker marker(this);
|
||||
myvm->iterate_active_frames(marker);
|
||||
parent->iterate_active_frames(marker);
|
||||
}
|
||||
|
||||
void full_collector::mark_object_code_block(object *obj)
|
||||
|
@ -54,7 +54,7 @@ void full_collector::mark_object_code_block(object *obj)
|
|||
{
|
||||
callstack *stack = (callstack *)obj;
|
||||
stack_frame_marker marker(this);
|
||||
myvm->iterate_callstack_object(stack,marker);
|
||||
parent->iterate_callstack_object(stack,marker);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ struct callback_tracer {
|
|||
void full_collector::trace_callbacks()
|
||||
{
|
||||
callback_tracer tracer(this);
|
||||
myvm->callbacks->iterate(tracer);
|
||||
parent->callbacks->iterate(tracer);
|
||||
}
|
||||
|
||||
/* Trace all literals referenced from a code block. Only for aging and nursery collections */
|
||||
|
@ -100,33 +100,33 @@ void full_collector::cheneys_algorithm()
|
|||
object *obj = (object *)scan;
|
||||
this->trace_slots(obj);
|
||||
this->mark_object_code_block(obj);
|
||||
scan = target->next_object_after(this->myvm,scan);
|
||||
scan = target->next_object_after(this->parent,scan);
|
||||
}
|
||||
}
|
||||
|
||||
/* After growing the heap, we have to perform a full relocation to update
|
||||
references to card and deck arrays. */
|
||||
struct big_code_heap_updater {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
|
||||
big_code_heap_updater(factor_vm *myvm_) : myvm(myvm_) {}
|
||||
big_code_heap_updater(factor_vm *parent_) : parent(parent_) {}
|
||||
|
||||
void operator()(heap_block *block)
|
||||
{
|
||||
myvm->relocate_code_block((code_block *)block);
|
||||
parent->relocate_code_block((code_block *)block);
|
||||
}
|
||||
};
|
||||
|
||||
/* After a full GC that did not grow the heap, we have to update references
|
||||
to literals and other words. */
|
||||
struct small_code_heap_updater {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
|
||||
small_code_heap_updater(factor_vm *myvm_) : myvm(myvm_) {}
|
||||
small_code_heap_updater(factor_vm *parent_) : parent(parent_) {}
|
||||
|
||||
void operator()(heap_block *block)
|
||||
{
|
||||
myvm->update_code_block_for_full_gc((code_block *)block);
|
||||
parent->update_code_block_for_full_gc((code_block *)block);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@ namespace factor
|
|||
{
|
||||
|
||||
struct full_policy {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
zone *tenured;
|
||||
|
||||
full_policy(factor_vm *myvm_) : myvm(myvm_), tenured(myvm->data->tenured) {}
|
||||
full_policy(factor_vm *parent_) : parent(parent_), tenured(parent->data->tenured) {}
|
||||
|
||||
bool should_copy_p(object *untagged)
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ struct full_policy {
|
|||
struct full_collector : copying_collector<tenured_space,full_policy> {
|
||||
bool trace_contexts_p;
|
||||
|
||||
full_collector(factor_vm *myvm_);
|
||||
full_collector(factor_vm *parent_);
|
||||
void mark_active_blocks();
|
||||
void mark_object_code_block(object *object);
|
||||
void trace_callbacks();
|
||||
|
|
|
@ -205,9 +205,9 @@ void factor_vm::inline_gc(cell *gc_roots_base, cell gc_roots_size)
|
|||
gc_locals.pop_back();
|
||||
}
|
||||
|
||||
VM_C_API void inline_gc(cell *gc_roots_base, cell gc_roots_size, factor_vm *myvm)
|
||||
VM_C_API void inline_gc(cell *gc_roots_base, cell gc_roots_size, factor_vm *parent)
|
||||
{
|
||||
myvm->inline_gc(gc_roots_base,gc_roots_size);
|
||||
parent->inline_gc(gc_roots_base,gc_roots_size);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -37,6 +37,6 @@ struct gc_state {
|
|||
~gc_state();
|
||||
};
|
||||
|
||||
VM_C_API void inline_gc(cell *gc_roots_base, cell gc_roots_size, factor_vm *myvm);
|
||||
VM_C_API void inline_gc(cell *gc_roots_base, cell gc_roots_size, factor_vm *parent);
|
||||
|
||||
}
|
||||
|
|
26
vm/image.cpp
26
vm/image.cpp
|
@ -188,15 +188,15 @@ void factor_vm::fixup_alien(alien *d)
|
|||
}
|
||||
|
||||
struct stack_frame_fixupper {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
cell code_relocation_base;
|
||||
|
||||
explicit stack_frame_fixupper(factor_vm *myvm_, cell code_relocation_base_) :
|
||||
myvm(myvm_), code_relocation_base(code_relocation_base_) {}
|
||||
explicit stack_frame_fixupper(factor_vm *parent_, cell code_relocation_base_) :
|
||||
parent(parent_), code_relocation_base(code_relocation_base_) {}
|
||||
void operator()(stack_frame *frame)
|
||||
{
|
||||
myvm->code_fixup(&frame->xt,code_relocation_base);
|
||||
myvm->code_fixup(&FRAME_RETURN_ADDRESS(frame,myvm),code_relocation_base);
|
||||
parent->code_fixup(&frame->xt,code_relocation_base);
|
||||
parent->code_fixup(&FRAME_RETURN_ADDRESS(frame,parent),code_relocation_base);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -207,15 +207,15 @@ void factor_vm::fixup_callstack_object(callstack *stack, cell code_relocation_ba
|
|||
}
|
||||
|
||||
struct object_fixupper {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
cell data_relocation_base;
|
||||
|
||||
explicit object_fixupper(factor_vm *myvm_, cell data_relocation_base_) :
|
||||
myvm(myvm_), data_relocation_base(data_relocation_base_) { }
|
||||
explicit object_fixupper(factor_vm *parent_, cell data_relocation_base_) :
|
||||
parent(parent_), data_relocation_base(data_relocation_base_) { }
|
||||
|
||||
void operator()(cell *scan)
|
||||
{
|
||||
myvm->data_fixup(scan,data_relocation_base);
|
||||
parent->data_fixup(scan,data_relocation_base);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -299,15 +299,15 @@ void factor_vm::fixup_code_block(code_block *compiled, cell data_relocation_base
|
|||
}
|
||||
|
||||
struct code_block_fixupper {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
cell data_relocation_base;
|
||||
|
||||
code_block_fixupper(factor_vm *myvm_, cell data_relocation_base_) :
|
||||
myvm(myvm_), data_relocation_base(data_relocation_base_) { }
|
||||
code_block_fixupper(factor_vm *parent_, cell data_relocation_base_) :
|
||||
parent(parent_), data_relocation_base(data_relocation_base_) { }
|
||||
|
||||
void operator()(code_block *compiled)
|
||||
{
|
||||
myvm->fixup_code_block(compiled,data_relocation_base);
|
||||
parent->fixup_code_block(compiled,data_relocation_base);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -92,9 +92,9 @@ void inline_cache_jit::emit_check(cell klass)
|
|||
{
|
||||
cell code_template;
|
||||
if(TAG(klass) == FIXNUM_TYPE && untag_fixnum(klass) < HEADER_TYPE)
|
||||
code_template = parent_vm->userenv[PIC_CHECK_TAG];
|
||||
code_template = parent->userenv[PIC_CHECK_TAG];
|
||||
else
|
||||
code_template = parent_vm->userenv[PIC_CHECK];
|
||||
code_template = parent->userenv[PIC_CHECK];
|
||||
|
||||
emit_with(code_template,klass);
|
||||
}
|
||||
|
@ -107,12 +107,12 @@ void inline_cache_jit::compile_inline_cache(fixnum index,
|
|||
cell cache_entries_,
|
||||
bool tail_call_p)
|
||||
{
|
||||
gc_root<word> generic_word(generic_word_,parent_vm);
|
||||
gc_root<array> methods(methods_,parent_vm);
|
||||
gc_root<array> cache_entries(cache_entries_,parent_vm);
|
||||
gc_root<word> generic_word(generic_word_,parent);
|
||||
gc_root<array> methods(methods_,parent);
|
||||
gc_root<array> cache_entries(cache_entries_,parent);
|
||||
|
||||
cell inline_cache_type = parent_vm->determine_inline_cache_type(cache_entries.untagged());
|
||||
parent_vm->update_pic_count(inline_cache_type);
|
||||
cell inline_cache_type = parent->determine_inline_cache_type(cache_entries.untagged());
|
||||
parent->update_pic_count(inline_cache_type);
|
||||
|
||||
/* Generate machine code to determine the object's class. */
|
||||
emit_class_lookup(index,inline_cache_type);
|
||||
|
@ -127,7 +127,7 @@ void inline_cache_jit::compile_inline_cache(fixnum index,
|
|||
|
||||
/* Yes? Jump to method */
|
||||
cell method = array_nth(cache_entries.untagged(),i + 1);
|
||||
emit_with(parent_vm->userenv[PIC_HIT],method);
|
||||
emit_with(parent->userenv[PIC_HIT],method);
|
||||
}
|
||||
|
||||
/* Generate machine code to handle a cache miss, which ultimately results in
|
||||
|
@ -139,7 +139,7 @@ void inline_cache_jit::compile_inline_cache(fixnum index,
|
|||
push(methods.value());
|
||||
push(tag_fixnum(index));
|
||||
push(cache_entries.value());
|
||||
word_special(parent_vm->userenv[tail_call_p ? PIC_MISS_TAIL_WORD : PIC_MISS_WORD]);
|
||||
word_special(parent->userenv[tail_call_p ? PIC_MISS_TAIL_WORD : PIC_MISS_WORD]);
|
||||
}
|
||||
|
||||
code_block *factor_vm::compile_inline_cache(fixnum index,cell generic_word_,cell methods_,cell cache_entries_,bool tail_call_p)
|
||||
|
@ -248,9 +248,9 @@ void *factor_vm::inline_cache_miss(cell return_address)
|
|||
return xt;
|
||||
}
|
||||
|
||||
VM_C_API void *inline_cache_miss(cell return_address, factor_vm *myvm)
|
||||
VM_C_API void *inline_cache_miss(cell return_address, factor_vm *parent)
|
||||
{
|
||||
return myvm->inline_cache_miss(return_address);
|
||||
return parent->inline_cache_miss(return_address);
|
||||
}
|
||||
|
||||
void factor_vm::primitive_reset_inline_cache_stats()
|
||||
|
|
18
vm/jit.cpp
18
vm/jit.cpp
|
@ -19,12 +19,12 @@ jit::jit(cell type_, cell owner_, factor_vm *vm)
|
|||
computing_offset_p(false),
|
||||
position(0),
|
||||
offset(0),
|
||||
parent_vm(vm)
|
||||
parent(vm)
|
||||
{}
|
||||
|
||||
void jit::emit_relocation(cell code_template_)
|
||||
{
|
||||
gc_root<array> code_template(code_template_,parent_vm);
|
||||
gc_root<array> code_template(code_template_,parent);
|
||||
cell capacity = array_capacity(code_template.untagged());
|
||||
for(cell i = 1; i < capacity; i += 3)
|
||||
{
|
||||
|
@ -43,11 +43,11 @@ void jit::emit_relocation(cell code_template_)
|
|||
/* Allocates memory */
|
||||
void jit::emit(cell code_template_)
|
||||
{
|
||||
gc_root<array> code_template(code_template_,parent_vm);
|
||||
gc_root<array> code_template(code_template_,parent);
|
||||
|
||||
emit_relocation(code_template.value());
|
||||
|
||||
gc_root<byte_array> insns(array_nth(code_template.untagged(),0),parent_vm);
|
||||
gc_root<byte_array> insns(array_nth(code_template.untagged(),0),parent);
|
||||
|
||||
if(computing_offset_p)
|
||||
{
|
||||
|
@ -71,16 +71,16 @@ void jit::emit(cell code_template_)
|
|||
}
|
||||
|
||||
void jit::emit_with(cell code_template_, cell argument_) {
|
||||
gc_root<array> code_template(code_template_,parent_vm);
|
||||
gc_root<object> argument(argument_,parent_vm);
|
||||
gc_root<array> code_template(code_template_,parent);
|
||||
gc_root<object> argument(argument_,parent);
|
||||
literal(argument.value());
|
||||
emit(code_template.value());
|
||||
}
|
||||
|
||||
void jit::emit_class_lookup(fixnum index, cell type)
|
||||
{
|
||||
emit_with(parent_vm->userenv[PIC_LOAD],tag_fixnum(-index * sizeof(cell)));
|
||||
emit(parent_vm->userenv[type]);
|
||||
emit_with(parent->userenv[PIC_LOAD],tag_fixnum(-index * sizeof(cell)));
|
||||
emit(parent->userenv[type]);
|
||||
}
|
||||
|
||||
/* Facility to convert compiled code offsets to quotation offsets.
|
||||
|
@ -100,7 +100,7 @@ code_block *jit::to_code_block()
|
|||
relocation.trim();
|
||||
literals.trim();
|
||||
|
||||
return parent_vm->add_code_block(
|
||||
return parent->add_code_block(
|
||||
type,
|
||||
code.elements.value(),
|
||||
false_object, /* no labels */
|
||||
|
|
18
vm/jit.hpp
18
vm/jit.hpp
|
@ -10,7 +10,7 @@ struct jit {
|
|||
bool computing_offset_p;
|
||||
fixnum position;
|
||||
cell offset;
|
||||
factor_vm *parent_vm;
|
||||
factor_vm *parent;
|
||||
|
||||
explicit jit(cell jit_type, cell owner, factor_vm *vm);
|
||||
void compute_position(cell offset);
|
||||
|
@ -22,28 +22,28 @@ struct jit {
|
|||
void emit_with(cell code_template_, cell literal_);
|
||||
|
||||
void push(cell literal) {
|
||||
emit_with(parent_vm->userenv[JIT_PUSH_IMMEDIATE],literal);
|
||||
emit_with(parent->userenv[JIT_PUSH_IMMEDIATE],literal);
|
||||
}
|
||||
|
||||
void word_jump(cell word_) {
|
||||
gc_root<word> word(word_,parent_vm);
|
||||
gc_root<word> word(word_,parent);
|
||||
literal(tag_fixnum(xt_tail_pic_offset));
|
||||
literal(word.value());
|
||||
emit(parent_vm->userenv[JIT_WORD_JUMP]);
|
||||
emit(parent->userenv[JIT_WORD_JUMP]);
|
||||
}
|
||||
|
||||
void word_call(cell word) {
|
||||
emit_with(parent_vm->userenv[JIT_WORD_CALL],word);
|
||||
emit_with(parent->userenv[JIT_WORD_CALL],word);
|
||||
}
|
||||
|
||||
void word_special(cell word) {
|
||||
emit_with(parent_vm->userenv[JIT_WORD_SPECIAL],word);
|
||||
emit_with(parent->userenv[JIT_WORD_SPECIAL],word);
|
||||
}
|
||||
|
||||
void emit_subprimitive(cell word_) {
|
||||
gc_root<word> word(word_,parent_vm);
|
||||
gc_root<array> code_pair(word->subprimitive,parent_vm);
|
||||
literals.append(parent_vm->untag<array>(array_nth(code_pair.untagged(),0)));
|
||||
gc_root<word> word(word_,parent);
|
||||
gc_root<array> code_pair(word->subprimitive,parent);
|
||||
literals.append(parent->untag<array>(array_nth(code_pair.untagged(),0)));
|
||||
emit(array_nth(code_pair.untagged(),1));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,21 +4,21 @@ namespace factor
|
|||
template<typename Type>
|
||||
struct gc_root : public tagged<Type>
|
||||
{
|
||||
factor_vm *parent_vm;
|
||||
factor_vm *parent;
|
||||
|
||||
void push() { parent_vm->check_tagged_pointer(tagged<Type>::value()); parent_vm->gc_locals.push_back((cell)this); }
|
||||
void push() { parent->check_tagged_pointer(tagged<Type>::value()); parent->gc_locals.push_back((cell)this); }
|
||||
|
||||
explicit gc_root(cell value_,factor_vm *vm) : tagged<Type>(value_),parent_vm(vm) { push(); }
|
||||
explicit gc_root(Type *value_, factor_vm *vm) : tagged<Type>(value_),parent_vm(vm) { push(); }
|
||||
explicit gc_root(cell value_,factor_vm *vm) : tagged<Type>(value_),parent(vm) { push(); }
|
||||
explicit gc_root(Type *value_, factor_vm *vm) : tagged<Type>(value_),parent(vm) { push(); }
|
||||
|
||||
const gc_root<Type>& operator=(const Type *x) { tagged<Type>::operator=(x); return *this; }
|
||||
const gc_root<Type>& operator=(const cell &x) { tagged<Type>::operator=(x); return *this; }
|
||||
|
||||
~gc_root() {
|
||||
#ifdef FACTOR_DEBUG
|
||||
assert(parent_vm->gc_locals.back() == (cell)this);
|
||||
assert(parent->gc_locals.back() == (cell)this);
|
||||
#endif
|
||||
parent_vm->gc_locals.pop_back();
|
||||
parent->gc_locals.pop_back();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -26,18 +26,18 @@ struct gc_root : public tagged<Type>
|
|||
struct gc_bignum
|
||||
{
|
||||
bignum **addr;
|
||||
factor_vm *parent_vm;
|
||||
gc_bignum(bignum **addr_, factor_vm *vm) : addr(addr_), parent_vm(vm) {
|
||||
factor_vm *parent;
|
||||
gc_bignum(bignum **addr_, factor_vm *vm) : addr(addr_), parent(vm) {
|
||||
if(*addr_)
|
||||
parent_vm->check_data_pointer(*addr_);
|
||||
parent_vm->gc_bignums.push_back((cell)addr);
|
||||
parent->check_data_pointer(*addr_);
|
||||
parent->gc_bignums.push_back((cell)addr);
|
||||
}
|
||||
|
||||
~gc_bignum() {
|
||||
#ifdef FACTOR_DEBUG
|
||||
assert(parent_vm->gc_bignums.back() == (cell)addr);
|
||||
assert(parent->gc_bignums.back() == (cell)addr);
|
||||
#endif
|
||||
parent_vm->gc_bignums.pop_back();
|
||||
parent->gc_bignums.pop_back();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
88
vm/math.cpp
88
vm/math.cpp
|
@ -219,9 +219,9 @@ unsigned int factor_vm::bignum_producer(unsigned int digit)
|
|||
return *(ptr + digit);
|
||||
}
|
||||
|
||||
unsigned int bignum_producer(unsigned int digit, factor_vm *myvm)
|
||||
unsigned int bignum_producer(unsigned int digit, factor_vm *parent)
|
||||
{
|
||||
return myvm->bignum_producer(digit);
|
||||
return parent->bignum_producer(digit);
|
||||
}
|
||||
|
||||
void factor_vm::primitive_byte_array_to_bignum()
|
||||
|
@ -393,9 +393,9 @@ fixnum factor_vm::to_fixnum(cell tagged)
|
|||
}
|
||||
}
|
||||
|
||||
VM_C_API fixnum to_fixnum(cell tagged,factor_vm *myvm)
|
||||
VM_C_API fixnum to_fixnum(cell tagged,factor_vm *parent)
|
||||
{
|
||||
return myvm->to_fixnum(tagged);
|
||||
return parent->to_fixnum(tagged);
|
||||
}
|
||||
|
||||
cell factor_vm::to_cell(cell tagged)
|
||||
|
@ -403,9 +403,9 @@ cell factor_vm::to_cell(cell tagged)
|
|||
return (cell)to_fixnum(tagged);
|
||||
}
|
||||
|
||||
VM_C_API cell to_cell(cell tagged, factor_vm *myvm)
|
||||
VM_C_API cell to_cell(cell tagged, factor_vm *parent)
|
||||
{
|
||||
return myvm->to_cell(tagged);
|
||||
return parent->to_cell(tagged);
|
||||
}
|
||||
|
||||
void factor_vm::box_signed_1(s8 n)
|
||||
|
@ -413,9 +413,9 @@ void factor_vm::box_signed_1(s8 n)
|
|||
dpush(tag_fixnum(n));
|
||||
}
|
||||
|
||||
VM_C_API void box_signed_1(s8 n,factor_vm *myvm)
|
||||
VM_C_API void box_signed_1(s8 n,factor_vm *parent)
|
||||
{
|
||||
return myvm->box_signed_1(n);
|
||||
return parent->box_signed_1(n);
|
||||
}
|
||||
|
||||
void factor_vm::box_unsigned_1(u8 n)
|
||||
|
@ -423,9 +423,9 @@ void factor_vm::box_unsigned_1(u8 n)
|
|||
dpush(tag_fixnum(n));
|
||||
}
|
||||
|
||||
VM_C_API void box_unsigned_1(u8 n,factor_vm *myvm)
|
||||
VM_C_API void box_unsigned_1(u8 n,factor_vm *parent)
|
||||
{
|
||||
return myvm->box_unsigned_1(n);
|
||||
return parent->box_unsigned_1(n);
|
||||
}
|
||||
|
||||
void factor_vm::box_signed_2(s16 n)
|
||||
|
@ -433,9 +433,9 @@ void factor_vm::box_signed_2(s16 n)
|
|||
dpush(tag_fixnum(n));
|
||||
}
|
||||
|
||||
VM_C_API void box_signed_2(s16 n,factor_vm *myvm)
|
||||
VM_C_API void box_signed_2(s16 n,factor_vm *parent)
|
||||
{
|
||||
return myvm->box_signed_2(n);
|
||||
return parent->box_signed_2(n);
|
||||
}
|
||||
|
||||
void factor_vm::box_unsigned_2(u16 n)
|
||||
|
@ -443,9 +443,9 @@ void factor_vm::box_unsigned_2(u16 n)
|
|||
dpush(tag_fixnum(n));
|
||||
}
|
||||
|
||||
VM_C_API void box_unsigned_2(u16 n,factor_vm *myvm)
|
||||
VM_C_API void box_unsigned_2(u16 n,factor_vm *parent)
|
||||
{
|
||||
return myvm->box_unsigned_2(n);
|
||||
return parent->box_unsigned_2(n);
|
||||
}
|
||||
|
||||
void factor_vm::box_signed_4(s32 n)
|
||||
|
@ -453,9 +453,9 @@ void factor_vm::box_signed_4(s32 n)
|
|||
dpush(allot_integer(n));
|
||||
}
|
||||
|
||||
VM_C_API void box_signed_4(s32 n,factor_vm *myvm)
|
||||
VM_C_API void box_signed_4(s32 n,factor_vm *parent)
|
||||
{
|
||||
return myvm->box_signed_4(n);
|
||||
return parent->box_signed_4(n);
|
||||
}
|
||||
|
||||
void factor_vm::box_unsigned_4(u32 n)
|
||||
|
@ -463,9 +463,9 @@ void factor_vm::box_unsigned_4(u32 n)
|
|||
dpush(allot_cell(n));
|
||||
}
|
||||
|
||||
VM_C_API void box_unsigned_4(u32 n,factor_vm *myvm)
|
||||
VM_C_API void box_unsigned_4(u32 n,factor_vm *parent)
|
||||
{
|
||||
return myvm->box_unsigned_4(n);
|
||||
return parent->box_unsigned_4(n);
|
||||
}
|
||||
|
||||
void factor_vm::box_signed_cell(fixnum integer)
|
||||
|
@ -473,9 +473,9 @@ void factor_vm::box_signed_cell(fixnum integer)
|
|||
dpush(allot_integer(integer));
|
||||
}
|
||||
|
||||
VM_C_API void box_signed_cell(fixnum integer,factor_vm *myvm)
|
||||
VM_C_API void box_signed_cell(fixnum integer,factor_vm *parent)
|
||||
{
|
||||
return myvm->box_signed_cell(integer);
|
||||
return parent->box_signed_cell(integer);
|
||||
}
|
||||
|
||||
void factor_vm::box_unsigned_cell(cell cell)
|
||||
|
@ -483,9 +483,9 @@ void factor_vm::box_unsigned_cell(cell cell)
|
|||
dpush(allot_cell(cell));
|
||||
}
|
||||
|
||||
VM_C_API void box_unsigned_cell(cell cell,factor_vm *myvm)
|
||||
VM_C_API void box_unsigned_cell(cell cell,factor_vm *parent)
|
||||
{
|
||||
return myvm->box_unsigned_cell(cell);
|
||||
return parent->box_unsigned_cell(cell);
|
||||
}
|
||||
|
||||
void factor_vm::box_signed_8(s64 n)
|
||||
|
@ -496,9 +496,9 @@ void factor_vm::box_signed_8(s64 n)
|
|||
dpush(tag_fixnum(n));
|
||||
}
|
||||
|
||||
VM_C_API void box_signed_8(s64 n,factor_vm *myvm)
|
||||
VM_C_API void box_signed_8(s64 n,factor_vm *parent)
|
||||
{
|
||||
return myvm->box_signed_8(n);
|
||||
return parent->box_signed_8(n);
|
||||
}
|
||||
|
||||
s64 factor_vm::to_signed_8(cell obj)
|
||||
|
@ -515,9 +515,9 @@ s64 factor_vm::to_signed_8(cell obj)
|
|||
}
|
||||
}
|
||||
|
||||
VM_C_API s64 to_signed_8(cell obj,factor_vm *myvm)
|
||||
VM_C_API s64 to_signed_8(cell obj,factor_vm *parent)
|
||||
{
|
||||
return myvm->to_signed_8(obj);
|
||||
return parent->to_signed_8(obj);
|
||||
}
|
||||
|
||||
void factor_vm::box_unsigned_8(u64 n)
|
||||
|
@ -528,9 +528,9 @@ void factor_vm::box_unsigned_8(u64 n)
|
|||
dpush(tag_fixnum(n));
|
||||
}
|
||||
|
||||
VM_C_API void box_unsigned_8(u64 n,factor_vm *myvm)
|
||||
VM_C_API void box_unsigned_8(u64 n,factor_vm *parent)
|
||||
{
|
||||
return myvm->box_unsigned_8(n);
|
||||
return parent->box_unsigned_8(n);
|
||||
}
|
||||
|
||||
u64 factor_vm::to_unsigned_8(cell obj)
|
||||
|
@ -547,9 +547,9 @@ u64 factor_vm::to_unsigned_8(cell obj)
|
|||
}
|
||||
}
|
||||
|
||||
VM_C_API u64 to_unsigned_8(cell obj,factor_vm *myvm)
|
||||
VM_C_API u64 to_unsigned_8(cell obj,factor_vm *parent)
|
||||
{
|
||||
return myvm->to_unsigned_8(obj);
|
||||
return parent->to_unsigned_8(obj);
|
||||
}
|
||||
|
||||
void factor_vm::box_float(float flo)
|
||||
|
@ -557,9 +557,9 @@ void factor_vm::box_float(float flo)
|
|||
dpush(allot_float(flo));
|
||||
}
|
||||
|
||||
VM_C_API void box_float(float flo, factor_vm *myvm)
|
||||
VM_C_API void box_float(float flo, factor_vm *parent)
|
||||
{
|
||||
return myvm->box_float(flo);
|
||||
return parent->box_float(flo);
|
||||
}
|
||||
|
||||
float factor_vm::to_float(cell value)
|
||||
|
@ -567,9 +567,9 @@ float factor_vm::to_float(cell value)
|
|||
return untag_float_check(value);
|
||||
}
|
||||
|
||||
VM_C_API float to_float(cell value,factor_vm *myvm)
|
||||
VM_C_API float to_float(cell value,factor_vm *parent)
|
||||
{
|
||||
return myvm->to_float(value);
|
||||
return parent->to_float(value);
|
||||
}
|
||||
|
||||
void factor_vm::box_double(double flo)
|
||||
|
@ -577,9 +577,9 @@ void factor_vm::box_double(double flo)
|
|||
dpush(allot_float(flo));
|
||||
}
|
||||
|
||||
VM_C_API void box_double(double flo,factor_vm *myvm)
|
||||
VM_C_API void box_double(double flo,factor_vm *parent)
|
||||
{
|
||||
return myvm->box_double(flo);
|
||||
return parent->box_double(flo);
|
||||
}
|
||||
|
||||
double factor_vm::to_double(cell value)
|
||||
|
@ -587,9 +587,9 @@ double factor_vm::to_double(cell value)
|
|||
return untag_float_check(value);
|
||||
}
|
||||
|
||||
VM_C_API double to_double(cell value,factor_vm *myvm)
|
||||
VM_C_API double to_double(cell value,factor_vm *parent)
|
||||
{
|
||||
return myvm->to_double(value);
|
||||
return parent->to_double(value);
|
||||
}
|
||||
|
||||
/* The fixnum+, fixnum- and fixnum* primitives are defined in cpu_*.S. On
|
||||
|
@ -600,9 +600,9 @@ inline void factor_vm::overflow_fixnum_add(fixnum x, fixnum y)
|
|||
untag_fixnum(x) + untag_fixnum(y))));
|
||||
}
|
||||
|
||||
VM_ASM_API void overflow_fixnum_add(fixnum x, fixnum y, factor_vm *myvm)
|
||||
VM_ASM_API void overflow_fixnum_add(fixnum x, fixnum y, factor_vm *parent)
|
||||
{
|
||||
((factor_vm*)myvm)->overflow_fixnum_add(x,y);
|
||||
parent->overflow_fixnum_add(x,y);
|
||||
}
|
||||
|
||||
inline void factor_vm::overflow_fixnum_subtract(fixnum x, fixnum y)
|
||||
|
@ -611,9 +611,9 @@ inline void factor_vm::overflow_fixnum_subtract(fixnum x, fixnum y)
|
|||
untag_fixnum(x) - untag_fixnum(y))));
|
||||
}
|
||||
|
||||
VM_ASM_API void overflow_fixnum_subtract(fixnum x, fixnum y, factor_vm *myvm)
|
||||
VM_ASM_API void overflow_fixnum_subtract(fixnum x, fixnum y, factor_vm *parent)
|
||||
{
|
||||
((factor_vm*)myvm)->overflow_fixnum_subtract(x,y);
|
||||
parent->overflow_fixnum_subtract(x,y);
|
||||
}
|
||||
|
||||
inline void factor_vm::overflow_fixnum_multiply(fixnum x, fixnum y)
|
||||
|
@ -625,9 +625,9 @@ inline void factor_vm::overflow_fixnum_multiply(fixnum x, fixnum y)
|
|||
drepl(tag<bignum>(bignum_multiply(bx,by)));
|
||||
}
|
||||
|
||||
VM_ASM_API void overflow_fixnum_multiply(fixnum x, fixnum y, factor_vm *myvm)
|
||||
VM_ASM_API void overflow_fixnum_multiply(fixnum x, fixnum y, factor_vm *parent)
|
||||
{
|
||||
((factor_vm*)myvm)->overflow_fixnum_multiply(x,y);
|
||||
parent->overflow_fixnum_multiply(x,y);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
namespace factor
|
||||
{
|
||||
|
||||
nursery_collector::nursery_collector(factor_vm *myvm_) :
|
||||
nursery_collector::nursery_collector(factor_vm *parent_) :
|
||||
copying_collector<aging_space,nursery_policy>(
|
||||
myvm_,
|
||||
&myvm_->gc_stats.nursery_stats,
|
||||
myvm_->data->aging,
|
||||
nursery_policy(myvm_)) {}
|
||||
parent_,
|
||||
&parent_->gc_stats.nursery_stats,
|
||||
parent_->data->aging,
|
||||
nursery_policy(parent_)) {}
|
||||
|
||||
void factor_vm::collect_nursery()
|
||||
{
|
||||
|
|
|
@ -2,18 +2,18 @@ namespace factor
|
|||
{
|
||||
|
||||
struct nursery_policy {
|
||||
factor_vm *myvm;
|
||||
factor_vm *parent;
|
||||
|
||||
nursery_policy(factor_vm *myvm_) : myvm(myvm_) {}
|
||||
nursery_policy(factor_vm *parent_) : parent(parent_) {}
|
||||
|
||||
bool should_copy_p(object *untagged)
|
||||
{
|
||||
return myvm->nursery.contains_p(untagged);
|
||||
return parent->nursery.contains_p(untagged);
|
||||
}
|
||||
};
|
||||
|
||||
struct nursery_collector : copying_collector<aging_space,nursery_policy> {
|
||||
nursery_collector(factor_vm *myvm_);
|
||||
nursery_collector(factor_vm *parent_);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -62,9 +62,9 @@ void old_space::clear_object_start_offsets()
|
|||
memset(object_start_offsets,card_starts_inside_object,addr_to_card(size));
|
||||
}
|
||||
|
||||
cell old_space::next_object_after(factor_vm *myvm, cell scan)
|
||||
cell old_space::next_object_after(factor_vm *parent, cell scan)
|
||||
{
|
||||
cell size = myvm->untagged_object_size((object *)scan);
|
||||
cell size = parent->untagged_object_size((object *)scan);
|
||||
if(scan + size < here)
|
||||
return scan + size;
|
||||
else
|
||||
|
|
|
@ -15,7 +15,7 @@ struct old_space : zone {
|
|||
void record_object_start_offset(object *obj);
|
||||
object *allot(cell size);
|
||||
void clear_object_start_offsets();
|
||||
cell next_object_after(factor_vm *myvm, cell scan);
|
||||
cell next_object_after(factor_vm *parent, cell scan);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -45,19 +45,19 @@ VM_C_API int inotify_rm_watch(int fd, u32 wd)
|
|||
|
||||
VM_C_API int inotify_init()
|
||||
{
|
||||
myvm->not_implemented_error();
|
||||
parent->not_implemented_error();
|
||||
return -1;
|
||||
}
|
||||
|
||||
VM_C_API int inotify_add_watch(int fd, const char *name, u32 mask)
|
||||
{
|
||||
myvm->not_implemented_error();
|
||||
parent->not_implemented_error();
|
||||
return -1;
|
||||
}
|
||||
|
||||
VM_C_API int inotify_rm_watch(int fd, u32 wd)
|
||||
{
|
||||
myvm->not_implemented_error();
|
||||
parent->not_implemented_error();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,18 +2,18 @@ namespace factor
|
|||
{
|
||||
|
||||
#if defined(FACTOR_X86)
|
||||
extern "C" __attribute__ ((regparm (1))) typedef void (*primitive_type)(void *myvm);
|
||||
#define PRIMITIVE(name) extern "C" __attribute__ ((regparm (1))) void primitive_##name(void *myvm)
|
||||
#define PRIMITIVE_FORWARD(name) extern "C" __attribute__ ((regparm (1))) void primitive_##name(void *myvm) \
|
||||
{ \
|
||||
((factor_vm*)myvm)->primitive_##name(); \
|
||||
extern "C" __attribute__ ((regparm (1))) typedef void (*primitive_type)(factor_vm *parent);
|
||||
#define PRIMITIVE(name) extern "C" __attribute__ ((regparm (1))) void primitive_##name(factor_vm *parent)
|
||||
#define PRIMITIVE_FORWARD(name) extern "C" __attribute__ ((regparm (1))) void primitive_##name(factor_vm *parent) \
|
||||
{ \
|
||||
parent->primitive_##name(); \
|
||||
}
|
||||
#else
|
||||
extern "C" typedef void (*primitive_type)(void *myvm);
|
||||
#define PRIMITIVE(name) extern "C" void primitive_##name(void *myvm)
|
||||
#define PRIMITIVE_FORWARD(name) extern "C" void primitive_##name(void *myvm) \
|
||||
{ \
|
||||
((factor_vm*)myvm)->primitive_##name(); \
|
||||
extern "C" typedef void (*primitive_type)(factor_vm *parent);
|
||||
#define PRIMITIVE(name) extern "C" void primitive_##name(factor_vm *parent)
|
||||
#define PRIMITIVE_FORWARD(name) extern "C" void primitive_##name(factor_vm *parent) \
|
||||
{ \
|
||||
parent->primitive_##name(); \
|
||||
}
|
||||
#endif
|
||||
extern const primitive_type primitives[];
|
||||
|
|
|
@ -38,29 +38,29 @@ so this results in a big speedup for relatively little effort. */
|
|||
|
||||
bool quotation_jit::primitive_call_p(cell i, cell length)
|
||||
{
|
||||
return (i + 2) == length && array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_PRIMITIVE_WORD];
|
||||
return (i + 2) == length && array_nth(elements.untagged(),i + 1) == parent->userenv[JIT_PRIMITIVE_WORD];
|
||||
}
|
||||
|
||||
bool quotation_jit::fast_if_p(cell i, cell length)
|
||||
{
|
||||
return (i + 3) == length
|
||||
&& tagged<object>(array_nth(elements.untagged(),i + 1)).type_p(QUOTATION_TYPE)
|
||||
&& array_nth(elements.untagged(),i + 2) == parent_vm->userenv[JIT_IF_WORD];
|
||||
&& array_nth(elements.untagged(),i + 2) == parent->userenv[JIT_IF_WORD];
|
||||
}
|
||||
|
||||
bool quotation_jit::fast_dip_p(cell i, cell length)
|
||||
{
|
||||
return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_DIP_WORD];
|
||||
return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent->userenv[JIT_DIP_WORD];
|
||||
}
|
||||
|
||||
bool quotation_jit::fast_2dip_p(cell i, cell length)
|
||||
{
|
||||
return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_2DIP_WORD];
|
||||
return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent->userenv[JIT_2DIP_WORD];
|
||||
}
|
||||
|
||||
bool quotation_jit::fast_3dip_p(cell i, cell length)
|
||||
{
|
||||
return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_3DIP_WORD];
|
||||
return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent->userenv[JIT_3DIP_WORD];
|
||||
}
|
||||
|
||||
bool quotation_jit::mega_lookup_p(cell i, cell length)
|
||||
|
@ -68,13 +68,13 @@ bool quotation_jit::mega_lookup_p(cell i, cell length)
|
|||
return (i + 4) <= length
|
||||
&& tagged<object>(array_nth(elements.untagged(),i + 1)).type_p(FIXNUM_TYPE)
|
||||
&& tagged<object>(array_nth(elements.untagged(),i + 2)).type_p(ARRAY_TYPE)
|
||||
&& array_nth(elements.untagged(),i + 3) == parent_vm->userenv[MEGA_LOOKUP_WORD];
|
||||
&& array_nth(elements.untagged(),i + 3) == parent->userenv[MEGA_LOOKUP_WORD];
|
||||
}
|
||||
|
||||
bool quotation_jit::declare_p(cell i, cell length)
|
||||
{
|
||||
return (i + 2) <= length
|
||||
&& array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_DECLARE_WORD];
|
||||
&& array_nth(elements.untagged(),i + 1) == parent->userenv[JIT_DECLARE_WORD];
|
||||
}
|
||||
|
||||
bool quotation_jit::stack_frame_p()
|
||||
|
@ -88,7 +88,7 @@ bool quotation_jit::stack_frame_p()
|
|||
switch(tagged<object>(obj).type())
|
||||
{
|
||||
case WORD_TYPE:
|
||||
if(!parent_vm->to_boolean(parent_vm->untag<word>(obj)->subprimitive))
|
||||
if(!parent->to_boolean(parent->untag<word>(obj)->subprimitive))
|
||||
return true;
|
||||
break;
|
||||
case QUOTATION_TYPE:
|
||||
|
@ -110,9 +110,9 @@ bool quotation_jit::trivial_quotation_p(array *elements)
|
|||
|
||||
void quotation_jit::emit_quot(cell quot_)
|
||||
{
|
||||
gc_root<quotation> quot(quot_,parent_vm);
|
||||
gc_root<quotation> quot(quot_,parent);
|
||||
|
||||
array *elements = parent_vm->untag<array>(quot->array);
|
||||
array *elements = parent->untag<array>(quot->array);
|
||||
|
||||
/* If the quotation consists of a single word, compile a direct call
|
||||
to the word. */
|
||||
|
@ -120,7 +120,7 @@ void quotation_jit::emit_quot(cell quot_)
|
|||
literal(array_nth(elements,0));
|
||||
else
|
||||
{
|
||||
if(compiling) parent_vm->jit_compile(quot.value(),relocate);
|
||||
if(compiling) parent->jit_compile(quot.value(),relocate);
|
||||
literal(quot.value());
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ void quotation_jit::iterate_quotation()
|
|||
set_position(0);
|
||||
|
||||
if(stack_frame)
|
||||
emit(parent_vm->userenv[JIT_PROLOG]);
|
||||
emit(parent->userenv[JIT_PROLOG]);
|
||||
|
||||
cell i;
|
||||
cell length = array_capacity(elements.untagged());
|
||||
|
@ -143,32 +143,32 @@ void quotation_jit::iterate_quotation()
|
|||
{
|
||||
set_position(i);
|
||||
|
||||
gc_root<object> obj(array_nth(elements.untagged(),i),parent_vm);
|
||||
gc_root<object> obj(array_nth(elements.untagged(),i),parent);
|
||||
|
||||
switch(obj.type())
|
||||
{
|
||||
case WORD_TYPE:
|
||||
/* Intrinsics */
|
||||
if(parent_vm->to_boolean(obj.as<word>()->subprimitive))
|
||||
if(parent->to_boolean(obj.as<word>()->subprimitive))
|
||||
emit_subprimitive(obj.value());
|
||||
/* The (execute) primitive is special-cased */
|
||||
else if(obj.value() == parent_vm->userenv[JIT_EXECUTE_WORD])
|
||||
else if(obj.value() == parent->userenv[JIT_EXECUTE_WORD])
|
||||
{
|
||||
if(i == length - 1)
|
||||
{
|
||||
if(stack_frame) emit(parent_vm->userenv[JIT_EPILOG]);
|
||||
if(stack_frame) emit(parent->userenv[JIT_EPILOG]);
|
||||
tail_call = true;
|
||||
emit(parent_vm->userenv[JIT_EXECUTE_JUMP]);
|
||||
emit(parent->userenv[JIT_EXECUTE_JUMP]);
|
||||
}
|
||||
else
|
||||
emit(parent_vm->userenv[JIT_EXECUTE_CALL]);
|
||||
emit(parent->userenv[JIT_EXECUTE_CALL]);
|
||||
}
|
||||
/* Everything else */
|
||||
else
|
||||
{
|
||||
if(i == length - 1)
|
||||
{
|
||||
if(stack_frame) emit(parent_vm->userenv[JIT_EPILOG]);
|
||||
if(stack_frame) emit(parent->userenv[JIT_EPILOG]);
|
||||
tail_call = true;
|
||||
/* Inline cache misses are special-cased.
|
||||
The calling convention for tail
|
||||
|
@ -178,8 +178,8 @@ void quotation_jit::iterate_quotation()
|
|||
the inline cache miss primitive, and
|
||||
we don't want to clobber the saved
|
||||
address. */
|
||||
if(obj.value() == parent_vm->userenv[PIC_MISS_WORD]
|
||||
|| obj.value() == parent_vm->userenv[PIC_MISS_TAIL_WORD])
|
||||
if(obj.value() == parent->userenv[PIC_MISS_WORD]
|
||||
|| obj.value() == parent->userenv[PIC_MISS_TAIL_WORD])
|
||||
{
|
||||
word_special(obj.value());
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ void quotation_jit::iterate_quotation()
|
|||
{
|
||||
literal(tag_fixnum(0));
|
||||
literal(obj.value());
|
||||
emit(parent_vm->userenv[JIT_PRIMITIVE]);
|
||||
emit(parent->userenv[JIT_PRIMITIVE]);
|
||||
|
||||
i++;
|
||||
|
||||
|
@ -215,12 +215,12 @@ void quotation_jit::iterate_quotation()
|
|||
mutually recursive in the library, but both still work) */
|
||||
if(fast_if_p(i,length))
|
||||
{
|
||||
if(stack_frame) emit(parent_vm->userenv[JIT_EPILOG]);
|
||||
if(stack_frame) emit(parent->userenv[JIT_EPILOG]);
|
||||
tail_call = true;
|
||||
|
||||
emit_quot(array_nth(elements.untagged(),i));
|
||||
emit_quot(array_nth(elements.untagged(),i + 1));
|
||||
emit(parent_vm->userenv[JIT_IF]);
|
||||
emit(parent->userenv[JIT_IF]);
|
||||
|
||||
i += 2;
|
||||
}
|
||||
|
@ -228,21 +228,21 @@ void quotation_jit::iterate_quotation()
|
|||
else if(fast_dip_p(i,length))
|
||||
{
|
||||
emit_quot(obj.value());
|
||||
emit(parent_vm->userenv[JIT_DIP]);
|
||||
emit(parent->userenv[JIT_DIP]);
|
||||
i++;
|
||||
}
|
||||
/* 2dip */
|
||||
else if(fast_2dip_p(i,length))
|
||||
{
|
||||
emit_quot(obj.value());
|
||||
emit(parent_vm->userenv[JIT_2DIP]);
|
||||
emit(parent->userenv[JIT_2DIP]);
|
||||
i++;
|
||||
}
|
||||
/* 3dip */
|
||||
else if(fast_3dip_p(i,length))
|
||||
{
|
||||
emit_quot(obj.value());
|
||||
emit(parent_vm->userenv[JIT_3DIP]);
|
||||
emit(parent->userenv[JIT_3DIP]);
|
||||
i++;
|
||||
}
|
||||
else
|
||||
|
@ -276,8 +276,8 @@ void quotation_jit::iterate_quotation()
|
|||
set_position(length);
|
||||
|
||||
if(stack_frame)
|
||||
emit(parent_vm->userenv[JIT_EPILOG]);
|
||||
emit(parent_vm->userenv[JIT_RETURN]);
|
||||
emit(parent->userenv[JIT_EPILOG]);
|
||||
emit(parent->userenv[JIT_RETURN]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,9 +367,9 @@ cell factor_vm::lazy_jit_compile_impl(cell quot_, stack_frame *stack)
|
|||
return quot.value();
|
||||
}
|
||||
|
||||
VM_ASM_API cell lazy_jit_compile_impl(cell quot_, stack_frame *stack, factor_vm *myvm)
|
||||
VM_ASM_API cell lazy_jit_compile_impl(cell quot_, stack_frame *stack, factor_vm *parent)
|
||||
{
|
||||
return myvm->lazy_jit_compile_impl(quot_,stack);
|
||||
return parent->lazy_jit_compile_impl(quot_,stack);
|
||||
}
|
||||
|
||||
void factor_vm::primitive_quot_compiled_p()
|
||||
|
|
|
@ -25,6 +25,6 @@ struct quotation_jit : public jit {
|
|||
void iterate_quotation();
|
||||
};
|
||||
|
||||
VM_ASM_API cell lazy_jit_compile_impl(cell quot, stack_frame *stack, factor_vm *myvm);
|
||||
VM_ASM_API cell lazy_jit_compile_impl(cell quot, stack_frame *stack, factor_vm *parent);
|
||||
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@ struct tagged
|
|||
|
||||
bool type_p(cell type_) const { return type() == type_; }
|
||||
|
||||
Type *untag_check(factor_vm *myvm) const {
|
||||
Type *untag_check(factor_vm *parent) const {
|
||||
if(Type::type_number != TYPE_COUNT && !type_p(Type::type_number))
|
||||
myvm->type_error(Type::type_number,value_);
|
||||
parent->type_error(Type::type_number,value_);
|
||||
return untagged();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue