]> gitweb.factorcode.org Git - factor.git/commitdiff
removed all vm-> singleton accesses from inlineimpls
authorPhil Dawes <phil@phildawes.net>
Sat, 22 Aug 2009 10:15:58 +0000 (11:15 +0100)
committerPhil Dawes <phil@phildawes.net>
Wed, 16 Sep 2009 07:16:33 +0000 (08:16 +0100)
vm/arrays.cpp
vm/inlineimpls.hpp
vm/math.cpp
vm/math.hpp
vm/primitives.hpp
vm/vm.hpp

index 62992c4e7c072d66e550833e848cd44f5b22c874..3052563deaf9a8718b762cc63d202906cc1f6f58 100644 (file)
@@ -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()
index ca0b13be39b45551a151fb8b3587edafcc638650..6b74634715e92db7e5e00c003e1f91b0d05b3eb6 100644 (file)
@@ -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<typename TYPE> TYPE *factorvm::allot(cell size)
 {
        return (TYPE *)allot_object(header(TYPE::type_number),size);
 }
 
-template<typename TYPE> TYPE *allot(cell size)
-{
-       return vm->allot<TYPE>(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 <typename TYPE>
 struct gc_root : public tagged<TYPE>
 {
        factorvm *myvm;
 
-       void push() { check_tagged_pointer(tagged<TYPE>::value()); myvm->gc_locals.push_back((cell)this); }
+       void push() { myvm->check_tagged_pointer(tagged<TYPE>::value()); myvm->gc_locals.push_back((cell)this); }
        
        //explicit gc_root(cell value_, factorvm *vm) : myvm(vm),tagged<TYPE>(value_) { push(); }
        explicit gc_root(cell value_,factorvm *vm) : tagged<TYPE>(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 <typename TYPE> TYPE *factorvm::allot_array_internal(cell capacity)
        return array;
 }
 
-template <typename TYPE> TYPE *allot_array_internal(cell capacity)
-{
-       return vm->allot_array_internal<TYPE>(capacity);
-}
-
 template <typename TYPE> bool factorvm::reallot_array_in_place_p(TYPE *array, cell capacity)
 {
        return in_zone(&nursery,array) && capacity <= array_capacity(array);
 }
 
-template <typename TYPE> bool reallot_array_in_place_p(TYPE *array, cell capacity)
-{
-       return vm->reallot_array_in_place_p<TYPE>(array,capacity);
-}
-
 template <typename TYPE> TYPE *factorvm::reallot_array(TYPE *array_, cell capacity)
 {
        gc_root<TYPE> 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<array> 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<boxed_float>(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<bignum>(tagged));
 }
 
-inline double bignum_to_float(cell tagged)
-{
-       return vm->bignum_to_float(tagged);
-}
-
 inline double factorvm::untag_float(cell tagged)
 {
        return untag<boxed_float>(tagged)->n;
 }
 
-inline double untag_float(cell tagged)
-{
-       return vm->untag_float(tagged);
-}
-
 inline double factorvm::untag_float_check(cell tagged)
 {
        return untag_check<boxed_float>(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<typename TYPE> void factorvm::iterate_callstack_object(callstack *stack
        }
 }
 
-template<typename TYPE> 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<typename TYPE> void factorvm::iterate_callstack(cell top, cell bottom, TYPE &iterator)
 {
@@ -522,11 +373,6 @@ template<typename TYPE> void factorvm::iterate_callstack(cell top, cell bottom,
        }
 }
 
-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
@@ -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)
index c403073804b4b17cb1cffb2ef2ec95d384d2da6b..8d213b391dc8d2760833aee825fd5782921d9fe6 100755 (executable)
@@ -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);
 }
 
 }
index 5939b25b379794a7e43d0348f453b1ba1f187d8e..b45284f693b9d8774083ff9bfc593992d56d58a2 100644 (file)
@@ -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);
index 212126f32244bf59fc665bb990575206607a7702..8e6c3b8f518dec1aafe2f9f46138b4b4c54deb96 100644 (file)
@@ -12,6 +12,7 @@ namespace factor
 #endif
 
 extern const primitive_type primitives[];
+#define PRIMITIVE_OVERFLOW_GETVM() vm
 #define VM_PTR vm
 #define ASSERTVM() 
 }
index f72076c7b143cf204f2777f4e09937e4144f9ba5..1b0274e0b17d34d78127d680bf48169dad26ff79 100644 (file)
--- 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);