diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index f8149ca69b..0afe6e34cf 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -85,6 +85,7 @@ + compiler/ffi: +- we need to optimize [ dup array? [ array? ] [ array? ] if ] - mac intel: struct returns from objc methods - fix compiled gc check - there was a performance hit, investigate diff --git a/library/bootstrap/boot-stage2.factor b/library/bootstrap/boot-stage2.factor index 24487fb1ba..95a72813e7 100644 --- a/library/bootstrap/boot-stage2.factor +++ b/library/bootstrap/boot-stage2.factor @@ -57,11 +57,14 @@ parser sequences sequences-internals words ; "x11" get [ "/library/ui/x11/load.factor" run-resource ] when - ] when + + ! We only do this if we are compiled, otherwise it takes + ! too long. - "Building online help search index..." print flush - H{ } clone parent-graph set-global xref-help - H{ } clone term-index set-global index-help + "Building online help search index..." print flush + H{ } clone parent-graph set-global xref-help + H{ } clone term-index set-global index-help + ] when [ boot @@ -86,6 +89,6 @@ parser sequences sequences-internals words ; "Now, you can run ./f factor.image" print flush "factor.image" resource-path save-image -] [ print-error listener ] recover +] [ print-error :c ] recover 0 exit diff --git a/library/bootstrap/primitives.factor b/library/bootstrap/primitives.factor index 827ff7198d..78e17f768f 100644 --- a/library/bootstrap/primitives.factor +++ b/library/bootstrap/primitives.factor @@ -372,7 +372,7 @@ num-types f builtins set f } { 2 - fixnum + object { "string-hashcode" "kernel-internals" } { "set-string-hashcode" "kernel-internals" } } diff --git a/library/compiler/inference/dataflow.factor b/library/compiler/inference/dataflow.factor index 89abd68f8c..4578a56971 100644 --- a/library/compiler/inference/dataflow.factor +++ b/library/compiler/inference/dataflow.factor @@ -268,3 +268,18 @@ DEFER: (map-nodes) #! Mutates nodes. node-stack get 1 head-slice* swap add [ >r 2dup r> node-successor (subst-values) ] each 2drop ; + +: node-literal? ( node value -- ? ) + dup value? + [ 2drop t ] [ swap node-literals ?hash* nip ] if ; + +: node-literal ( node value -- obj ) + dup value? + [ nip value-literal ] [ swap node-literals ?hash ] if ; + +: node-class ( node value -- class ) + dup value? [ + nip value-literal class + ] [ + swap node-classes ?hash [ object ] unless* + ] if ; diff --git a/library/compiler/optimizer/call-optimizers.factor b/library/compiler/optimizer/call-optimizers.factor index d67d218cbe..baa2d00dc5 100644 --- a/library/compiler/optimizer/call-optimizers.factor +++ b/library/compiler/optimizer/call-optimizers.factor @@ -23,7 +23,7 @@ math math-internals sequences words ; ] if ; : literal-in-d ( #call -- inputs ) - dup node-in-d [ node-value-literal ] map-with ; + dup node-in-d [ node-literal ] map-with ; : partial-eval ( #call -- node ) dup literal-in-d over node-param diff --git a/library/compiler/optimizer/class-infer.factor b/library/compiler/optimizer/class-infer.factor index 7d43214d05..b523e93523 100644 --- a/library/compiler/optimizer/class-infer.factor +++ b/library/compiler/optimizer/class-infer.factor @@ -155,8 +155,7 @@ DEFER: (infer-classes) ] 2each ; : merge-value-class ( # nodes -- class ) - [ tuck node-in-d ?nth node-class ] map-with - null [ class-or ] reduce ; + [ swap node-class# ] map-with null [ class-or ] reduce ; : annotate-merge ( nodes values -- ) dup length @@ -165,7 +164,7 @@ DEFER: (infer-classes) : merge-children ( node -- ) dup node-successor dup #merge? [ - node-out-d + node-out-d >r node-children [ last-node ] map r> annotate-merge ] [ diff --git a/library/compiler/optimizer/inline-methods.factor b/library/compiler/optimizer/inline-methods.factor index 60ff84bed8..bdd9d2ce71 100644 --- a/library/compiler/optimizer/inline-methods.factor +++ b/library/compiler/optimizer/inline-methods.factor @@ -19,7 +19,8 @@ words ; : dispatch# ( #call -- n ) node-param "combination" word-prop first ; -: dispatching-class ( node -- seq ) dup dispatch# node-class# ; +: dispatching-class ( node -- class ) + dup dispatch# node-class# ; : already-inlined? ( node -- ? ) #! Was this node inlined from definition of 'word'? diff --git a/library/compiler/optimizer/optimizer.factor b/library/compiler/optimizer/optimizer.factor index e42b984d23..c53329131c 100644 --- a/library/compiler/optimizer/optimizer.factor +++ b/library/compiler/optimizer/optimizer.factor @@ -79,21 +79,6 @@ M: #return optimize-node* ( node -- node/t ) set-node-successor ; ! Constant branch folding -: node-literal? ( node value -- ? ) - dup value? - [ 2drop t ] [ swap node-literals ?hash* nip ] if ; - -: node-literal ( node value -- obj ) - dup value? - [ nip value-literal ] [ swap node-literals ?hash ] if ; - -: node-class ( node value -- class ) - dup value? [ - nip value-literal class - ] [ - swap node-classes ?hash [ object ] unless* - ] if ; - : fold-branch ( node branch# -- node ) over drop-inputs >r >r dup node-successor r> rot node-children nth diff --git a/library/generic/classes.factor b/library/generic/classes.factor index b971fdcaa6..81664529bc 100644 --- a/library/generic/classes.factor +++ b/library/generic/classes.factor @@ -92,7 +92,7 @@ SYMBOL: classclass dup ] map>hash ; : (class-or) ( class class -- class ) - [ flatten-class ] 2apply hash-union lookup-union ; + [ types* ] 2apply hash-union lookup-union ; : class-or ( class class -- class ) { @@ -102,7 +102,7 @@ SYMBOL: class