From 77561573e0baf5a059fad22110032a4d7a0a1e92 Mon Sep 17 00:00:00 2001 From: slava Date: Fri, 18 Aug 2006 05:50:34 +0000 Subject: [PATCH] Slight speedup --- TODO.FACTOR.txt | 1 - library/compiler/compiler.factor | 1 + library/compiler/inference/inference.factor | 7 ++++++- library/compiler/inference/words.factor | 17 ++++++++++++----- library/math/complex.factor | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 0200c78e1d..1777c57e08 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -4,7 +4,6 @@ - document inference errors - update docs for declared effects - better doc for accumulate, link from tree -- bootstrap speedup with compiling recursives - RT_WORD should refer to XTs not word objects. - better listener multi-line expression handling - history doesn't work in a good way if you ^K the input diff --git a/library/compiler/compiler.factor b/library/compiler/compiler.factor index 6c027df1c5..ef9b4c98ac 100644 --- a/library/compiler/compiler.factor +++ b/library/compiler/compiler.factor @@ -7,6 +7,7 @@ words ; : word-dataflow ( word -- dataflow ) [ + dup ?no-effect dup dup add-recursive-state dup specialized-def (dataflow) swap current-effect check-effect diff --git a/library/compiler/inference/inference.factor b/library/compiler/inference/inference.factor index 548fcede4e..5ac09a1540 100644 --- a/library/compiler/inference/inference.factor +++ b/library/compiler/inference/inference.factor @@ -98,6 +98,11 @@ M: quotation infer-quot inference-error ] unless ; +: undo-infer ( -- ) + recorded get + [ "infer" word-prop not ] subset + [ f "infer-effect" set-word-prop ] each ; + : with-infer ( quot -- ) [ [ @@ -107,7 +112,7 @@ M: quotation infer-quot call check-return ] [ - recorded get [ f "infer-effect" set-word-prop ] each + undo-infer rethrow ] recover ] with-scope ; diff --git a/library/compiler/inference/words.factor b/library/compiler/inference/words.factor index 77cb25387e..bbe318d49c 100644 --- a/library/compiler/inference/words.factor +++ b/library/compiler/inference/words.factor @@ -118,10 +118,14 @@ TUPLE: effect-error word effect ; : effect-error ( word effect -- * ) throw ; : check-effect ( word effect -- ) - over recorded get push - dup pick "declared-effect" word-prop dup - [ effect<= [ effect-error ] unless ] [ 2drop ] if - "infer-effect" set-word-prop ; + over "infer" word-prop [ + 2drop + ] [ + over recorded get push + dup pick "declared-effect" word-prop dup + [ effect<= [ effect-error ] unless ] [ 2drop ] if + "infer-effect" set-word-prop + ] if ; M: compound apply-word #! Infer a compound word's stack effect. @@ -131,8 +135,11 @@ M: compound apply-word swap t "no-effect" set-word-prop rethrow ] recover ; +: ?no-effect ( word -- ) + dup "no-effect" word-prop [ no-effect ] [ drop ] if ; + : apply-default ( word -- ) - dup "no-effect" word-prop [ no-effect ] when + dup ?no-effect dup "infer-effect" word-prop [ over "infer" word-prop [ swap effect-in length ensure-values call drop diff --git a/library/math/complex.factor b/library/math/complex.factor index f2f08a7d64..55a7ce16cc 100644 --- a/library/math/complex.factor +++ b/library/math/complex.factor @@ -31,7 +31,7 @@ M: number equal? number= ; : >polar ( z -- abs arg ) dup abs swap >rect swap fatan2 ; inline -: cis ( arg --- z ) dup fcos swap fsin rect> ; inline +: cis ( arg -- z ) dup fcos swap fsin rect> ; inline : polar> ( abs arg -- z ) cis * ; inline