]> gitweb.factorcode.org Git - factor.git/commitdiff
moved userenv into vm in C code (DOESNT BOOTSTRAP YET!!!)
authorPhil Dawes <phil@phildawes.net>
Fri, 21 Aug 2009 18:27:40 +0000 (19:27 +0100)
committerPhil Dawes <phil@phildawes.net>
Wed, 16 Sep 2009 07:16:32 +0000 (08:16 +0100)
vm/dispatch.cpp
vm/inline_cache.cpp
vm/jit.cpp
vm/jit.hpp
vm/quotations.cpp
vm/run.cpp
vm/run.hpp
vm/vm.hpp

index 85d92f90a03813854e137f793d088f8c52cde52e..e87cdeac70c1df3ee69c1380a419d157a2174204 100755 (executable)
@@ -207,21 +207,21 @@ void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index, cell cac
        emit_class_lookup(index,PIC_HI_TAG_TUPLE);
 
        /* Do a cache lookup. */
-       emit_with(userenv[MEGA_LOOKUP],cache.value());
+       emit_with(myvm->userenv[MEGA_LOOKUP],cache.value());
        
        /* If we end up here, the cache missed. */
-       emit(userenv[JIT_PROLOG]);
+       emit(myvm->userenv[JIT_PROLOG]);
 
        /* Push index, method table and cache on the stack. */
        push(methods.value());
        push(tag_fixnum(index));
        push(cache.value());
-       word_call(userenv[MEGA_MISS_WORD]);
+       word_call(myvm->userenv[MEGA_MISS_WORD]);
 
        /* Now the new method has been stored into the cache, and its on
           the stack. */
-       emit(userenv[JIT_EPILOG]);
-       emit(userenv[JIT_EXECUTE_JUMP]);
+       emit(myvm->userenv[JIT_EPILOG]);
+       emit(myvm->userenv[JIT_EXECUTE_JUMP]);
 }
 
 }
index 24008cae798c149f6d28e0cd6f352fd9542893d4..35479c29f5ac15ecf56fdb63de723bea3ed7a057 100755 (executable)
@@ -89,9 +89,9 @@ void inline_cache_jit::emit_check(cell klass)
 {
        cell code_template;
        if(TAG(klass) == FIXNUM_TYPE && untag_fixnum(klass) < HEADER_TYPE)
-               code_template = userenv[PIC_CHECK_TAG];
+               code_template = myvm->userenv[PIC_CHECK_TAG];
        else
-               code_template = userenv[PIC_CHECK];
+               code_template = myvm->userenv[PIC_CHECK];
 
        emit_with(code_template,klass);
 }
@@ -124,7 +124,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(userenv[PIC_HIT],method);
+               emit_with(myvm->userenv[PIC_HIT],method);
        }
 
        /* Generate machine code to handle a cache miss, which ultimately results in
@@ -136,7 +136,7 @@ void inline_cache_jit::compile_inline_cache(fixnum index,
        push(methods.value());
        push(tag_fixnum(index));
        push(cache_entries.value());
-       word_special(userenv[tail_call_p ? PIC_MISS_TAIL_WORD : PIC_MISS_WORD]);
+       word_special(myvm->userenv[tail_call_p ? PIC_MISS_TAIL_WORD : PIC_MISS_WORD]);
 }
 
 code_block *factorvm::compile_inline_cache(fixnum index,cell generic_word_,cell methods_,cell cache_entries_,bool tail_call_p)
index d474d23a18a22fbd2d39e727043eec24678ffdfa..cdb5acace374e63e9b5277e0b3becddf1153522d 100644 (file)
@@ -81,8 +81,8 @@ void jit::emit_with(cell code_template_, cell argument_) {
 
 void jit::emit_class_lookup(fixnum index, cell type)
 {
-       emit_with(userenv[PIC_LOAD],tag_fixnum(-index * sizeof(cell)));
-       emit(userenv[type]);
+       emit_with(myvm->userenv[PIC_LOAD],tag_fixnum(-index * sizeof(cell)));
+       emit(myvm->userenv[type]);
 }
 
 /* Facility to convert compiled code offsets to quotation offsets.
index 81754be26a9cde286082bd215bffa5b7d2dd1443..a44f359ffe3632c2017a22f3ee496f2739a3c484 100644 (file)
@@ -22,21 +22,21 @@ struct jit {
        void emit_with(cell code_template_, cell literal_);
 
        void push(cell literal) {
-               emit_with(userenv[JIT_PUSH_IMMEDIATE],literal);
+               emit_with(myvm->userenv[JIT_PUSH_IMMEDIATE],literal);
        }
 
        void word_jump(cell word) {
                literal(tag_fixnum(xt_tail_pic_offset));
                literal(word);
-               emit(userenv[JIT_WORD_JUMP]);
+               emit(myvm->userenv[JIT_WORD_JUMP]);
        }
 
        void word_call(cell word) {
-               emit_with(userenv[JIT_WORD_CALL],word);
+               emit_with(myvm->userenv[JIT_WORD_CALL],word);
        }
 
        void word_special(cell word) {
-               emit_with(userenv[JIT_WORD_SPECIAL],word);
+               emit_with(myvm->userenv[JIT_WORD_SPECIAL],word);
        }
 
        void emit_subprimitive(cell word_) {
index 9654e2eff3bf88e37bf45108488540417dab5c5d..7b03ada175734b1d974ae0139891b7dc19972874 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) == userenv[JIT_PRIMITIVE_WORD];
+               && array_nth(elements.untagged(),i + 1) == myvm->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) == userenv[JIT_IF_WORD];
+               && array_nth(elements.untagged(),i + 2) == myvm->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) == userenv[JIT_DIP_WORD];
+               && array_nth(elements.untagged(),i + 1) == myvm->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) == userenv[JIT_2DIP_WORD];
+               && array_nth(elements.untagged(),i + 1) == myvm->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) == userenv[JIT_3DIP_WORD];
+               && array_nth(elements.untagged(),i + 1) == myvm->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) == userenv[MEGA_LOOKUP_WORD];
+               && array_nth(elements.untagged(),i + 3) == myvm->userenv[MEGA_LOOKUP_WORD];
 }
 
 bool quotation_jit::stack_frame_p()
@@ -115,7 +115,7 @@ void quotation_jit::iterate_quotation()
        set_position(0);
 
        if(stack_frame)
-               emit(userenv[JIT_PROLOG]);
+               emit(myvm->userenv[JIT_PROLOG]);
 
        cell i;
        cell length = array_capacity(elements.untagged());
@@ -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() == userenv[JIT_EXECUTE_WORD])
+                       else if(obj.value() == myvm->userenv[JIT_EXECUTE_WORD])
                        {
                                if(i == length - 1)
                                {
-                                       if(stack_frame) emit(userenv[JIT_EPILOG]);
+                                       if(stack_frame) emit(myvm->userenv[JIT_EPILOG]);
                                        tail_call = true;
-                                       emit(userenv[JIT_EXECUTE_JUMP]);
+                                       emit(myvm->userenv[JIT_EXECUTE_JUMP]);
                                }
                                else
-                                       emit(userenv[JIT_EXECUTE_CALL]);
+                                       emit(myvm->userenv[JIT_EXECUTE_CALL]);
                        }
                        /* Everything else */
                        else
                        {
                                if(i == length - 1)
                                {
-                                       if(stack_frame) emit(userenv[JIT_EPILOG]);
+                                       if(stack_frame) emit(myvm->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() == userenv[PIC_MISS_WORD]
-                                          || obj.value() == userenv[PIC_MISS_TAIL_WORD])
+                                       if(obj.value() == myvm->userenv[PIC_MISS_WORD]
+                                          || obj.value() == myvm->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(userenv[JIT_PRIMITIVE],obj.value());
+                               emit_with(myvm->userenv[JIT_PRIMITIVE],obj.value());
 
                                i++;
 
@@ -193,7 +193,7 @@ void quotation_jit::iterate_quotation()
                           mutually recursive in the library, but both still work) */
                        if(fast_if_p(i))
                        {
-                               if(stack_frame) emit(userenv[JIT_EPILOG]);
+                               if(stack_frame) emit(myvm->userenv[JIT_EPILOG]);
                                tail_call = true;
 
                                if(compiling)
@@ -204,7 +204,7 @@ void quotation_jit::iterate_quotation()
 
                                literal(array_nth(elements.untagged(),i));
                                literal(array_nth(elements.untagged(),i + 1));
-                               emit(userenv[JIT_IF]);
+                               emit(myvm->userenv[JIT_IF]);
 
                                i += 2;
 
@@ -215,7 +215,7 @@ void quotation_jit::iterate_quotation()
                        {
                                if(compiling)
                                        myvm->jit_compile(obj.value(),relocate);
-                               emit_with(userenv[JIT_DIP],obj.value());
+                               emit_with(myvm->userenv[JIT_DIP],obj.value());
                                i++;
                                break;
                        }
@@ -224,7 +224,7 @@ void quotation_jit::iterate_quotation()
                        {
                                if(compiling)
                                        myvm->jit_compile(obj.value(),relocate);
-                               emit_with(userenv[JIT_2DIP],obj.value());
+                               emit_with(myvm->userenv[JIT_2DIP],obj.value());
                                i++;
                                break;
                        }
@@ -233,7 +233,7 @@ void quotation_jit::iterate_quotation()
                        {
                                if(compiling)
                                        myvm->jit_compile(obj.value(),relocate);
-                               emit_with(userenv[JIT_3DIP],obj.value());
+                               emit_with(myvm->userenv[JIT_3DIP],obj.value());
                                i++;
                                break;
                        }
@@ -260,8 +260,8 @@ void quotation_jit::iterate_quotation()
                set_position(length);
 
                if(stack_frame)
-                       emit(userenv[JIT_EPILOG]);
-               emit(userenv[JIT_RETURN]);
+                       emit(myvm->userenv[JIT_EPILOG]);
+               emit(myvm->userenv[JIT_RETURN]);
        }
 }
 
index f8c099bbfd38b4f7a6da59c23bb6fb73ec7e8556..1d670e36255f30b97b3827b3f1ee473223b84dba 100755 (executable)
@@ -1,7 +1,5 @@
 #include "master.hpp"
 
-factor::cell userenv[USER_ENV];
-
 namespace factor
 {
 
index 4b43a156e43c4287d03f80bc503a2744a2beec76..d10a6678b821cd5e5125a84b06aa9e1ce7434c46 100755 (executable)
@@ -109,5 +109,4 @@ PRIMITIVE(clone);
 
 }
 
-/* TAGGED user environment data; see getenv/setenv prims */
-VM_C_API factor::cell userenv[USER_ENV];
index 88b323adf4df4e1074a49fb9ba3aae117c208bd4..967956e0cfba49b1dcd37c0a7d73f66df94ab69c 100644 (file)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -8,8 +8,7 @@ struct factorvm {
        zone nursery; /* new objects are allocated here */
        cell cards_offset;
        cell decks_offset;
-       //      cell userenv[USER_ENV];  // prob best to put this last 
-
+       cell userenv[USER_ENV]; /* TAGGED user environment data; see getenv/setenv prims */
 
 
        // segments