]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.crossref: changes the way in which dependencies are stored on words
authorBjörn Lindqvist <bjourne@gmail.com>
Mon, 28 Nov 2016 05:33:58 +0000 (06:33 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Wed, 30 Nov 2016 06:29:10 +0000 (07:29 +0100)
Previosly, they were stored in three sequences in the properties
"conditional-dependencies" "effect-dependencies" and
"definition-dependencies". It seem to better to store all three
types in one big property called "dependencies".

basis/compiler/crossref/crossref-docs.factor
basis/compiler/crossref/crossref-tests.factor
basis/compiler/crossref/crossref.factor
basis/compiler/tests/redefine3.factor
basis/tools/deploy/shaker/shaker.factor
core/words/words-docs.factor
core/words/words-tests.factor

index 6e77350b51e8c2fa23ebeb0d13ad7779d022d14c..5415ad0ca77f6dbc443285c407b928acf7ab3c3d 100644 (file)
@@ -1,13 +1,21 @@
-USING: assocs help.markup help.syntax words ;
+USING: assocs help.markup help.syntax sequences words ;
 IN: compiler.crossref
 
 HELP: compiled-crossref
-{ $var-description "A hashtable that maps words to other words that depend on them. It also stores the types of the dependencies." } ;
+{ $var-description "A hashtable that maps words to other words that depend on them and their dependency types." } ;
+
+HELP: delete-compiled-xref
+{ $values { "word" word } }
+{ $description "Deletes cross-referencing data for a word. Used when the optimizing compiler forgets a word." } ;
 
 HELP: load-dependencies
-{ $values { "word" word } { "assoc" assoc } }
-{ $description "Creates an assoc where keys are the words the word depends on and values are the dependency type." } ;
+{ $values { "word" word } { "seq" sequence } }
+{ $description "Outputs a sequence of the words dependencies." } ;
+
+HELP: remove-xref
+{ $values { "word" word } { "dependencies" sequence } { "crossref" assoc } }
+{ $description "Removes a set of dependencies from the cross referencing table." } ;
 
 HELP: store-dependencies
 { $values { "word" word } { "assoc" assoc } }
-{ $description "Stores the dependencies in 'assoc' in the word attributes named \"effect-dependencies\", \"conditional-dependencies\" and \"definition-dependencies\"." } ;
+{ $description "Stores the dependencies in 'assoc' in the word attribute \"dependencies\"." } ;
index 954c0b893802599ad24d03c5165f5673c9e25429..6b91c0874f97b8a2ad39643c451aedb632f803a3 100644 (file)
@@ -1,5 +1,5 @@
-USING: accessors assocs compiler.crossref fry kernel namespaces
-sequences stack-checker.dependencies tools.test vocabs words ;
+USING: assocs compiler.crossref fry io kernel namespaces sequences
+stack-checker.dependencies tools.test vocabs words ;
 IN: compiler.crossref.tests
 
 ! Dependencies of all words should always be satisfied unless we're
@@ -21,6 +21,19 @@ IN: compiler.crossref.tests
         }
     } clone ;
 
+! compiled-unxref
+SYMBOL: kolobi
+{ f f } [
+    ! Setup a fake dependency; kolobi -> print
+    +effect+ kolobi compiled-crossref get \ print of set-at
+    kolobi { print } "dependencies" set-word-prop
+
+    ! Ensure it is being forgotten
+    kolobi compiled-unxref
+    kolobi "dependencies" word-prop
+    compiled-crossref get \ print of kolobi of
+] unit-test
+
 ! dependencies-of
 {
     H{ { 20 +definition+ } }
@@ -38,18 +51,15 @@ IN: compiler.crossref.tests
     ] with-variable
 ] unit-test
 
-! join-dependencies
+! remove-xref
+SYMBOLS: foo1 bar ;
 {
-    H{
-        { 1 +effect+ }
-        { 2 +effect+ }
-        { 3 +conditional+ }
-        { 4 +conditional+ }
-        { 5 +definition+ }
-        { 6 +definition+ }
-    }
+    H{ { foo1 H{ } } }
 } [
-    { 1 2 } { 3 4 } { 5 6 } join-dependencies
+    bar { foo1 }
+    H{
+        { foo1 H{ { bar +definition+ } } }
+    } clone [ remove-xref ] keep
 ] unit-test
 
 ! store-dependencies
@@ -63,10 +73,8 @@ IN: compiler.crossref.tests
 
 SYMBOL: foo
 {
-    { 20 } { 40 50 } { 30 }
+    { 40 50 20 30 }
 } [
-    foo [ setup-deps store-dependencies ] keep props>>
-    [ "definition-dependencies" of ]
-    [ "effect-dependencies" of ]
-    [ "conditional-dependencies" of ] tri
+    foo [ setup-deps store-dependencies ] keep "dependencies" word-prop
+    foo delete-compiled-xref
 ] unit-test
index 88cfa018305267d374758ddab11eb7e1fa69139f..195a024f1fa54d4dcf32796d52216581d3bd1bd3 100644 (file)
@@ -47,11 +47,7 @@ generic-call-site-crossref [ H{ } clone ] initialize
     [ rot '[ nip _ = ] assoc-filter keys ] dip set-word-prop ;
 
 : store-dependencies ( word assoc -- )
-    {
-        { +effect+ "effect-dependencies" }
-        { +conditional+ "conditional-dependencies" }
-        { +definition+ "definition-dependencies" }
-    } [ store-dependencies-of-type ] 2with assoc-each ;
+    keys "dependencies" set-word-prop ;
 
 : add-xref ( word dependencies crossref -- )
     rot '[
@@ -59,7 +55,7 @@ generic-call-site-crossref [ H{ } clone ] initialize
     ] assoc-each ;
 
 : remove-xref ( word dependencies crossref -- )
-    [ keys ] dip '[ _ at delete-at ] with each ;
+    '[ _ at delete-at ] with each ;
 
 : (compiled-xref) ( word dependencies generic-dependencies -- )
     compiled-crossref generic-call-site-crossref
@@ -72,21 +68,8 @@ generic-call-site-crossref [ H{ } clone ] initialize
     [ (compiled-xref) ]
     3tri ;
 
-: set-at-each ( keys assoc value -- )
-    '[ _ [ _ ] 2dip set-at ] each ;
-
-: join-dependencies ( effect-deps cond-deps def-deps -- assoc )
-    H{ } clone [
-        [ +effect+ set-at-each ]
-        [ +conditional+ set-at-each ]
-        [ +definition+ set-at-each ] tri-curry tri*
-    ] keep ;
-
-: load-dependencies ( word -- assoc )
-    [ "effect-dependencies" word-prop ]
-    [ "conditional-dependencies" word-prop ]
-    [ "definition-dependencies" word-prop ] tri
-    join-dependencies ;
+: load-dependencies ( word -- seq )
+    "dependencies" word-prop ;
 
 : (compiled-unxref) ( word dependencies variable -- )
     get remove-xref ;
@@ -98,9 +81,7 @@ generic-call-site-crossref [ H{ } clone ] initialize
     {
         [ dup load-dependencies compiled-crossref (compiled-unxref) ]
         [ dup generic-call-sites generic-call-site-crossref (compiled-unxref) ]
-        [ "effect-dependencies" remove-word-prop ]
-        [ "conditional-dependencies" remove-word-prop ]
-        [ "definition-dependencies" remove-word-prop ]
+        [ "dependencies" remove-word-prop ]
         [ "generic-call-sites" remove-word-prop ]
     } cleave ;
 
index 84713612f5425965d961bd0b05e6cdba466d49a5..b58bd8447b8ffcf12f08d54fbc073bd292b602b4 100644 (file)
@@ -1,6 +1,5 @@
-USING: accessors compiler compiler.units tools.test math parser
-kernel sequences sequences.private classes.mixin generic
-definitions arrays words assocs eval grouping ;
+USING: arrays classes.mixin compiler.crossref compiler.units eval
+generic kernel sequences tools.test words ;
 IN: compiler.tests.redefine3
 
 GENERIC: sheeple ( obj -- x )
@@ -14,7 +13,7 @@ M: empty-mixin sheeple drop "wake up" ; inline
 : sheeple-test ( -- string ) { } sheeple ;
 
 : compiled-use? ( key word -- ? )
-    "definition-dependencies" word-prop member-eq? ;
+    load-dependencies member-eq? ;
 
 [ "sheeple" ] [ sheeple-test ] unit-test
 [ t ] [ \ sheeple-test word-optimized? ] unit-test
index a6559a19e14c611127ceadae283293c90e2833ed..15a43efbb35579b89c6c52f18444e1781168d56f 100755 (executable)
@@ -127,7 +127,6 @@ IN: tools.deploy.shaker
                 "boa-check"
                 "coercer"
                 "combination"
-                "conditional-dependencies"
                 "constant"
                 "constraints"
                 "custom-inlining"
@@ -136,11 +135,10 @@ IN: tools.deploy.shaker
                 "default"
                 "default-method"
                 "default-output-classes"
-                "definition-dependencies"
+                "dependencies"
                 "dependency-checks"
                 "derived-from"
                 "ebnf-parser"
-                "effect-dependencies"
                 "engines"
                 "forgotten"
 
index f9beeba3b295ed34378f21cfad3154f78b30e736..24052576c9be4f1ba4164d419b4a8085d45d3e48 100644 (file)
@@ -148,6 +148,17 @@ $nl
       { $snippet "\"specializer\"" }
       { $link "hints" }
   }
+  {
+      {
+          { $snippet "\"dependencies\"" } ", "
+
+      }
+      { "Used by the optimizing compiler when forgetting words for fast dependency lookup. See " { $link "compilation-units"  } "." }
+  }
+  {
+      { $snippet "\"generic-call-sites\"" }
+      { "Set on some generic words." }
+  }
 }
 "Properties which are defined for classes only:"
 { $table
index 0333cafec9fc1911efa06775353054a784aa9ea7..e07057f28030033cd18af3c419d757a3f1fa5908 100644 (file)
@@ -1,6 +1,6 @@
-USING: accessors arrays compiler.units definitions eval generic
-io.streams.string kernel math namespaces parser sequences tools.test
-vocabs words words.private words.symbol ;
+USING: accessors arrays compiler.crossref compiler.units definitions
+eval generic io.streams.string kernel math namespaces parser sequences
+tools.test vocabs words words.private words.symbol ;
 IN: words.tests
 
 { 4 } [
@@ -125,11 +125,9 @@ DEFER: deferred
 
 { { } }
 [
+    ! No word can have dependencies to forgotten words.
     all-words [
-        [ "effect-dependencies" word-prop ]
-        [ "definition-dependencies" word-prop ]
-        [ "conditional-dependencies" word-prop ] tri
-        3append [ "forgotten" word-prop ] filter
+        load-dependencies [ "forgotten" word-prop ] filter
     ] map harvest
 ] unit-test