Only build a generic word once, even if a compilation unit defines several methods on it, by adding generics to a set and building them at the end. 25% improvement on bootstrap time
parent
2445a83cb9
commit
cdb5c30bd3
|
@ -8,7 +8,8 @@ grouping growable classes classes.builtin classes.tuple
|
|||
classes.tuple.private words.private io.binary io.files vocabs
|
||||
vocabs.loader source-files definitions debugger
|
||||
quotations.private sequences.private combinators
|
||||
io.encodings.binary math.order math.private accessors slots.private ;
|
||||
io.encodings.binary math.order math.private accessors
|
||||
slots.private compiler.units ;
|
||||
IN: bootstrap.image
|
||||
|
||||
: my-arch ( -- arch )
|
||||
|
@ -458,6 +459,8 @@ M: quotation '
|
|||
800000 <vector> image set
|
||||
20000 <hashtable> objects set
|
||||
emit-header t, 0, 1, -1,
|
||||
"Building generic words..." print flush
|
||||
call-remake-generics-hook
|
||||
"Serializing words..." print flush
|
||||
emit-words
|
||||
"Serializing JIT data..." print flush
|
||||
|
|
|
@ -36,6 +36,7 @@ H{ } clone dictionary set
|
|||
H{ } clone new-classes set
|
||||
H{ } clone changed-definitions set
|
||||
H{ } clone changed-generics set
|
||||
H{ } clone remake-generics set
|
||||
H{ } clone forgotten-definitions set
|
||||
H{ } clone root-cache set
|
||||
H{ } clone source-files set
|
||||
|
|
|
@ -42,7 +42,7 @@ TUPLE: check-mixin-class mixin ;
|
|||
: update-classes/new ( mixin -- )
|
||||
class-usages
|
||||
[ [ update-class ] each ]
|
||||
[ implementors [ make-generic ] each ] bi ;
|
||||
[ implementors [ remake-generic ] each ] bi ;
|
||||
|
||||
: add-mixin-instance ( class mixin -- )
|
||||
#! Note: we call update-classes on the new member, not the
|
||||
|
|
|
@ -72,6 +72,7 @@ GENERIC: definitions-changed ( assoc obj -- )
|
|||
|
||||
SYMBOL: outdated-tuples
|
||||
SYMBOL: update-tuples-hook
|
||||
SYMBOL: remake-generics-hook
|
||||
|
||||
: dependency>= ( how1 how2 -- ? )
|
||||
[
|
||||
|
@ -127,6 +128,9 @@ SYMBOL: update-tuples-hook
|
|||
: call-recompile-hook ( -- )
|
||||
to-recompile recompile-hook get call ;
|
||||
|
||||
: call-remake-generics-hook ( -- )
|
||||
remake-generics-hook get call ;
|
||||
|
||||
: call-update-tuples-hook ( -- )
|
||||
update-tuples-hook get call ;
|
||||
|
||||
|
@ -136,6 +140,7 @@ SYMBOL: update-tuples-hook
|
|||
[ delete-compiled-xref ] each ;
|
||||
|
||||
: finish-compilation-unit ( -- )
|
||||
call-remake-generics-hook
|
||||
call-recompile-hook
|
||||
call-update-tuples-hook
|
||||
unxref-forgotten-definitions
|
||||
|
@ -145,6 +150,7 @@ SYMBOL: update-tuples-hook
|
|||
[
|
||||
H{ } clone changed-definitions set
|
||||
H{ } clone changed-generics set
|
||||
H{ } clone remake-generics set
|
||||
H{ } clone outdated-tuples set
|
||||
H{ } clone new-classes set
|
||||
[ finish-compilation-unit ] [ ] cleanup
|
||||
|
@ -154,6 +160,7 @@ SYMBOL: update-tuples-hook
|
|||
[
|
||||
H{ } clone changed-definitions set
|
||||
H{ } clone changed-generics set
|
||||
H{ } clone remake-generics set
|
||||
H{ } clone forgotten-definitions set
|
||||
H{ } clone outdated-tuples set
|
||||
H{ } clone new-classes set
|
||||
|
|
|
@ -9,23 +9,32 @@ SYMBOL: inlined-dependency
|
|||
SYMBOL: flushed-dependency
|
||||
SYMBOL: called-dependency
|
||||
|
||||
<PRIVATE
|
||||
|
||||
: set-in-unit ( value key assoc -- )
|
||||
[ set-at ] [ no-compilation-unit ] if* ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
SYMBOL: changed-definitions
|
||||
|
||||
: changed-definition ( defspec -- )
|
||||
inlined-dependency swap changed-definitions get
|
||||
[ set-at ] [ no-compilation-unit ] if* ;
|
||||
inlined-dependency swap changed-definitions get set-in-unit ;
|
||||
|
||||
SYMBOL: changed-generics
|
||||
|
||||
: changed-generic ( class generic -- )
|
||||
changed-generics get
|
||||
[ set-at ] [ no-compilation-unit ] if* ;
|
||||
changed-generics get set-in-unit ;
|
||||
|
||||
SYMBOL: remake-generics
|
||||
|
||||
: remake-generic ( generic -- )
|
||||
dup remake-generics get set-in-unit ;
|
||||
|
||||
SYMBOL: new-classes
|
||||
|
||||
: new-class ( word -- )
|
||||
dup new-classes get
|
||||
[ set-at ] [ no-compilation-unit ] if* ;
|
||||
dup new-classes get set-in-unit ;
|
||||
|
||||
: new-class? ( word -- ? )
|
||||
new-classes get key? ;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
USING: accessors words kernel sequences namespaces make assocs
|
||||
hashtables definitions kernel.private classes classes.private
|
||||
classes.algebra quotations arrays vocabs effects combinators
|
||||
sets ;
|
||||
sets compiler.units ;
|
||||
IN: generic
|
||||
|
||||
! Method combination protocol
|
||||
|
@ -21,6 +21,11 @@ M: generic definition drop f ;
|
|||
[ dup "combination" word-prop perform-combination ]
|
||||
bi ;
|
||||
|
||||
[
|
||||
remake-generics get keys
|
||||
[ generic? ] filter [ make-generic ] each
|
||||
] remake-generics-hook set-global
|
||||
|
||||
: method ( class generic -- method/f )
|
||||
"methods" word-prop at ;
|
||||
|
||||
|
@ -62,7 +67,7 @@ TUPLE: check-method class generic ;
|
|||
: with-methods ( class generic quot -- )
|
||||
[ drop changed-generic ]
|
||||
[ [ "methods" word-prop ] dip call ]
|
||||
[ drop make-generic drop ]
|
||||
[ drop remake-generic drop ]
|
||||
3tri ; inline
|
||||
|
||||
: method-word-name ( class word -- string )
|
||||
|
@ -165,7 +170,7 @@ M: method-body smart-usage
|
|||
|
||||
M: sequence update-methods ( class seq -- )
|
||||
implementors [
|
||||
[ changed-generic ] [ make-generic drop ] 2bi
|
||||
[ changed-generic ] [ remake-generic drop ] 2bi
|
||||
] with each ;
|
||||
|
||||
: define-generic ( word combination -- )
|
||||
|
@ -174,7 +179,7 @@ M: sequence update-methods ( class seq -- )
|
|||
over "methods" word-prop values forget-all
|
||||
over H{ } clone "methods" set-word-prop
|
||||
dupd define-default-method
|
||||
] if make-generic ;
|
||||
] if remake-generic ;
|
||||
|
||||
M: generic subwords
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue