]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: put code block owner directly in the header, instead of as the first entry in...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 6 Oct 2009 11:25:07 +0000 (06:25 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 6 Oct 2009 11:25:07 +0000 (06:25 -0500)
20 files changed:
basis/command-line/command-line-docs.factor
basis/compiler/codegen/codegen.factor
basis/compiler/codegen/fixup/fixup.factor
basis/tools/deploy/backend/backend.factor
basis/tools/deploy/deploy-tests.factor
basis/tools/deploy/shaker/shaker.factor
core/bootstrap/primitives.factor
vm/callstack.cpp
vm/code_block.cpp
vm/code_heap.cpp
vm/data_gc.cpp
vm/factor.cpp
vm/image.cpp
vm/image.hpp
vm/jit.cpp
vm/layouts.hpp
vm/primitives.cpp
vm/primitives.hpp
vm/run.hpp
vm/vm.hpp

index 6bcdd4f4afe26e8e30dee835d6db9fc7c5053e6e..697f95b14f595ed1a34d4f0f95ae7dd2a2b86a02 100644 (file)
@@ -47,7 +47,6 @@ ARTICLE: "runtime-cli-args" "Command line switches for the VM"
     { { $snippet "-i=" { $emphasis "image" } } { "Specifies the image file to use; see " { $link "images" } } }
     { { $snippet "-datastack=" { $emphasis "n" } } "Data stack size, kilobytes" }
     { { $snippet "-retainstack=" { $emphasis "n" } } "Retain stack size, kilobytes" }
-    { { $snippet "-generations=" { $emphasis "n" } } "Number of generations, must equal 1, 2 or 3" }
     { { $snippet "-young=" { $emphasis "n" } } { "Size of youngest generation (0), megabytes" } }
     { { $snippet "-aging=" { $emphasis "n" } } "Size of aging generation (1), megabytes" }
     { { $snippet "-tenured=" { $emphasis "n" } } "Size of oldest generation (2), megabytes" }
index 121f09a5a8b40a22640a392161176b0fd1c79f1d..a750e6d6105966e9d34c2cb69fabbe6c4200f085 100755 (executable)
@@ -32,30 +32,21 @@ SYMBOL: calls
     #! Compile this word later.
     calls get push ;
 
-SYMBOL: compiling-word
-
-: compiled-stack-traces? ( -- ? ) 67 getenv ;
-
 ! Mapping _label IDs to label instances
 SYMBOL: labels
 
-: init-generator ( word -- )
+: init-generator ( -- )
     H{ } clone labels set
-    V{ } clone calls set
-    compiling-word set
-    compiled-stack-traces? [ compiling-word get add-literal ] when ;
+    V{ } clone calls set ;
 
 : generate-insns ( asm -- code )
-    [
-        [ word>> init-generator ]
-        [
-            instructions>>
-            [
-                [ class insn-counts get inc-at ]
-                [ generate-insn ]
-                bi
-            ] each
-        ] bi
+    dup word>> [
+        init-generator
+        instructions>> [
+            [ class insn-counts get inc-at ]
+            [ generate-insn ]
+            bi
+        ] each
     ] with-fixup ;
 
 : generate ( mr -- asm )
index d44f6afd994e680988ac7bca3a6fbdf74573a9c5..60dd055a5f6eb00343757309b589eeffd69f8626 100755 (executable)
@@ -4,9 +4,12 @@ USING: arrays byte-arrays byte-vectors generic assocs hashtables
 io.binary kernel kernel.private math namespaces make sequences
 words quotations strings alien.accessors alien.strings layouts
 system combinators math.bitwise math.order
-accessors growable compiler.constants ;
+accessors growable fry generalizations compiler.constants ;
 IN: compiler.codegen.fixup
 
+! Owner
+SYMBOL: compiling-word
+
 ! Literal table
 SYMBOL: literal-table
 
@@ -91,17 +94,19 @@ SYMBOL: relocation-table
     [ [ resolve-relative-label ] map concat ]
     bi* ;
 
-: init-fixup ( -- )
+: init-fixup ( word -- )
+    compiling-word set
     V{ } clone literal-table set
     V{ } clone label-table set
     BV{ } clone relocation-table set ;
 
-: with-fixup ( quot -- code )
-    [
+: with-fixup ( word quot -- code )
+    '[
         init-fixup
-        call
+        @
         label-table [ resolve-labels ] change
+        compiling-word get
         literal-table get >array
         relocation-table get >byte-array
         label-table get
-    ] B{ } make 4array ; inline
+    ] B{ } make 5 narray ; inline
index ba822769272f302e4143ffb6cb6cb971cefbf787..bd58c7505b8fe19ca91ce854fef8aef046b8662d 100755 (executable)
@@ -53,9 +53,7 @@ CONSTANT: theme-path "basis/ui/gadgets/theme/"
     ] { } make ;
 
 : staging-image-name ( profile -- name )
-    "staging."
-    swap strip-word-names? [ "strip" suffix ] when
-    "-" join ".image" 3append temp-file ;
+    "-" join "staging." ".image" surround temp-file ;
 
 DEFER: ?make-staging-image
 
@@ -72,7 +70,6 @@ DEFER: ?make-staging-image
         ] if
         "-output-image=" over staging-image-name append ,
         "-include=" swap " " join append ,
-        strip-word-names? [ "-no-stack-traces" , ] when
         "-no-user-init" ,
     ] { } make ;
 
@@ -102,7 +99,6 @@ DEFER: ?make-staging-image
             [ "-deploy-vocab=" prepend , ]
             [ make-deploy-config "-deploy-config=" prepend , ] bi
             "-output-image=" prepend ,
-            strip-word-names? [ "-no-stack-traces" , ] when
         ] { } make
     ] bind ;
 
index 012b5405115458b5ba8b1321239ff880e833f0f1..6a1f949b0b40b9c7499dd44096a8d485a5950fbd 100644 (file)
@@ -11,7 +11,7 @@ IN: tools.deploy.tests
 \r
 [ t ] [ "hello-ui" shake-and-bake 1300000 small-enough? ] unit-test\r
 \r
-[ "staging.math-threads-compiler-ui-strip.image" ] [\r
+[ "staging.math-threads-compiler-ui.image" ] [\r
     "hello-ui" deploy-config\r
     [ bootstrap-profile staging-image-name file-name ] bind\r
 ] unit-test\r
index c623ea419423ec432efa461f756ff45fe770a794..994073b149c024833f1c875b734fadc093924c5d 100755 (executable)
@@ -208,7 +208,7 @@ IN: tools.deploy.shaker
     [ word? ] instances
     deploy-word-props? get [ 2dup strip-word-props ] unless
     deploy-word-defs? get [ dup strip-word-defs ] unless
-    strip-word-names? [ dup strip-word-names ] when
+    strip-word-names? [ dup strip-word-names strip-stack-traces ] when
     2drop ;
 
 : compiler-classes ( -- seq )
index f42ab779f48972a47aad3f56dc23624a19d2791f..23da40d2c5d67146aaf9e9083ae4096f20fed74e 100644 (file)
@@ -522,6 +522,7 @@ tuple
     { "optimized?" "words" (( word -- ? )) }
     { "quot-compiled?" "quotations" (( quot -- ? )) }
     { "vm-ptr" "vm" (( -- ptr )) }
+    { "strip-stack-traces" "kernel.private" (( -- )) }
 } [ [ first3 ] dip swap make-primitive ] each-index
 
 ! Bump build number
index da3a2a089546cf2ac54f1bc6bd88264757ee1032..954eedcecbcccb9f3cc40e72c13edf870305fbbc 100755 (executable)
@@ -86,16 +86,7 @@ cell factor_vm::frame_type(stack_frame *frame)
 
 cell factor_vm::frame_executing(stack_frame *frame)
 {
-       code_block *compiled = frame_code(frame);
-       if(compiled->literals == F || !stack_traces_p())
-               return F;
-       else
-       {
-               array *literals = untag<array>(compiled->literals);
-               cell executing = array_nth(literals,0);
-               check_data_pointer((object *)executing);
-               return executing;
-       }
+       return frame_code(frame)->owner;
 }
 
 stack_frame *factor_vm::frame_successor(stack_frame *frame)
index 0967e01f4c43751f52e0b0deef83464c0b41f9c3..24c68c90ce591aed3872b7642684f6b0eb65331b 100755 (executable)
@@ -194,9 +194,9 @@ template<typename Iterator> void factor_vm::iterate_relocations(code_block *comp
        {
                byte_array *relocation = untag<byte_array>(compiled->relocation);
 
-               cell index = stack_traces_p() ? 1 : 0;
-
+               cell index = 0;
                cell length = array_capacity(relocation) / sizeof(relocation_entry);
+
                for(cell i = 0; i < length; i++)
                {
                        relocation_entry rel = relocation->data<relocation_entry>()[i];
@@ -425,16 +425,19 @@ code_block *factor_vm::allot_code_block(cell size, cell type)
 }
 
 /* Might GC */
-code_block *factor_vm::add_code_block(cell type, cell code_, cell labels_, cell relocation_, cell literals_)
+code_block *factor_vm::add_code_block(cell type, cell code_, cell labels_, cell owner_, cell relocation_, cell literals_)
 {
        gc_root<byte_array> code(code_,this);
        gc_root<object> labels(labels_,this);
+       gc_root<object> owner(owner_,this);
        gc_root<byte_array> relocation(relocation_,this);
        gc_root<array> literals(literals_,this);
 
        cell code_length = align8(array_capacity(code.untagged()));
        code_block *compiled = allot_code_block(code_length,type);
 
+       compiled->owner = owner.value();
+
        /* slight space optimization */
        if(relocation.type() == BYTE_ARRAY_TYPE && array_capacity(relocation.untagged()) == 0)
                compiled->relocation = F;
index d8fb6c53dd1e5090ce03e94ab55b3be81feb152d..6cb952cd36b7c86227077942a0b224120fb73928 100755 (executable)
@@ -91,15 +91,17 @@ void factor_vm::primitive_modify_code_heap()
                case ARRAY_TYPE:
                        {
                                array *compiled_data = data.as<array>().untagged();
-                               cell literals = array_nth(compiled_data,0);
-                               cell relocation = array_nth(compiled_data,1);
-                               cell labels = array_nth(compiled_data,2);
-                               cell code = array_nth(compiled_data,3);
+                               cell owner = array_nth(compiled_data,0);
+                               cell literals = array_nth(compiled_data,1);
+                               cell relocation = array_nth(compiled_data,2);
+                               cell labels = array_nth(compiled_data,3);
+                               cell code = array_nth(compiled_data,4);
 
                                code_block *compiled = add_code_block(
                                        WORD_TYPE,
                                        code,
                                        labels,
+                                       owner,
                                        relocation,
                                        literals);
 
@@ -245,4 +247,19 @@ void factor_vm::compact_code_heap()
        code->build_free_list(size);
 }
 
+struct stack_trace_stripper {
+       explicit stack_trace_stripper() {}
+
+       void operator()(code_block *compiled)
+       {
+               compiled->owner = F;
+       }
+};
+
+void factor_vm::primitive_strip_stack_traces()
+{
+       stack_trace_stripper stripper;
+       iterate_code_heap(stripper);
+}
+
 }
index cf84fe0084f0825b039d15c6914e601bf2f4ef4d..a5ce68d16e1b4c1d4b6a5c03278aed1f05f3bb50 100755 (executable)
@@ -287,6 +287,7 @@ template<typename Strategy> void factor_vm::trace_contexts(Strategy &strategy)
 /* Trace all literals referenced from a code block. Only for aging and nursery collections */
 template<typename Strategy> void factor_vm::trace_literal_references(code_block *compiled, Strategy &strategy)
 {
+       trace_handle(&compiled->owner,strategy);
        trace_handle(&compiled->literals,strategy);
        trace_handle(&compiled->relocation,strategy);
 }
index 9ade30318c64a6c22d2887ea2c176e0b18cbd274..9a26cacf1ac394eb1db09cf8924d1294edb56ef2 100755 (executable)
@@ -49,8 +49,6 @@ void factor_vm::default_parameters(vm_parameters *p)
                p->console = false;
        
 #endif
-
-       p->stack_traces = true;
 }
 
 bool factor_vm::factor_arg(const vm_char* str, const vm_char* arg, cell* value)
@@ -85,7 +83,6 @@ void factor_vm::init_parameters_from_args(vm_parameters *p, int argc, vm_char **
                else if(STRCMP(argv[i],STRING_LITERAL("-fep")) == 0) p->fep = true;
                else if(STRNCMP(argv[i],STRING_LITERAL("-i="),3) == 0) p->image_path = argv[i] + 3;
                else if(STRCMP(argv[i],STRING_LITERAL("-console")) == 0) p->console = true;
-               else if(STRCMP(argv[i],STRING_LITERAL("-no-stack-traces")) == 0) p->stack_traces = false;
        }
 }
 
@@ -152,10 +149,7 @@ void factor_vm::init_factor(vm_parameters *p)
        gc_off = false;
 
        if(userenv[STAGE2_ENV] == F)
-       {
-               userenv[STACK_TRACES_ENV] = tag_boolean(p->stack_traces);
                do_stage1_init();
-       }
 }
 
 /* May allocate memory */
index 1e10bd288654935f732fe7472e3c5e6a1677332b..90afaa82f2909295ccfeff7925c010af7754adae 100755 (executable)
@@ -295,8 +295,9 @@ void factor_vm::relocate_data()
 void factor_vm::fixup_code_block(code_block *compiled)
 {
        /* relocate literal table data */
-       data_fixup(&compiled->relocation);
+       data_fixup(&compiled->owner);
        data_fixup(&compiled->literals);
+       data_fixup(&compiled->relocation);
 
        relocate_code_block(compiled);
 }
index 5b1bcaf74aa209c7aa00a7f5982f583be6a37255..80ee2556e9cacf25a4929e66b863dfa216ccce28 100755 (executable)
@@ -37,7 +37,6 @@ struct vm_parameters {
        bool secure_gc;
        bool fep;
        bool console;
-       bool stack_traces;
        cell max_pic_size;
 };
 
index 3eb0f04547e5e3178ef47c42d5c0e842c5ea1ac4..77a311cb24d58d9beb3d05010f27dc7f9e8e017f 100644 (file)
@@ -20,9 +20,7 @@ jit::jit(cell type_, cell owner_, factor_vm *vm)
          position(0),
          offset(0),
          parent_vm(vm)
-{
-       if(parent_vm->stack_traces_p()) literal(owner.value());
-}
+{}
 
 void jit::emit_relocation(cell code_template_)
 {
@@ -106,6 +104,7 @@ code_block *jit::to_code_block()
                type,
                code.elements.value(),
                F, /* no labels */
+               owner.value(),
                relocation.elements.value(),
                literals.elements.value());
 }
index eb08ff20f389f8af61c44cda7f1e562bb1f1345b..68e2c7d87add51fbe79c49475bb595e410fd7778 100644 (file)
@@ -233,8 +233,8 @@ struct free_heap_block : public heap_block
 
 struct code_block : public heap_block
 {
-       cell unused;
-       cell literals; /* # bytes */
+       cell owner; /* tagged pointer to word, quotation or f */
+       cell literals; /* tagged pointer to array or f */
        cell relocation; /* tagged pointer to byte-array or f */
 
        void *xt() { return (void *)(this + 1); }
index e2e663333f41000c704c9658e251a0c02d9427ce..9419518d795b1ba7235c1c9e39540ca912f122d7 100644 (file)
@@ -164,6 +164,7 @@ const primitive_type primitives[] = {
        primitive_optimized_p,
        primitive_quot_compiled_p,
        primitive_vm_ptr,
+       primitive_strip_stack_traces,
 };
 
 PRIMITIVE_FORWARD(bignum_to_fixnum)
@@ -289,5 +290,6 @@ PRIMITIVE_FORWARD(inline_cache_stats)
 PRIMITIVE_FORWARD(optimized_p)
 PRIMITIVE_FORWARD(quot_compiled_p)
 PRIMITIVE_FORWARD(vm_ptr)
+PRIMITIVE_FORWARD(strip_stack_traces)
 
 }
index dd264869b29019b3790a540655a48244bb25bd90..cff22bf5fc4f772df138a1bdd9fb7c499e3c1a2e 100644 (file)
@@ -172,5 +172,6 @@ PRIMITIVE(inline_cache_stats);
 PRIMITIVE(optimized_p);
 PRIMITIVE(quot_compiled_p);
 PRIMITIVE(vm_ptr);
+PRIMITIVE(strip_stack_traces);
 
 }
index 23eabdfe14a0789f27f7e80dd182e7b5cc2160b8..cfc2acfb5c0863d86f81c94171533d8e121bf1fd 100755 (executable)
@@ -87,8 +87,6 @@ enum special_object {
        THREADS_ENV         = 64,
        RUN_QUEUE_ENV       = 65,
        SLEEP_QUEUE_ENV     = 66,
-
-       STACK_TRACES_ENV    = 67,
 };
 
 #define FIRST_SAVE_ENV BOOT_ENV
@@ -96,7 +94,7 @@ enum special_object {
 
 inline static bool save_env_p(cell i)
 {
-       return (i >= FIRST_SAVE_ENV && i <= LAST_SAVE_ENV) || i == STACK_TRACES_ENV;
+       return (i >= FIRST_SAVE_ENV && i <= LAST_SAVE_ENV);
 }
 
 }
index 5f327acb0bf3ff389e95d928609cf402a4ac104e..cb24ce8456f71ceb9be42dc42b5c115661f13881 100755 (executable)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -514,11 +514,7 @@ struct factor_vm
        void relocate_code_block(code_block *compiled);
        void fixup_labels(array *labels, code_block *compiled);
        code_block *allot_code_block(cell size, cell type);
-       code_block *add_code_block(cell type, cell code_, cell labels_, cell relocation_, cell literals_);
-       inline bool stack_traces_p()
-       {
-               return userenv[STACK_TRACES_ENV] != F;
-       }
+       code_block *add_code_block(cell type, cell code_, cell labels_, cell owner_, cell relocation_, cell literals_);
 
        //code_heap
        code_heap *code;
@@ -540,6 +536,7 @@ struct factor_vm
        void forward_object_xts();
        void fixup_object_xts();
        void compact_code_heap();
+       void primitive_strip_stack_traces();
 
        /* Apply a function to every code block */
        template<typename Iterator> void iterate_code_heap(Iterator &iter)