From: Phil Dawes Date: Sat, 22 Aug 2009 10:15:58 +0000 (+0100) Subject: removed all vm-> singleton accesses from inlineimpls X-Git-Tag: 0.97~5502^2~2^2~56 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=7759b89de9e70a31d47b76284bc7320d0f942d64 removed all vm-> singleton accesses from inlineimpls --- diff --git a/vm/arrays.cpp b/vm/arrays.cpp index 62992c4e7c..3052563dea 100644 --- a/vm/arrays.cpp +++ b/vm/arrays.cpp @@ -91,7 +91,7 @@ void growable_array::add(cell elt_) if(count == array_capacity(elements.untagged())) elements = myvm->reallot_array(elements.untagged(),count * 2); - set_array_nth(elements.untagged(),count++,elt.value()); + myvm->set_array_nth(elements.untagged(),count++,elt.value()); } void growable_array::trim() diff --git a/vm/inlineimpls.hpp b/vm/inlineimpls.hpp index ca0b13be39..6b74634715 100644 --- a/vm/inlineimpls.hpp +++ b/vm/inlineimpls.hpp @@ -11,11 +11,6 @@ inline cell factorvm::align_page(cell a) return align(a,getpagesize()); } -inline static cell align_page(cell a) -{ - return vm->align_page(a); -} - // write_barrier.hpp inline card *factorvm::addr_to_card(cell a) @@ -23,71 +18,38 @@ inline card *factorvm::addr_to_card(cell a) return (card*)(((cell)(a) >> card_bits) + cards_offset); } -inline card *addr_to_card(cell a) -{ - return vm->addr_to_card(a); -} inline cell factorvm::card_to_addr(card *c) { return ((cell)c - cards_offset) << card_bits; } -inline cell card_to_addr(card *c) -{ - return vm->card_to_addr(c); -} inline cell factorvm::card_offset(card *c) { return *(c - (cell)data->cards + (cell)data->allot_markers); } -inline cell card_offset(card *c) -{ - return vm->card_offset(c); -} - inline card_deck *factorvm::addr_to_deck(cell a) { return (card_deck *)(((cell)a >> deck_bits) + decks_offset); } -inline card_deck *addr_to_deck(cell a) -{ - return vm->addr_to_deck(a); -} - inline cell factorvm::deck_to_addr(card_deck *c) { return ((cell)c - decks_offset) << deck_bits; } -inline cell deck_to_addr(card_deck *c) -{ - return vm->deck_to_addr(c); -} - inline card *factorvm::deck_to_card(card_deck *d) { return (card *)((((cell)d - decks_offset) << (deck_bits - card_bits)) + cards_offset); } -inline card *deck_to_card(card_deck *d) -{ - return vm->deck_to_card(d); -} - inline card *factorvm::addr_to_allot_marker(object *a) { return (card *)(((cell)a >> card_bits) + allot_markers_offset); } -inline card *addr_to_allot_marker(object *a) -{ - return vm->addr_to_allot_marker(a); -} - /* the write barrier must be called any time we are potentially storing a pointer from an older generation to a younger one */ inline void factorvm::write_barrier(object *obj) @@ -96,11 +58,6 @@ inline void factorvm::write_barrier(object *obj) *addr_to_deck((cell)obj) = card_mark_mask; } -inline void write_barrier(object *obj) -{ - return vm->write_barrier(obj); -} - /* we need to remember the first object allocated in the card */ inline void factorvm::allot_barrier(object *address) { @@ -109,11 +66,6 @@ inline void factorvm::allot_barrier(object *address) *ptr = ((cell)address & addr_card_mask); } -inline void allot_barrier(object *address) -{ - return vm->allot_barrier(address); -} - //data_gc.hpp inline bool factorvm::collecting_accumulation_gen_p() @@ -124,11 +76,6 @@ inline bool factorvm::collecting_accumulation_gen_p() || collecting_gen == data->tenured()); } -inline bool collecting_accumulation_gen_p() -{ - return vm->collecting_accumulation_gen_p(); -} - inline object *factorvm::allot_zone(zone *z, cell a) { cell h = z->here; @@ -138,11 +85,6 @@ inline object *factorvm::allot_zone(zone *z, cell a) return obj; } -inline object *allot_zone(zone *z, cell a) -{ - return vm->allot_zone(z,a); -} - /* * It is up to the caller to fill in the object's fields in a meaningful * fashion! @@ -198,21 +140,11 @@ inline object *factorvm::allot_object(header header, cell size) return obj; } -inline object *allot_object(header header, cell size) -{ - return vm->allot_object(header,size); -} - template TYPE *factorvm::allot(cell size) { return (TYPE *)allot_object(header(TYPE::type_number),size); } -template TYPE *allot(cell size) -{ - return vm->allot(size); -} - inline void factorvm::check_data_pointer(object *pointer) { #ifdef FACTOR_DEBUG @@ -224,11 +156,6 @@ inline void factorvm::check_data_pointer(object *pointer) #endif } -inline void check_data_pointer(object *pointer) -{ - return vm->check_data_pointer(pointer); -} - inline void factorvm::check_tagged_pointer(cell tagged) { #ifdef FACTOR_DEBUG @@ -241,18 +168,13 @@ inline void factorvm::check_tagged_pointer(cell tagged) #endif } -inline void check_tagged_pointer(cell tagged) -{ - return vm->check_tagged_pointer(tagged); -} - //local_roots.hpp template struct gc_root : public tagged { factorvm *myvm; - void push() { check_tagged_pointer(tagged::value()); myvm->gc_locals.push_back((cell)this); } + void push() { myvm->check_tagged_pointer(tagged::value()); myvm->gc_locals.push_back((cell)this); } //explicit gc_root(cell value_, factorvm *vm) : myvm(vm),tagged(value_) { push(); } explicit gc_root(cell value_,factorvm *vm) : tagged(value_),myvm(vm) { push(); } @@ -276,7 +198,7 @@ struct gc_bignum factorvm *myvm; gc_bignum(bignum **addr_, factorvm *vm) : addr(addr_), myvm(vm) { if(*addr_) - check_data_pointer(*addr_); + myvm->check_data_pointer(*addr_); myvm->gc_bignums.push_back((cell)addr); } @@ -298,21 +220,11 @@ template TYPE *factorvm::allot_array_internal(cell capacity) return array; } -template TYPE *allot_array_internal(cell capacity) -{ - return vm->allot_array_internal(capacity); -} - template bool factorvm::reallot_array_in_place_p(TYPE *array, cell capacity) { return in_zone(&nursery,array) && capacity <= array_capacity(array); } -template bool reallot_array_in_place_p(TYPE *array, cell capacity) -{ - return vm->reallot_array_in_place_p(array,capacity); -} - template TYPE *factorvm::reallot_array(TYPE *array_, cell capacity) { gc_root array(array_,this); @@ -350,11 +262,6 @@ inline void factorvm::set_array_nth(array *array, cell slot, cell value) write_barrier(array); } -inline void set_array_nth(array *array, cell slot, cell value) -{ - return vm->set_array_nth(array,slot,value); -} - struct growable_array { cell count; gc_root elements; @@ -387,11 +294,6 @@ inline cell factorvm::allot_integer(fixnum x) return tag_fixnum(x); } -inline cell allot_integer(fixnum x) -{ - return vm->allot_integer(x); -} - inline cell factorvm::allot_cell(cell x) { if(x > (cell)fixnum_max) @@ -400,11 +302,6 @@ inline cell factorvm::allot_cell(cell x) return tag_fixnum(x); } -inline cell allot_cell(cell x) -{ - return vm->allot_cell(x); -} - inline cell factorvm::allot_float(double n) { boxed_float *flo = allot(sizeof(boxed_float)); @@ -412,72 +309,36 @@ inline cell factorvm::allot_float(double n) return tag(flo); } -inline cell allot_float(double n) -{ - return vm->allot_float(n); -} - inline bignum *factorvm::float_to_bignum(cell tagged) { return double_to_bignum(untag_float(tagged)); } -inline bignum *float_to_bignum(cell tagged) -{ - return vm->float_to_bignum(tagged); -} - inline double factorvm::bignum_to_float(cell tagged) { return bignum_to_double(untag(tagged)); } -inline double bignum_to_float(cell tagged) -{ - return vm->bignum_to_float(tagged); -} - inline double factorvm::untag_float(cell tagged) { return untag(tagged)->n; } -inline double untag_float(cell tagged) -{ - return vm->untag_float(tagged); -} - inline double factorvm::untag_float_check(cell tagged) { return untag_check(tagged)->n; } -inline double untag_float_check(cell tagged) -{ - return vm->untag_float_check(tagged); -} - inline fixnum factorvm::float_to_fixnum(cell tagged) { return (fixnum)untag_float(tagged); } -inline static fixnum float_to_fixnum(cell tagged) -{ - return vm->float_to_fixnum(tagged); -} - inline double factorvm::fixnum_to_float(cell tagged) { return (double)untag_fixnum(tagged); } -inline double fixnum_to_float(cell tagged) -{ - return vm->fixnum_to_float(tagged); -} - - //callstack.hpp /* This is a little tricky. The iterator may allocate memory, so we keep the callstack in a GC root and use relative offsets */ @@ -494,22 +355,12 @@ template void factorvm::iterate_callstack_object(callstack *stack } } -template void iterate_callstack_object(callstack *stack_, TYPE &iterator) -{ - return vm->iterate_callstack_object(stack_,iterator); -} - //booleans.hpp inline cell factorvm::tag_boolean(cell untagged) { return (untagged ? T : F); } -inline cell tag_boolean(cell untagged) -{ - return vm->tag_boolean(untagged); -} - // callstack.hpp template void factorvm::iterate_callstack(cell top, cell bottom, TYPE &iterator) { @@ -522,11 +373,6 @@ template void factorvm::iterate_callstack(cell top, cell bottom, } } -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 @@ -548,11 +394,6 @@ inline void factorvm::do_slots(cell obj, void (* iter)(cell *,factorvm*)) } } -inline void do_slots(cell obj, void (* iter)(cell *,factorvm*)) -{ - return vm->do_slots(obj,iter); -} - // code_heap.hpp inline void factorvm::check_code_pointer(cell ptr) diff --git a/vm/math.cpp b/vm/math.cpp index c403073804..8d213b391d 100755 --- a/vm/math.cpp +++ b/vm/math.cpp @@ -841,7 +841,7 @@ void factorvm::overflow_fixnum_add(fixnum x, fixnum y) VM_ASM_API void overflow_fixnum_add(fixnum x, fixnum y) { - return vm->overflow_fixnum_add(x,y); + return PRIMITIVE_OVERFLOW_GETVM()->overflow_fixnum_add(x,y); } void factorvm::overflow_fixnum_subtract(fixnum x, fixnum y) @@ -852,7 +852,7 @@ void factorvm::overflow_fixnum_subtract(fixnum x, fixnum y) VM_ASM_API void overflow_fixnum_subtract(fixnum x, fixnum y) { - return vm->overflow_fixnum_subtract(x,y); + return PRIMITIVE_OVERFLOW_GETVM()->overflow_fixnum_subtract(x,y); } void factorvm::overflow_fixnum_multiply(fixnum x, fixnum y) @@ -866,7 +866,7 @@ void factorvm::overflow_fixnum_multiply(fixnum x, fixnum y) VM_ASM_API void overflow_fixnum_multiply(fixnum x, fixnum y) { - return vm->overflow_fixnum_multiply(x,y); + return PRIMITIVE_OVERFLOW_GETVM()->overflow_fixnum_multiply(x,y); } } diff --git a/vm/math.hpp b/vm/math.hpp index 5939b25b37..b45284f693 100644 --- a/vm/math.hpp +++ b/vm/math.hpp @@ -5,6 +5,7 @@ static const fixnum fixnum_max = (((fixnum)1 << (WORD_SIZE - TAG_BITS - 1)) - 1) static const fixnum fixnum_min = (-((fixnum)1 << (WORD_SIZE - TAG_BITS - 1))); static const fixnum array_size_max = ((cell)1 << (WORD_SIZE - TAG_BITS - 2)); +// defined in assembler PRIMITIVE(fixnum_add); PRIMITIVE(fixnum_subtract); PRIMITIVE(fixnum_multiply); diff --git a/vm/primitives.hpp b/vm/primitives.hpp index 212126f322..8e6c3b8f51 100644 --- a/vm/primitives.hpp +++ b/vm/primitives.hpp @@ -12,6 +12,7 @@ namespace factor #endif extern const primitive_type primitives[]; +#define PRIMITIVE_OVERFLOW_GETVM() vm #define VM_PTR vm #define ASSERTVM() } diff --git a/vm/vm.hpp b/vm/vm.hpp index f72076c7b1..1b0274e0b1 100644 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -221,9 +221,6 @@ struct factorvm { bool growing_data_heap; data_heap *old_data_heap; - DEFPUSHPOP(gc_local_,gc_locals) - - void init_data_gc(); object *copy_untagged_object_impl(object *pointer, cell size); object *copy_object_impl(object *untagged);