From 4e55cd973bbcc08154c6e6d6ccd2ae2d4d4199ff Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 6 Nov 2008 11:48:55 -0600 Subject: [PATCH] If a #dispatch branch is a call to another word which is not an intrinsic, we avoid generating the dispatch branch and just jump to the word directly --- basis/compiler/cfg/builder/builder.factor | 35 +++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/basis/compiler/cfg/builder/builder.factor b/basis/compiler/cfg/builder/builder.factor index 5b9f2e068b..93daa601fe 100755 --- a/basis/compiler/cfg/builder/builder.factor +++ b/basis/compiler/cfg/builder/builder.factor @@ -156,19 +156,30 @@ M: #if emit-node } cond iterate-next ; ! #dispatch +: trivial-dispatch-branch? ( nodes -- ? ) + dup length 1 = [ + first dup #call? [ + word>> "intrinsic" word-prop not + ] [ drop f ] if + ] [ drop f ] if ; + : dispatch-branch ( nodes word -- label ) - gensym [ - [ - V{ } clone node-stack set - ##prologue - emit-nodes - basic-block get [ - ##epilogue - ##return - end-basic-block - ] when - ] with-cfg-builder - ] keep ; + over trivial-dispatch-branch? [ + drop first word>> + ] [ + gensym [ + [ + V{ } clone node-stack set + ##prologue + emit-nodes + basic-block get [ + ##epilogue + ##return + end-basic-block + ] when + ] with-cfg-builder + ] keep + ] if ; : dispatch-branches ( node -- ) children>> [