]> gitweb.factorcode.org Git - factor.git/commitdiff
renamed myvm member variable to parent_vm
authorPhil Dawes <phil@phildawes.net>
Wed, 23 Sep 2009 18:26:54 +0000 (19:26 +0100)
committerPhil Dawes <phil@phildawes.net>
Thu, 24 Sep 2009 07:16:57 +0000 (08:16 +0100)
vm/arrays.cpp
vm/byte_arrays.cpp
vm/dispatch.cpp
vm/inline_cache.cpp
vm/inlineimpls.hpp
vm/jit.cpp
vm/jit.hpp
vm/quotations.cpp

index aeae1d664fc5e3e7a4e004edd8cd0c14bf77e92b..a50500a2dbf08600f1eb379aaa7748df193cabfe 100644 (file)
@@ -82,18 +82,18 @@ PRIMITIVE(resize_array)
 
 void growable_array::add(cell elt_)
 {
-       factor_vm* myvm = elements.myvm;
-       gc_root<object> elt(elt_,myvm);
+       factor_vm* parent_vm = elements.parent_vm;
+       gc_root<object> elt(elt_,parent_vm);
        if(count == array_capacity(elements.untagged()))
-               elements = myvm->reallot_array(elements.untagged(),count * 2);
+               elements = parent_vm->reallot_array(elements.untagged(),count * 2);
 
-       myvm->set_array_nth(elements.untagged(),count++,elt.value());
+       parent_vm->set_array_nth(elements.untagged(),count++,elt.value());
 }
 
 void growable_array::trim()
 {
-       factor_vm *myvm = elements.myvm;
-       elements = myvm->reallot_array(elements.untagged(),count);
+       factor_vm *parent_vm = elements.parent_vm;
+       elements = parent_vm->reallot_array(elements.untagged(),count);
 }
 
 }
index 82474e18c2fd67543801da6ac14e71f8e4a37ff8..4213ed45a8f4148bca34310a65fe4e39f2e9d1bb 100644 (file)
@@ -47,9 +47,9 @@ PRIMITIVE(resize_byte_array)
 void growable_byte_array::append_bytes(void *elts, cell len)
 {
        cell new_size = count + len;
-       factor_vm *myvm = elements.myvm;
+       factor_vm *parent_vm = elements.parent_vm;
        if(new_size >= array_capacity(elements.untagged()))
-               elements = myvm->reallot_array(elements.untagged(),new_size * 2);
+               elements = parent_vm->reallot_array(elements.untagged(),new_size * 2);
 
        memcpy(&elements->data<u8>()[count],elts,len);
 
@@ -58,13 +58,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.myvm);
+       gc_root<byte_array> byte_array(byte_array_,elements.parent_vm);
 
        cell len = array_capacity(byte_array.untagged());
        cell new_size = count + len;
-       factor_vm *myvm = elements.myvm;
+       factor_vm *parent_vm = elements.parent_vm;
        if(new_size >= array_capacity(elements.untagged()))
-               elements = myvm->reallot_array(elements.untagged(),new_size * 2);
+               elements = parent_vm->reallot_array(elements.untagged(),new_size * 2);
 
        memcpy(&elements->data<u8>()[count],byte_array->data<u8>(),len);
 
@@ -73,8 +73,8 @@ void growable_byte_array::append_byte_array(cell byte_array_)
 
 void growable_byte_array::trim()
 {
-       factor_vm *myvm = elements.myvm;
-       elements = myvm->reallot_array(elements.untagged(),count);
+       factor_vm *parent_vm = elements.parent_vm;
+       elements = parent_vm->reallot_array(elements.untagged(),count);
 }
 
 }
index 96d77c75927dfc41cbeb1cb34ed71e338b98e816..1e13e90d5ab3fda775f44be39dd91a29b1c0532b 100755 (executable)
@@ -200,28 +200,28 @@ PRIMITIVE(dispatch_stats)
 
 void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index, cell cache_)
 {
-       gc_root<array> methods(methods_,myvm);
-       gc_root<array> cache(cache_,myvm);
+       gc_root<array> methods(methods_,parent_vm);
+       gc_root<array> cache(cache_,parent_vm);
 
        /* Generate machine code to determine the object's class. */
        emit_class_lookup(index,PIC_HI_TAG_TUPLE);
 
        /* Do a cache lookup. */
-       emit_with(myvm->userenv[MEGA_LOOKUP],cache.value());
+       emit_with(parent_vm->userenv[MEGA_LOOKUP],cache.value());
        
        /* If we end up here, the cache missed. */
-       emit(myvm->userenv[JIT_PROLOG]);
+       emit(parent_vm->userenv[JIT_PROLOG]);
 
        /* Push index, method table and cache on the stack. */
        push(methods.value());
        push(tag_fixnum(index));
        push(cache.value());
-       word_call(myvm->userenv[MEGA_MISS_WORD]);
+       word_call(parent_vm->userenv[MEGA_MISS_WORD]);
 
        /* Now the new method has been stored into the cache, and its on
           the stack. */
-       emit(myvm->userenv[JIT_EPILOG]);
-       emit(myvm->userenv[JIT_EXECUTE_JUMP]);
+       emit(parent_vm->userenv[JIT_EPILOG]);
+       emit(parent_vm->userenv[JIT_EXECUTE_JUMP]);
 }
 
 }
index 99c563882a4537352e70c72dde2346fa55aa6d8b..9bb1d1c2f145489bc7281efec14bf11c9d4ff243 100755 (executable)
@@ -88,9 +88,9 @@ void inline_cache_jit::emit_check(cell klass)
 {
        cell code_template;
        if(TAG(klass) == FIXNUM_TYPE && untag_fixnum(klass) < HEADER_TYPE)
-               code_template = myvm->userenv[PIC_CHECK_TAG];
+               code_template = parent_vm->userenv[PIC_CHECK_TAG];
        else
-               code_template = myvm->userenv[PIC_CHECK];
+               code_template = parent_vm->userenv[PIC_CHECK];
 
        emit_with(code_template,klass);
 }
@@ -103,12 +103,12 @@ void inline_cache_jit::compile_inline_cache(fixnum index,
                                            cell cache_entries_,
                                            bool tail_call_p)
 {
-       gc_root<word> generic_word(generic_word_,myvm);
-       gc_root<array> methods(methods_,myvm);
-       gc_root<array> cache_entries(cache_entries_,myvm);
+       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);
 
-       cell inline_cache_type = myvm->determine_inline_cache_type(cache_entries.untagged());
-       myvm->update_pic_count(inline_cache_type);
+       cell inline_cache_type = parent_vm->determine_inline_cache_type(cache_entries.untagged());
+       parent_vm->update_pic_count(inline_cache_type);
 
        /* Generate machine code to determine the object's class. */
        emit_class_lookup(index,inline_cache_type);
@@ -123,7 +123,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(myvm->userenv[PIC_HIT],method);
+               emit_with(parent_vm->userenv[PIC_HIT],method);
        }
 
        /* Generate machine code to handle a cache miss, which ultimately results in
@@ -135,7 +135,7 @@ void inline_cache_jit::compile_inline_cache(fixnum index,
        push(methods.value());
        push(tag_fixnum(index));
        push(cache_entries.value());
-       word_special(myvm->userenv[tail_call_p ? PIC_MISS_TAIL_WORD : PIC_MISS_WORD]);
+       word_special(parent_vm->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)
index 600629608ee51a2ef1ff9d46063cdd8997771167..db6ef8abf45f4642088e9f796e1be18986fd7578 100644 (file)
@@ -169,12 +169,12 @@ inline void factor_vm::check_tagged_pointer(cell tagged)
 template <typename TYPE>
 struct gc_root : public tagged<TYPE>
 {
-       factor_vm *myvm;
+       factor_vm *parent_vm;
 
-       void push() { myvm->check_tagged_pointer(tagged<TYPE>::value()); myvm->gc_locals.push_back((cell)this); }
+       void push() { parent_vm->check_tagged_pointer(tagged<TYPE>::value()); parent_vm->gc_locals.push_back((cell)this); }
        
-       explicit gc_root(cell value_,factor_vm *vm) : tagged<TYPE>(value_),myvm(vm) { push(); }
-       explicit gc_root(TYPE *value_, factor_vm *vm) : tagged<TYPE>(value_),myvm(vm) { push(); }
+       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(); }
 
        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; }
@@ -183,7 +183,7 @@ struct gc_root : public tagged<TYPE>
 #ifdef FACTOR_DEBUG
                assert(myvm->gc_locals.back() == (cell)this);
 #endif
-               myvm->gc_locals.pop_back();
+               parent_vm->gc_locals.pop_back();
        }
 };
 
@@ -191,18 +191,18 @@ struct gc_root : public tagged<TYPE>
 struct gc_bignum
 {
        bignum **addr;
-       factor_vm *myvm;
-       gc_bignum(bignum **addr_, factor_vm *vm) : addr(addr_), myvm(vm) {
+       factor_vm *parent_vm;
+       gc_bignum(bignum **addr_, factor_vm *vm) : addr(addr_), parent_vm(vm) {
                if(*addr_)
-                       myvm->check_data_pointer(*addr_);
-               myvm->gc_bignums.push_back((cell)addr);
+                       parent_vm->check_data_pointer(*addr_);
+               parent_vm->gc_bignums.push_back((cell)addr);
        }
 
        ~gc_bignum() {
 #ifdef FACTOR_DEBUG
                assert(myvm->gc_bignums.back() == (cell)addr);
 #endif
-               myvm->gc_bignums.pop_back();
+               parent_vm->gc_bignums.pop_back();
        }
 };
 
index 597575fcfdcbdf43767fc759970085800d91dc9e..3eb0f04547e5e3178ef47c42d5c0e842c5ea1ac4 100644 (file)
@@ -19,14 +19,14 @@ jit::jit(cell type_, cell owner_, factor_vm *vm)
          computing_offset_p(false),
          position(0),
          offset(0),
-         myvm(vm)
+         parent_vm(vm)
 {
-       if(myvm->stack_traces_p()) literal(owner.value());
+       if(parent_vm->stack_traces_p()) literal(owner.value());
 }
 
 void jit::emit_relocation(cell code_template_)
 {
-       gc_root<array> code_template(code_template_,myvm);
+       gc_root<array> code_template(code_template_,parent_vm);
        cell capacity = array_capacity(code_template.untagged());
        for(cell i = 1; i < capacity; i += 3)
        {
@@ -45,11 +45,11 @@ void jit::emit_relocation(cell code_template_)
 /* Allocates memory */
 void jit::emit(cell code_template_)
 {
-       gc_root<array> code_template(code_template_,myvm);
+       gc_root<array> code_template(code_template_,parent_vm);
 
        emit_relocation(code_template.value());
 
-       gc_root<byte_array> insns(array_nth(code_template.untagged(),0),myvm);
+       gc_root<byte_array> insns(array_nth(code_template.untagged(),0),parent_vm);
 
        if(computing_offset_p)
        {
@@ -73,16 +73,16 @@ void jit::emit(cell code_template_)
 }
 
 void jit::emit_with(cell code_template_, cell argument_) {
-       gc_root<array> code_template(code_template_,myvm);
-       gc_root<object> argument(argument_,myvm);
+       gc_root<array> code_template(code_template_,parent_vm);
+       gc_root<object> argument(argument_,parent_vm);
        literal(argument.value());
        emit(code_template.value());
 }
 
 void jit::emit_class_lookup(fixnum index, cell type)
 {
-       emit_with(myvm->userenv[PIC_LOAD],tag_fixnum(-index * sizeof(cell)));
-       emit(myvm->userenv[type]);
+       emit_with(parent_vm->userenv[PIC_LOAD],tag_fixnum(-index * sizeof(cell)));
+       emit(parent_vm->userenv[type]);
 }
 
 /* Facility to convert compiled code offsets to quotation offsets.
@@ -102,7 +102,7 @@ code_block *jit::to_code_block()
        relocation.trim();
        literals.trim();
 
-       return myvm->add_code_block(
+       return parent_vm->add_code_block(
                type,
                code.elements.value(),
                F, /* no labels */
index 1004da96366a9f4909a74074d362adb548aed91e..ee626e853fd4474c982911053e30d6cb627be17c 100644 (file)
@@ -10,7 +10,7 @@ struct jit {
        bool computing_offset_p;
        fixnum position;
        cell offset;
-       factor_vm *myvm;
+       factor_vm *parent_vm;
 
        jit(cell jit_type, cell owner, factor_vm *vm);
        void compute_position(cell offset);
@@ -22,27 +22,27 @@ struct jit {
        void emit_with(cell code_template_, cell literal_);
 
        void push(cell literal) {
-               emit_with(myvm->userenv[JIT_PUSH_IMMEDIATE],literal);
+               emit_with(parent_vm->userenv[JIT_PUSH_IMMEDIATE],literal);
        }
 
        void word_jump(cell word) {
                literal(tag_fixnum(xt_tail_pic_offset));
                literal(word);
-               emit(myvm->userenv[JIT_WORD_JUMP]);
+               emit(parent_vm->userenv[JIT_WORD_JUMP]);
        }
 
        void word_call(cell word) {
-               emit_with(myvm->userenv[JIT_WORD_CALL],word);
+               emit_with(parent_vm->userenv[JIT_WORD_CALL],word);
        }
 
        void word_special(cell word) {
-               emit_with(myvm->userenv[JIT_WORD_SPECIAL],word);
+               emit_with(parent_vm->userenv[JIT_WORD_SPECIAL],word);
        }
 
        void emit_subprimitive(cell word_) {
-               gc_root<word> word(word_,myvm);
-               gc_root<array> code_template(word->subprimitive,myvm);
-               if(array_capacity(code_template.untagged()) > 1) literal(myvm->T);
+               gc_root<word> word(word_,parent_vm);
+               gc_root<array> code_template(word->subprimitive,parent_vm);
+               if(array_capacity(code_template.untagged()) > 1) literal(parent_vm->T);
                emit(code_template.value());
        }
 
index d6774692e9cfd244d6ba2ae1aa0146ebbecd1226..1bc6240481bbe16db90f2e129558b59b57a82fa8 100755 (executable)
@@ -40,7 +40,7 @@ bool quotation_jit::primitive_call_p(cell i)
 {
        return (i + 2) == array_capacity(elements.untagged())
                && tagged<object>(array_nth(elements.untagged(),i)).type_p(FIXNUM_TYPE)
-               && array_nth(elements.untagged(),i + 1) == myvm->userenv[JIT_PRIMITIVE_WORD];
+               && array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_PRIMITIVE_WORD];
 }
 
 bool quotation_jit::fast_if_p(cell i)
@@ -48,28 +48,28 @@ bool quotation_jit::fast_if_p(cell i)
        return (i + 3) == array_capacity(elements.untagged())
                && tagged<object>(array_nth(elements.untagged(),i)).type_p(QUOTATION_TYPE)
                && tagged<object>(array_nth(elements.untagged(),i + 1)).type_p(QUOTATION_TYPE)
-               && array_nth(elements.untagged(),i + 2) == myvm->userenv[JIT_IF_WORD];
+               && array_nth(elements.untagged(),i + 2) == parent_vm->userenv[JIT_IF_WORD];
 }
 
 bool quotation_jit::fast_dip_p(cell i)
 {
        return (i + 2) <= array_capacity(elements.untagged())
                && tagged<object>(array_nth(elements.untagged(),i)).type_p(QUOTATION_TYPE)
-               && array_nth(elements.untagged(),i + 1) == myvm->userenv[JIT_DIP_WORD];
+               && array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_DIP_WORD];
 }
 
 bool quotation_jit::fast_2dip_p(cell i)
 {
        return (i + 2) <= array_capacity(elements.untagged())
                && tagged<object>(array_nth(elements.untagged(),i)).type_p(QUOTATION_TYPE)
-               && array_nth(elements.untagged(),i + 1) == myvm->userenv[JIT_2DIP_WORD];
+               && array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_2DIP_WORD];
 }
 
 bool quotation_jit::fast_3dip_p(cell i)
 {
        return (i + 2) <= array_capacity(elements.untagged())
                && tagged<object>(array_nth(elements.untagged(),i)).type_p(QUOTATION_TYPE)
-               && array_nth(elements.untagged(),i + 1) == myvm->userenv[JIT_3DIP_WORD];
+               && array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_3DIP_WORD];
 }
 
 bool quotation_jit::mega_lookup_p(cell i)
@@ -78,7 +78,7 @@ bool quotation_jit::mega_lookup_p(cell i)
                && tagged<object>(array_nth(elements.untagged(),i)).type_p(ARRAY_TYPE)
                && 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) == myvm->userenv[MEGA_LOOKUP_WORD];
+               && array_nth(elements.untagged(),i + 3) == parent_vm->userenv[MEGA_LOOKUP_WORD];
 }
 
 bool quotation_jit::stack_frame_p()
@@ -92,7 +92,7 @@ bool quotation_jit::stack_frame_p()
                switch(tagged<object>(obj).type())
                {
                case WORD_TYPE:
-                       if(myvm->untag<word>(obj)->subprimitive == F)
+                       if(parent_vm->untag<word>(obj)->subprimitive == F)
                                return true;
                        break;
                case QUOTATION_TYPE:
@@ -115,7 +115,7 @@ void quotation_jit::iterate_quotation()
        set_position(0);
 
        if(stack_frame)
-               emit(myvm->userenv[JIT_PROLOG]);
+               emit(parent_vm->userenv[JIT_PROLOG]);
 
        cell i;
        cell length = array_capacity(elements.untagged());
@@ -125,7 +125,7 @@ void quotation_jit::iterate_quotation()
        {
                set_position(i);
 
-               gc_root<object> obj(array_nth(elements.untagged(),i),myvm);
+               gc_root<object> obj(array_nth(elements.untagged(),i),parent_vm);
 
                switch(obj.type())
                {
@@ -134,23 +134,23 @@ void quotation_jit::iterate_quotation()
                        if(obj.as<word>()->subprimitive != F)
                                emit_subprimitive(obj.value());
                        /* The (execute) primitive is special-cased */
-                       else if(obj.value() == myvm->userenv[JIT_EXECUTE_WORD])
+                       else if(obj.value() == parent_vm->userenv[JIT_EXECUTE_WORD])
                        {
                                if(i == length - 1)
                                {
-                                       if(stack_frame) emit(myvm->userenv[JIT_EPILOG]);
+                                       if(stack_frame) emit(parent_vm->userenv[JIT_EPILOG]);
                                        tail_call = true;
-                                       emit(myvm->userenv[JIT_EXECUTE_JUMP]);
+                                       emit(parent_vm->userenv[JIT_EXECUTE_JUMP]);
                                }
                                else
-                                       emit(myvm->userenv[JIT_EXECUTE_CALL]);
+                                       emit(parent_vm->userenv[JIT_EXECUTE_CALL]);
                        }
                        /* Everything else */
                        else
                        {
                                if(i == length - 1)
                                {
-                                       if(stack_frame) emit(myvm->userenv[JIT_EPILOG]);
+                                       if(stack_frame) emit(parent_vm->userenv[JIT_EPILOG]);
                                        tail_call = true;
                                        /* Inline cache misses are special-cased.
                                           The calling convention for tail
@@ -160,8 +160,8 @@ void quotation_jit::iterate_quotation()
                                           the inline cache miss primitive, and
                                           we don't want to clobber the saved
                                           address. */
-                                       if(obj.value() == myvm->userenv[PIC_MISS_WORD]
-                                          || obj.value() == myvm->userenv[PIC_MISS_TAIL_WORD])
+                                       if(obj.value() == parent_vm->userenv[PIC_MISS_WORD]
+                                          || obj.value() == parent_vm->userenv[PIC_MISS_TAIL_WORD])
                                        {
                                                word_special(obj.value());
                                        }
@@ -181,7 +181,7 @@ void quotation_jit::iterate_quotation()
                        /* Primitive calls */
                        if(primitive_call_p(i))
                        {
-                               emit_with(myvm->userenv[JIT_PRIMITIVE],obj.value());
+                               emit_with(parent_vm->userenv[JIT_PRIMITIVE],obj.value());
 
                                i++;
 
@@ -193,18 +193,18 @@ void quotation_jit::iterate_quotation()
                           mutually recursive in the library, but both still work) */
                        if(fast_if_p(i))
                        {
-                               if(stack_frame) emit(myvm->userenv[JIT_EPILOG]);
+                               if(stack_frame) emit(parent_vm->userenv[JIT_EPILOG]);
                                tail_call = true;
 
                                if(compiling)
                                {
-                                       myvm->jit_compile(array_nth(elements.untagged(),i),relocate);
-                                       myvm->jit_compile(array_nth(elements.untagged(),i + 1),relocate);
+                                       parent_vm->jit_compile(array_nth(elements.untagged(),i),relocate);
+                                       parent_vm->jit_compile(array_nth(elements.untagged(),i + 1),relocate);
                                }
 
                                literal(array_nth(elements.untagged(),i));
                                literal(array_nth(elements.untagged(),i + 1));
-                               emit(myvm->userenv[JIT_IF]);
+                               emit(parent_vm->userenv[JIT_IF]);
 
                                i += 2;
 
@@ -214,8 +214,8 @@ void quotation_jit::iterate_quotation()
                        else if(fast_dip_p(i))
                        {
                                if(compiling)
-                                       myvm->jit_compile(obj.value(),relocate);
-                               emit_with(myvm->userenv[JIT_DIP],obj.value());
+                                       parent_vm->jit_compile(obj.value(),relocate);
+                               emit_with(parent_vm->userenv[JIT_DIP],obj.value());
                                i++;
                                break;
                        }
@@ -223,8 +223,8 @@ void quotation_jit::iterate_quotation()
                        else if(fast_2dip_p(i))
                        {
                                if(compiling)
-                                       myvm->jit_compile(obj.value(),relocate);
-                               emit_with(myvm->userenv[JIT_2DIP],obj.value());
+                                       parent_vm->jit_compile(obj.value(),relocate);
+                               emit_with(parent_vm->userenv[JIT_2DIP],obj.value());
                                i++;
                                break;
                        }
@@ -232,8 +232,8 @@ void quotation_jit::iterate_quotation()
                        else if(fast_3dip_p(i))
                        {
                                if(compiling)
-                                       myvm->jit_compile(obj.value(),relocate);
-                               emit_with(myvm->userenv[JIT_3DIP],obj.value());
+                                       parent_vm->jit_compile(obj.value(),relocate);
+                               emit_with(parent_vm->userenv[JIT_3DIP],obj.value());
                                i++;
                                break;
                        }
@@ -260,8 +260,8 @@ void quotation_jit::iterate_quotation()
                set_position(length);
 
                if(stack_frame)
-                       emit(myvm->userenv[JIT_EPILOG]);
-               emit(myvm->userenv[JIT_RETURN]);
+                       emit(parent_vm->userenv[JIT_EPILOG]);
+               emit(parent_vm->userenv[JIT_RETURN]);
        }
 }