From b48aca89a63f8356ae9661e8db7864f76d0c2f07 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 20 Jul 2008 01:13:14 -0500 Subject: [PATCH] Optimizer report now shows number of passes --- extra/optimizer/debugger/debugger.factor | 25 ++++++++++++++---------- extra/reports/optimizer/optimizer.factor | 16 ++++++--------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/extra/optimizer/debugger/debugger.factor b/extra/optimizer/debugger/debugger.factor index fdae538896..7fe317aadd 100755 --- a/extra/optimizer/debugger/debugger.factor +++ b/extra/optimizer/debugger/debugger.factor @@ -3,8 +3,8 @@ USING: classes io kernel kernel.private math.parser namespaces optimizer prettyprint prettyprint.backend sequences words arrays match macros assocs sequences.private generic combinators -sorting math quotations accessors inference inference.dataflow -optimizer.specializers ; +sorting math quotations accessors inference inference.backend +inference.dataflow optimizer.specializers generator ; IN: optimizer.debugger ! A simple tool for turning dataflow IR into quotations, for @@ -135,14 +135,21 @@ M: object node>quot : optimized-word. ( word ? -- ) >r specialized-def r> optimized-quot. ; +SYMBOL: pass-count SYMBOL: words-called SYMBOL: generics-called SYMBOL: methods-called SYMBOL: intrinsics-called SYMBOL: node-count -: dataflow>report ( node -- alist ) +: count-optimization-passes ( node n -- node n ) + >r optimize-1 + [ r> 1+ count-optimization-passes ] [ r> ] if ; + +: make-report ( word -- assoc ) [ + word-dataflow nip 1 count-optimization-passes pass-count set + H{ } clone words-called set H{ } clone generics-called set H{ } clone methods-called set @@ -164,14 +171,12 @@ SYMBOL: node-count node-count set ] H{ } make-assoc ; -: quot-optimize-report ( quot -- report ) - dataflow optimize dataflow>report ; - -: word-optimize-report ( word -- report ) - def>> quot-optimize-report ; - : report. ( report -- ) [ + "==== Optimization passes:" print + pass-count get . + nl + "==== Total number of dataflow nodes:" print node-count get . @@ -186,4 +191,4 @@ SYMBOL: node-count ] bind ; : optimizer-report. ( word -- ) - word-optimize-report report. ; + make-report report. ; diff --git a/extra/reports/optimizer/optimizer.factor b/extra/reports/optimizer/optimizer.factor index ec3668b83b..b51fa5c8ee 100755 --- a/extra/reports/optimizer/optimizer.factor +++ b/extra/reports/optimizer/optimizer.factor @@ -2,13 +2,10 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs words sequences arrays compiler tools.time io.styles io prettyprint vocabs kernel sorting -generator optimizer math math.order math.statistics combinators ; +generator optimizer math math.order math.statistics combinators +optimizer.debugger ; IN: report.optimizer -: count-optimization-passes ( nodes n -- n ) - >r optimize-1 - [ r> 1+ count-optimization-passes ] [ drop r> ] if ; - : table. ( alist -- ) 20 short tail* standard-table-style @@ -28,13 +25,12 @@ IN: report.optimizer tri ] 2bi ; inline +: optimization-passes ( word -- n ) + word-dataflow nip 1 count-optimization-passes nip ; + : optimizer-measurements ( -- alist ) all-words [ compiled>> ] filter - [ - dup [ - word-dataflow nip 1 count-optimization-passes - ] benchmark 2array - ] { } map>assoc ; + [ dup [ optimization-passes ] benchmark 2array ] { } map>assoc ; : optimizer-measurements. ( alist -- ) {