2008-08-02 00:31:43 -04:00
|
|
|
! Copyright (C) 2008 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
USING: kernel accessors sequences classes.tuple
|
|
|
|
classes.tuple.private math math.private slots.private
|
2008-08-03 22:32:12 -04:00
|
|
|
combinators dequeues search-dequeues namespaces fry classes
|
|
|
|
stack-checker.state
|
2008-08-02 00:31:43 -04:00
|
|
|
compiler.tree
|
|
|
|
compiler.tree.propagation.info
|
|
|
|
compiler.tree.escape-analysis.nodes
|
|
|
|
compiler.tree.escape-analysis.allocations ;
|
|
|
|
IN: compiler.tree.escape-analysis.simple
|
|
|
|
|
2008-08-04 05:35:31 -04:00
|
|
|
M: #introduce escape-analysis*
|
|
|
|
value>> unknown-allocation ;
|
|
|
|
|
|
|
|
: record-literal-allocation ( value object -- )
|
|
|
|
dup class immutable-tuple-class? [
|
|
|
|
tuple-slots rest-slice
|
|
|
|
[ <slot-value> [ swap record-literal-allocation ] keep ] map
|
|
|
|
swap record-allocation
|
|
|
|
] [
|
|
|
|
drop unknown-allocation
|
|
|
|
] if ;
|
|
|
|
|
2008-08-03 22:32:12 -04:00
|
|
|
M: #push escape-analysis*
|
|
|
|
#! Delegation.
|
2008-08-04 05:35:31 -04:00
|
|
|
[ out-d>> first ] [ literal>> ] bi record-literal-allocation ;
|
2008-08-03 22:32:12 -04:00
|
|
|
|
2008-08-02 00:31:43 -04:00
|
|
|
: record-tuple-allocation ( #call -- )
|
|
|
|
#! Delegation.
|
|
|
|
dup dup in-d>> peek node-value-info literal>>
|
2008-08-03 22:32:12 -04:00
|
|
|
class>> immutable-tuple-class? [
|
2008-08-02 00:31:43 -04:00
|
|
|
[ in-d>> but-last ] [ out-d>> first ] bi
|
|
|
|
record-allocation
|
2008-08-04 05:35:31 -04:00
|
|
|
] [ out-d>> unknown-allocations ] if ;
|
2008-08-02 00:31:43 -04:00
|
|
|
|
|
|
|
: record-slot-call ( #call -- )
|
|
|
|
[ out-d>> first ]
|
|
|
|
[ dup in-d>> second node-value-info literal>> ]
|
|
|
|
[ in-d>> first ] tri
|
2008-08-04 05:35:31 -04:00
|
|
|
over fixnum? [
|
|
|
|
[ 3 - ] dip record-slot-access
|
|
|
|
] [
|
|
|
|
2drop unknown-allocation
|
|
|
|
] if ;
|
2008-08-02 00:31:43 -04:00
|
|
|
|
|
|
|
M: #call escape-analysis*
|
|
|
|
dup word>> {
|
|
|
|
{ \ <tuple-boa> [ record-tuple-allocation ] }
|
|
|
|
{ \ slot [ record-slot-call ] }
|
2008-08-04 05:35:31 -04:00
|
|
|
[
|
|
|
|
drop
|
|
|
|
[ in-d>> add-escaping-values ]
|
|
|
|
[ out-d>> unknown-allocations ] bi
|
|
|
|
]
|
2008-08-02 00:31:43 -04:00
|
|
|
} case ;
|
|
|
|
|
|
|
|
M: #return escape-analysis*
|
|
|
|
in-d>> add-escaping-values ;
|