diff --git a/vm/dispatch.cpp b/vm/dispatch.cpp index 85d92f90a0..e87cdeac70 100755 --- a/vm/dispatch.cpp +++ b/vm/dispatch.cpp @@ -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]); } } diff --git a/vm/inline_cache.cpp b/vm/inline_cache.cpp index 24008cae79..35479c29f5 100755 --- a/vm/inline_cache.cpp +++ b/vm/inline_cache.cpp @@ -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) diff --git a/vm/jit.cpp b/vm/jit.cpp index d474d23a18..cdb5acace3 100644 --- a/vm/jit.cpp +++ b/vm/jit.cpp @@ -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. diff --git a/vm/jit.hpp b/vm/jit.hpp index 81754be26a..a44f359ffe 100644 --- a/vm/jit.hpp +++ b/vm/jit.hpp @@ -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_) { diff --git a/vm/quotations.cpp b/vm/quotations.cpp index 9654e2eff3..7b03ada175 100755 --- a/vm/quotations.cpp +++ b/vm/quotations.cpp @@ -40,7 +40,7 @@ bool quotation_jit::primitive_call_p(cell i) { return (i + 2) == array_capacity(elements.untagged()) && tagged(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(array_nth(elements.untagged(),i)).type_p(QUOTATION_TYPE) && tagged(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(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(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(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(array_nth(elements.untagged(),i)).type_p(ARRAY_TYPE) && tagged(array_nth(elements.untagged(),i + 1)).type_p(FIXNUM_TYPE) && tagged(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()->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]); } } diff --git a/vm/run.cpp b/vm/run.cpp index f8c099bbfd..1d670e3625 100755 --- a/vm/run.cpp +++ b/vm/run.cpp @@ -1,7 +1,5 @@ #include "master.hpp" -factor::cell userenv[USER_ENV]; - namespace factor { diff --git a/vm/run.hpp b/vm/run.hpp index 4b43a156e4..d10a6678b8 100755 --- a/vm/run.hpp +++ b/vm/run.hpp @@ -109,5 +109,4 @@ PRIMITIVE(clone); } -/* TAGGED user environment data; see getenv/setenv prims */ -VM_C_API factor::cell userenv[USER_ENV]; + diff --git a/vm/vm.hpp b/vm/vm.hpp index 88b323adf4..967956e0cf 100644 --- 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