diff --git a/vm/callstack.cpp b/vm/callstack.cpp index e4f03abca9..8df438206c 100755 --- a/vm/callstack.cpp +++ b/vm/callstack.cpp @@ -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 executing(frame_executing(frame),frames.elements.myvm); - gc_root scan(frame_scan(frame),frames.elements.myvm); + gc_root executing(frame_executing(frame),myvm); + gc_root scan(frame_scan(frame),myvm); frames.add(executing.value()); frames.add(scan.value()); diff --git a/vm/callstack.hpp b/vm/callstack.hpp index ee097b528c..82fb93a1bc 100755 --- a/vm/callstack.hpp +++ b/vm/callstack.hpp @@ -22,16 +22,6 @@ PRIMITIVE(set_innermost_stack_frame_quot); VM_ASM_API void save_callstack_bottom(stack_frame *callstack_bottom); -template 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); - } -} } diff --git a/vm/code_block.cpp b/vm/code_block.cpp index 9486d7f3b3..b8d4621d38 100755 --- a/vm/code_block.cpp +++ b/vm/code_block.cpp @@ -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. */ diff --git a/vm/code_heap.cpp b/vm/code_heap.cpp index 9399c9ae70..fb24af4044 100755 --- a/vm/code_heap.cpp +++ b/vm/code_heap.cpp @@ -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() diff --git a/vm/data_heap.hpp b/vm/data_heap.hpp index 2bec35b8c1..67e3109924 100755 --- a/vm/data_heap.hpp +++ b/vm/data_heap.hpp @@ -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); - } -} } diff --git a/vm/debug.cpp b/vm/debug.cpp index 5d033fd90e..eb64ad22d4 100755 --- a/vm/debug.cpp +++ b/vm/debug.cpp @@ -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_) diff --git a/vm/image.cpp b/vm/image.cpp index ee86dd5a3f..b8e89d5fcb 100755 --- a/vm/image.cpp +++ b/vm/image.cpp @@ -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 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) diff --git a/vm/math.cpp b/vm/math.cpp index 74caec3074..ed556f268a 100755 --- a/vm/math.cpp +++ b/vm/math.cpp @@ -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(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(result)); } diff --git a/vm/vm.hpp b/vm/vm.hpp index d0f31e4d3f..42a250832c 100644 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -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 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 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 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 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); +} }