Dev checkpoint

db4
Phil Dawes 2009-08-17 21:37:14 +01:00
parent baaf71eddc
commit d5da6a3d58
9 changed files with 68 additions and 47 deletions

View File

@ -194,10 +194,10 @@ struct stack_frame_accumulator {
stack_frame_accumulator(factorvm *vm) : frames(vm) {}
void operator()(stack_frame *frame)
void operator()(stack_frame *frame, factorvm *myvm)
{
gc_root<object> executing(frame_executing(frame),frames.elements.myvm);
gc_root<object> scan(frame_scan(frame),frames.elements.myvm);
gc_root<object> executing(frame_executing(frame),myvm);
gc_root<object> scan(frame_scan(frame),myvm);
frames.add(executing.value());
frames.add(scan.value());

View File

@ -22,16 +22,6 @@ PRIMITIVE(set_innermost_stack_frame_quot);
VM_ASM_API void save_callstack_bottom(stack_frame *callstack_bottom);
template<typename T> void iterate_callstack(cell top, cell bottom, T &iterator)
{
stack_frame *frame = (stack_frame *)bottom - 1;
while((cell)frame >= top)
{
iterator(frame);
frame = frame_successor(frame);
}
}
}

View File

@ -137,9 +137,9 @@ void factorvm::undefined_symbol()
general_error(ERROR_UNDEFINED_SYMBOL,F,F,NULL);
}
void undefined_symbol()
void undefined_symbol(factorvm *myvm)
{
return vm->undefined_symbol();
return myvm->undefined_symbol();
}
/* Look up an external library symbol referenced by a compiled code block */
@ -509,9 +509,9 @@ void factorvm::mark_stack_frame_step(stack_frame *frame)
mark_code_block(frame_code(frame));
}
void mark_stack_frame_step(stack_frame *frame)
void mark_stack_frame_step(stack_frame *frame, factorvm *myvm)
{
return vm->mark_stack_frame_step(frame);
return myvm->mark_stack_frame_step(frame);
}
/* Mark code blocks executing in currently active stack frames. */

View File

@ -176,9 +176,9 @@ void factorvm::forward_frame_xt(stack_frame *frame)
FRAME_RETURN_ADDRESS(frame) = (void *)((cell)forwarded + offset);
}
void forward_frame_xt(stack_frame *frame)
void forward_frame_xt(stack_frame *frame,factorvm *myvm)
{
return vm->forward_frame_xt(frame);
return myvm->forward_frame_xt(frame);
}
void factorvm::forward_object_xts()

View File

@ -98,23 +98,6 @@ PRIMITIVE(end_scan);
cell find_all_words();
/* Every object has a regular representation in the runtime, which makes GC
much simpler. Every slot of the object until binary_payload_start is a pointer
to some other object. */
inline static void do_slots(cell obj, void (* iter)(cell *))
{
cell scan = obj;
cell payload_start = binary_payload_start((object *)obj);
cell end = obj + payload_start;
scan += sizeof(cell);
while(scan < end)
{
iter((cell *)scan);
scan += sizeof(cell);
}
}
}

View File

@ -232,9 +232,9 @@ void factorvm::print_stack_frame(stack_frame *frame)
print_string("\n");
}
void print_stack_frame(stack_frame *frame)
void print_stack_frame(stack_frame *frame, factorvm *myvm)
{
return vm->print_stack_frame(frame);
return myvm->print_stack_frame(frame);
}
void factorvm::print_callstack()
@ -356,9 +356,9 @@ void factorvm::find_data_references_step(cell *scan)
}
}
void find_data_references_step(cell *scan)
void find_data_references_step(cell *scan,factorvm *myvm)
{
return vm->find_data_references_step(scan);
return myvm->find_data_references_step(scan);
}
void factorvm::find_data_references(cell look_for_)

View File

@ -195,9 +195,9 @@ void factorvm::data_fixup(cell *cell)
*cell += (tenured->start - data_relocation_base);
}
void data_fixup(cell *cell)
void data_fixup(cell *cell, factorvm *myvm)
{
return vm->data_fixup(cell);
return myvm->data_fixup(cell);
}
template <typename TYPE> void factorvm::code_fixup(TYPE **handle)
@ -258,9 +258,9 @@ void factorvm::fixup_stack_frame(stack_frame *frame)
code_fixup(&FRAME_RETURN_ADDRESS(frame));
}
void fixup_stack_frame(stack_frame *frame)
void fixup_stack_frame(stack_frame *frame, factorvm *myvm)
{
return vm->fixup_stack_frame(frame);
return myvm->fixup_stack_frame(frame);
}
void factorvm::fixup_callstack_object(callstack *stack)

View File

@ -367,7 +367,8 @@ unsigned int bignum_producer(unsigned int digit)
inline void factorvm::vmprim_byte_array_to_bignum()
{
cell n_digits = array_capacity(untag_check<byte_array>(dpeek()));
bignum * result = factor::digit_stream_to_bignum(n_digits,factor::bignum_producer,0x100,0);
// bignum * result = factor::digit_stream_to_bignum(n_digits,factor::bignum_producer,0x100,0);
bignum * result = digit_stream_to_bignum(n_digits,factor::bignum_producer,0x100,0);
drepl(tag<bignum>(result));
}

View File

@ -61,6 +61,8 @@ struct factorvm {
void type_error(cell type, cell tagged);
void general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *callstack_top);
//callstack
// bignum
int bignum_equal_p(bignum * x, bignum * y);
enum bignum_comparison bignum_compare(bignum * x, bignum * y);
@ -530,6 +532,10 @@ struct factorvm {
inline void vmprim_innermost_stack_frame_scan();
inline void vmprim_set_innermost_stack_frame_quot();
void save_callstack_bottom(stack_frame *callstack_bottom);
template<typename T> void iterate_callstack(cell top, cell bottom, T &iterator);
inline void do_slots(cell obj, void (* iter)(cell *,factorvm*));
// next method here:
//alien
char *pinned_alien_offset(cell obj);
@ -1066,7 +1072,7 @@ template<typename TYPE> void factorvm::iterate_callstack_object(callstack *stack
{
stack_frame *frame = stack->frame_at(frame_offset);
frame_offset -= frame->size;
iterator(frame);
iterator(frame,this);
}
}
@ -1086,7 +1092,48 @@ inline cell tag_boolean(cell untagged)
return vm->tag_boolean(untagged);
}
// next method here:
// callstack.hpp
template<typename TYPE> void factorvm::iterate_callstack(cell top, cell bottom, TYPE &iterator)
{
stack_frame *frame = (stack_frame *)bottom - 1;
while((cell)frame >= top)
{
iterator(frame,this);
frame = frame_successor(frame);
}
}
template<typename TYPE> void iterate_callstack(cell top, cell bottom, TYPE &iterator)
{
return vm->iterate_callstack(top,bottom,iterator);
}
// data_heap.hpp
/* Every object has a regular representation in the runtime, which makes GC
much simpler. Every slot of the object until binary_payload_start is a pointer
to some other object. */
struct factorvm;
inline void factorvm::do_slots(cell obj, void (* iter)(cell *,factorvm*))
{
cell scan = obj;
cell payload_start = binary_payload_start((object *)obj);
cell end = obj + payload_start;
scan += sizeof(cell);
while(scan < end)
{
iter((cell *)scan,this);
scan += sizeof(cell);
}
}
inline void do_slots(cell obj, void (* iter)(cell *,factorvm*))
{
return vm->do_slots(obj,iter);
}
}