From 0a5b076c11531994c29e296ea42cc9a863b5c1f5 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 16 Apr 2009 23:14:11 -0500 Subject: [PATCH] Make the walker infer --- basis/compiler/compiler.factor | 21 ++++++++++--------- basis/compiler/tree/builder/builder.factor | 3 +++ .../tree/propagation/inlining/inlining.factor | 6 +++++- .../tools/continuations/continuations.factor | 11 +++++----- core/continuations/continuations.factor | 16 +++++++------- 5 files changed, 32 insertions(+), 25 deletions(-) diff --git a/basis/compiler/compiler.factor b/basis/compiler/compiler.factor index 0afe7f1141..e5d88af14a 100644 --- a/basis/compiler/compiler.factor +++ b/basis/compiler/compiler.factor @@ -63,19 +63,20 @@ SYMBOLS: +optimized+ +unoptimized+ ; } 1|| ] [ error-type +compiler-warning+ eq? ] bi* and ; -: fail ( word error -- * ) - [ 2dup ignore-error? [ drop f ] when swap compiler-error ] - [ - drop - [ compiled-unxref ] - [ f swap compiled get set-at ] - [ +unoptimized+ save-compiled-status ] - tri - ] 2bi +: (fail) ( word -- * ) + [ compiled-unxref ] + [ f swap compiled get set-at ] + [ +unoptimized+ save-compiled-status ] + tri return ; +: fail ( word error -- * ) + [ 2dup ignore-error? [ drop f ] when swap compiler-error ] [ drop (fail) ] 2bi ; + : frontend ( word -- nodes ) - [ build-tree-from-word ] [ fail ] recover optimize-tree ; + dup contains-breakpoints? [ (fail) ] [ + [ build-tree-from-word ] [ fail ] recover optimize-tree + ] if ; ! Only switch this off for debugging. SYMBOL: compile-dependencies? diff --git a/basis/compiler/tree/builder/builder.factor b/basis/compiler/tree/builder/builder.factor index dc87d596aa..fe9c2a26a4 100644 --- a/basis/compiler/tree/builder/builder.factor +++ b/basis/compiler/tree/builder/builder.factor @@ -58,3 +58,6 @@ TUPLE: do-not-compile word ; } cleave ] maybe-cannot-infer ] with-tree-builder ; + +: contains-breakpoints? ( word -- ? ) + def>> [ word? ] filter [ "break?" word-prop ] any? ; diff --git a/basis/compiler/tree/propagation/inlining/inlining.factor b/basis/compiler/tree/propagation/inlining/inlining.factor index f18cfcd3a3..0815351057 100755 --- a/basis/compiler/tree/propagation/inlining/inlining.factor +++ b/basis/compiler/tree/propagation/inlining/inlining.factor @@ -148,7 +148,11 @@ DEFER: (flat-length) ] sum-outputs ; : should-inline? ( #call word -- ? ) - dup "inline" word-prop [ 2drop t ] [ inlining-rank 5 >= ] if ; + { + { [ dup contains-breakpoints? ] [ 2drop f ] } + { [ dup "inline" word-prop ] [ 2drop t ] } + [ inlining-rank 5 >= ] + } cond ; SYMBOL: history diff --git a/basis/tools/continuations/continuations.factor b/basis/tools/continuations/continuations.factor index 75eeb602fb..1ecb10be6c 100644 --- a/basis/tools/continuations/continuations.factor +++ b/basis/tools/continuations/continuations.factor @@ -12,7 +12,6 @@ IN: tools.continuations : after-break ( object -- ) { { [ dup continuation? ] [ (continue) ] } - { [ dup quotation? ] [ call ] } { [ dup not ] [ "Single stepping abandoned" rethrow ] } } cond ; @@ -22,7 +21,7 @@ SYMBOL: break-hook : break ( -- ) continuation callstack >>call - break-hook get call + break-hook get call( continuation -- continuation' ) after-break ; \ break t "break?" set-word-prop @@ -125,14 +124,14 @@ PRIVATE> } [ "step-into" set-word-prop ] assoc-each ! Never step into these words +: don't-step-into ( word -- ) + dup [ execute break ] curry "step-into" set-word-prop ; + { >n ndrop >c c> continue continue-with stop suspend (spawn) -} [ - dup [ execute break ] curry - "step-into" set-word-prop -] each +} [ don't-step-into ] each \ break [ break ] "step-into" set-word-prop diff --git a/core/continuations/continuations.factor b/core/continuations/continuations.factor index e350b24856..56ac4a71e9 100644 --- a/core/continuations/continuations.factor +++ b/core/continuations/continuations.factor @@ -74,14 +74,14 @@ C: continuation continuation< - set-catchstack - set-namestack - set-retainstack - [ set-datastack ] dip - set-callstack ; - -\ (continue) t "no-compile" set-word-prop + [ + >continuation< + set-catchstack + set-namestack + set-retainstack + [ set-datastack ] dip + set-callstack + ] (( continuation -- * )) call-effect-unsafe ; PRIVATE>