diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 0de957b785..e5d8f6231c 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -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 -\ { object object } { word } define-primitive -\ make-flushable +\ (word) { object object object } { word } define-primitive +\ (word) make-flushable \ word-xt { word } { integer integer } define-primitive \ word-xt make-flushable diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index fc071cc566..f7fb28c8f4 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -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 -- ? )) } - { "" "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 -- )) } diff --git a/core/words/words.factor b/core/words/words.factor index df5bc84ede..45e014f6be 100755 --- a/core/words/words.factor +++ b/core/words/words.factor @@ -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 ; +: ( name vocab -- word ) + 2dup [ hashcode ] bi@ bitxor >fixnum (word) ; + : gensym ( -- word ) - "( gensym )" f ; + "( gensym )" f \ gensym counter >fixnum (word) ; : define-temp ( quot effect -- word ) [ gensym dup ] 2dip define-declared ; diff --git a/vm/vm.hpp b/vm/vm.hpp index 937c043343..837b5309f2 100644 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -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_); diff --git a/vm/words.cpp b/vm/words.cpp index b6f7097f71..7660d119ad 100644 --- a/vm/words.cpp +++ b/vm/words.cpp @@ -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 vocab(vocab_,this); gc_root name(name_,this); gc_root new_word(allot(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(); } -/* ( 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(allot_word(vocab,name))); + dpush(tag(allot_word(name,vocab,hashcode))); } PRIMITIVE_FORWARD(word)