Fix amazing performance regression
parent
1e538ccd03
commit
3a374f2045
|
@ -12,8 +12,6 @@ $nl
|
||||||
{ $subsection forget }
|
{ $subsection forget }
|
||||||
"Definitions can answer a sequence of definitions they directly depend on:"
|
"Definitions can answer a sequence of definitions they directly depend on:"
|
||||||
{ $subsection uses }
|
{ $subsection uses }
|
||||||
"When a definition is changed, all definitions which depend on it are notified via a hook:"
|
|
||||||
{ $subsection redefined* }
|
|
||||||
"Definitions must implement a few operations used for printing them in source form:"
|
"Definitions must implement a few operations used for printing them in source form:"
|
||||||
{ $subsection synopsis* }
|
{ $subsection synopsis* }
|
||||||
{ $subsection definer }
|
{ $subsection definer }
|
||||||
|
@ -108,11 +106,6 @@ HELP: usage
|
||||||
{ $description "Outputs a sequence of definitions that directly call the given definition." }
|
{ $description "Outputs a sequence of definitions that directly call the given definition." }
|
||||||
{ $notes "The sequence might include the definition itself, if it is a recursive word." } ;
|
{ $notes "The sequence might include the definition itself, if it is a recursive word." } ;
|
||||||
|
|
||||||
HELP: redefined*
|
|
||||||
{ $values { "defspec" "a definition specifier" } }
|
|
||||||
{ $contract "Updates the definition to cope with a callee being redefined." }
|
|
||||||
$low-level-note ;
|
|
||||||
|
|
||||||
HELP: unxref
|
HELP: unxref
|
||||||
{ $values { "defspec" "a definition specifier" } }
|
{ $values { "defspec" "a definition specifier" } }
|
||||||
{ $description "Remove edges leaving the vertex which represents the definition from the " { $link crossref } " graph." }
|
{ $description "Remove edges leaving the vertex which represents the definition from the " { $link crossref } " graph." }
|
||||||
|
|
|
@ -42,13 +42,6 @@ M: object uses drop f ;
|
||||||
|
|
||||||
: usage ( defspec -- seq ) \ f or crossref get at keys ;
|
: usage ( defspec -- seq ) \ f or crossref get at keys ;
|
||||||
|
|
||||||
GENERIC: redefined* ( defspec -- )
|
|
||||||
|
|
||||||
M: object redefined* drop ;
|
|
||||||
|
|
||||||
: redefined ( defspec -- )
|
|
||||||
[ crossref get at ] closure [ drop redefined* ] assoc-each ;
|
|
||||||
|
|
||||||
: unxref ( defspec -- )
|
: unxref ( defspec -- )
|
||||||
dup uses crossref get remove-vertex ;
|
dup uses crossref get remove-vertex ;
|
||||||
|
|
||||||
|
|
|
@ -121,8 +121,28 @@ SYMBOL: +called+
|
||||||
compiled-usage [ nip +inlined+ eq? ] assoc-subset update
|
compiled-usage [ nip +inlined+ eq? ] assoc-subset update
|
||||||
] with each keys ;
|
] with each keys ;
|
||||||
|
|
||||||
M: word redefined* ( word -- )
|
<PRIVATE
|
||||||
{ "inferred-effect" "no-effect" } reset-props ;
|
|
||||||
|
SYMBOL: visited
|
||||||
|
|
||||||
|
: reset-on-redefine { "inferred-effect" "no-effect" } ; inline
|
||||||
|
|
||||||
|
: (redefined) ( word -- )
|
||||||
|
dup visited get key? [ drop ] [
|
||||||
|
[ reset-on-redefine reset-props ]
|
||||||
|
[ dup visited get set-at ]
|
||||||
|
[
|
||||||
|
crossref get at keys [ word? ] subset [
|
||||||
|
reset-on-redefine [ word-prop ] with contains?
|
||||||
|
] subset
|
||||||
|
[ (redefined) ] each
|
||||||
|
] tri
|
||||||
|
] if ;
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
|
: redefined ( word -- )
|
||||||
|
H{ } clone visited [ (redefined) ] with-variable ;
|
||||||
|
|
||||||
SYMBOL: changed-words
|
SYMBOL: changed-words
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ F_WORD *allot_word(CELL vocab, CELL name)
|
||||||
UNREGISTER_ROOT(name);
|
UNREGISTER_ROOT(name);
|
||||||
UNREGISTER_ROOT(vocab);
|
UNREGISTER_ROOT(vocab);
|
||||||
|
|
||||||
word->hashcode = tag_fixnum(rand());
|
word->hashcode = tag_fixnum((rand() << 16) ^ rand());
|
||||||
word->vocabulary = vocab;
|
word->vocabulary = vocab;
|
||||||
word->name = name;
|
word->name = name;
|
||||||
word->def = userenv[UNDEFINED_ENV];
|
word->def = userenv[UNDEFINED_ENV];
|
||||||
|
|
Loading…
Reference in New Issue