Word hashcodes are now computed from the word's name/vocabulary, removing a source of non-determinism
parent
d3aa0a538b
commit
ab8c6e9978
|
@ -1,18 +1,18 @@
|
|||
! Copyright (C) 2004, 2009 Slava Pestov, Daniel Ehrenberg.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: fry accessors alien alien.accessors arrays byte-arrays classes
|
||||
continuations.private effects generic hashtables
|
||||
USING: fry accessors alien alien.accessors arrays byte-arrays
|
||||
classes continuations.private effects generic hashtables
|
||||
hashtables.private io io.backend io.files io.files.private
|
||||
io.streams.c kernel kernel.private math math.private
|
||||
math.parser.private memory memory.private namespaces
|
||||
namespaces.private parser quotations quotations.private sbufs
|
||||
sbufs.private sequences sequences.private slots.private strings
|
||||
strings.private system threads.private classes.tuple
|
||||
classes.tuple.private vectors vectors.private words definitions assocs
|
||||
summary compiler.units system.private combinators
|
||||
combinators.short-circuit locals locals.backend locals.types
|
||||
combinators.private stack-checker.values
|
||||
generic.single generic.single.private
|
||||
classes.tuple.private vectors vectors.private words
|
||||
words.private definitions assocs summary compiler.units
|
||||
system.private combinators combinators.short-circuit locals
|
||||
locals.backend locals.types combinators.private
|
||||
stack-checker.values generic.single generic.single.private
|
||||
alien.libraries
|
||||
stack-checker.alien
|
||||
stack-checker.state
|
||||
|
@ -482,8 +482,8 @@ M: bad-executable summary
|
|||
\ float-u>= { float float } { object } define-primitive
|
||||
\ float-u>= make-foldable
|
||||
|
||||
\ <word> { object object } { word } define-primitive
|
||||
\ <word> make-flushable
|
||||
\ (word) { object object object } { word } define-primitive
|
||||
\ (word) make-flushable
|
||||
|
||||
\ word-xt { word } { integer integer } define-primitive
|
||||
\ word-xt make-flushable
|
||||
|
|
|
@ -101,6 +101,7 @@ bootstrapping? on
|
|||
"threads.private"
|
||||
"tools.profiler.private"
|
||||
"words"
|
||||
"words.private"
|
||||
"vectors"
|
||||
"vectors.private"
|
||||
"vm"
|
||||
|
@ -414,7 +415,7 @@ tuple
|
|||
{ "float-u<=" "math.private" (( x y -- ? )) }
|
||||
{ "float-u>" "math.private" (( x y -- ? )) }
|
||||
{ "float-u>=" "math.private" (( x y -- ? )) }
|
||||
{ "<word>" "words" (( name vocab -- word )) }
|
||||
{ "(word)" "words.private" (( name vocab -- word )) }
|
||||
{ "word-xt" "words" (( word -- start end )) }
|
||||
{ "getenv" "kernel.private" (( n -- obj )) }
|
||||
{ "setenv" "kernel.private" (( obj n -- )) }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
USING: accessors arrays definitions graphs kernel
|
||||
kernel.private slots.private math namespaces sequences
|
||||
strings vectors sbufs quotations assocs hashtables sorting vocabs
|
||||
math.order sets ;
|
||||
math.order sets words.private ;
|
||||
IN: words
|
||||
|
||||
: word ( -- word ) \ word get-global ;
|
||||
|
@ -169,8 +169,11 @@ M: word reset-word
|
|||
} reset-props
|
||||
] tri ;
|
||||
|
||||
: <word> ( name vocab -- word )
|
||||
2dup [ hashcode ] bi@ bitxor >fixnum (word) ;
|
||||
|
||||
: gensym ( -- word )
|
||||
"( gensym )" f <word> ;
|
||||
"( gensym )" f \ gensym counter >fixnum (word) ;
|
||||
|
||||
: define-temp ( quot effect -- word )
|
||||
[ gensym dup ] 2dip define-declared ;
|
||||
|
|
|
@ -269,7 +269,7 @@ struct factor_vm : factor_vm_data {
|
|||
inline void primitive_tuple_boa();
|
||||
|
||||
//words
|
||||
word *allot_word(cell vocab_, cell name_);
|
||||
word *allot_word(cell name_, cell vocab_, cell hashcode_);
|
||||
inline void primitive_word();
|
||||
inline void primitive_word_xt();
|
||||
void update_word_xt(cell w_);
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
namespace factor
|
||||
{
|
||||
|
||||
word *factor_vm::allot_word(cell vocab_, cell name_)
|
||||
word *factor_vm::allot_word(cell name_, cell vocab_, cell hashcode_)
|
||||
{
|
||||
gc_root<object> vocab(vocab_,this);
|
||||
gc_root<object> name(name_,this);
|
||||
|
||||
gc_root<word> new_word(allot<word>(sizeof(word)),this);
|
||||
|
||||
new_word->hashcode = tag_fixnum((rand() << 16) ^ rand());
|
||||
new_word->hashcode = hashcode_;
|
||||
new_word->vocabulary = vocab.value();
|
||||
new_word->name = name.value();
|
||||
new_word->def = userenv[UNDEFINED_ENV];
|
||||
|
@ -31,12 +31,13 @@ word *factor_vm::allot_word(cell vocab_, cell name_)
|
|||
return new_word.untagged();
|
||||
}
|
||||
|
||||
/* <word> ( name vocabulary -- word ) */
|
||||
/* (word) ( name vocabulary hashcode -- word ) */
|
||||
inline void factor_vm::primitive_word()
|
||||
{
|
||||
cell hashcode = dpop();
|
||||
cell vocab = dpop();
|
||||
cell name = dpop();
|
||||
dpush(tag<word>(allot_word(vocab,name)));
|
||||
dpush(tag<word>(allot_word(name,vocab,hashcode)));
|
||||
}
|
||||
|
||||
PRIMITIVE_FORWARD(word)
|
||||
|
|
Loading…
Reference in New Issue