Paste: callsite splitting
Author: | littledan |
Mode: | factor |
Date: | Thu, 16 Jul 2009 17:47:15 |
Plain Text |
USING: words kernel locals accessors compiler.tree.propagation.info
sequences kernel.private assocs fry parser math quotations
effects arrays definitions compiler.units namespaces ;
IN: specialized
: in-compilation-unit? ( -- ? )
changed-definitions get >boolean ;
: evil-define-temp ( quot effect -- word )
in-compilation-unit?
[ define-temp ]
[ [ define-temp ] with-compilation-unit ]
if ;
:: lookup-specialized ( #call word n -- special-word/f )
#call in-d>> n tail* >array [ value-info class>> ] map
dup [ object = ] all? [ drop f ] [
word "specialized-defs" word-prop [
[ declare ] curry word def>> compose
word stack-effect evil-define-temp 1quotation
] cache
] if ;
: specialized-quot ( word n -- quot )
'[ _ _ lookup-specialized ] ;
: define-specialized ( word n -- )
[ drop H{ } clone "specialized-defs" set-word-prop ]
[ dupd specialized-quot "custom-inlining" set-word-prop ] 2bi ;
ERROR: bad-specialized ;
SYNTAX: SPECIALIZED:
scan-word scan-object
dup integer? [ bad-specialized ] unless
define-specialized ;
Author: | littledan |
Mode: | factor |
Date: | Thu, 16 Jul 2009 18:10:55 |
Plain Text |
: evil-define-temp ( quot effect -- word )
in-compilation-unit?
[ [ define-temp ] with-nested-compilation-unit ]
[ [ define-temp ] with-compilation-unit ]
if ;
Author: | littledan |
Mode: | factor |
Date: | Thu, 16 Jul 2009 23:08:32 |
Plain Text |
: record-final-info ( word -- )
dup def>> final-info >quotation "outputs" set-word-prop ;
:: lookup-specialized ( #call word n -- special-word/f )
#call in-d>> n tail* >array [ value-info class>> ] map
dup [ object = ] all? [ drop f ] [
word "specialized-defs" word-prop [
[ declare ] curry word def>> compose
word stack-effect evil-define-temp
dup record-final-info
1quotation
] cache
] if ;
Author: | littledan |
Mode: | factor |
Date: | Fri, 17 Jul 2009 00:29:13 |
Plain Text |
USING: words kernel locals accessors compiler.tree.propagation.info
sequences kernel.private assocs fry parser math quotations
effects arrays definitions compiler.units namespaces
compiler.tree.debugger generalizations stack-checker ;
IN: specialized
: in-compilation-unit? ( -- ? )
changed-definitions get >boolean ;
: evil-define-temp ( quot effect -- word )
in-compilation-unit?
[ [ define-temp ] with-nested-compilation-unit ]
[ [ define-temp ] with-compilation-unit ]
if ;
: final-info-quot ( word -- quot )
[ stack-effect in>> length '[ _ ndrop ] ]
[ def>> [ final-info ] with-scope >quotation ] bi
compose ;
ERROR: bad-outputs word quot ;
: define-outputs ( word quot -- )
2dup [ stack-effect ] [ infer ] bi* effect<=
[ "outputs" set-word-prop ] [ bad-outputs ] if ;
: record-final-info ( word -- )
dup final-info-quot define-outputs ;
:: lookup-specialized ( #call word n -- special-word/f )
#call in-d>> n tail* >array [ value-info class>> ] map
dup [ object = ] all? [ drop f ] [
word "specialized-defs" word-prop [
[ declare ] curry word def>> compose
word stack-effect evil-define-temp
dup record-final-info
1quotation
] cache
] if ;
: specialized-quot ( word n -- quot )
'[ _ _ lookup-specialized ] ;
: define-specialized ( word n -- )
[ drop H{ } clone "specialized-defs" set-word-prop ]
[ dupd specialized-quot "custom-inlining" set-word-prop ] 2bi ;
ERROR: bad-specialized ;
SYNTAX: SPECIALIZED:
scan-word scan-object
dup integer? [ bad-specialized ] unless
define-specialized ;
New Annotation