6 word *factorvm::allot_word(cell vocab_, cell name_)
8 gc_root<object> vocab(vocab_,this);
9 gc_root<object> name(name_,this);
11 gc_root<word> new_word(allot<word>(sizeof(word)),this);
13 new_word->hashcode = tag_fixnum((rand() << 16) ^ rand());
14 new_word->vocabulary = vocab.value();
15 new_word->name = name.value();
16 new_word->def = userenv[UNDEFINED_ENV];
18 new_word->counter = tag_fixnum(0);
19 new_word->pic_def = F;
20 new_word->pic_tail_def = F;
21 new_word->subprimitive = F;
22 new_word->profiling = NULL;
23 new_word->code = NULL;
25 jit_compile_word(new_word.value(),new_word->def,true);
26 update_word_xt(new_word.value());
29 relocate_code_block(new_word->profiling);
31 return new_word.untagged();
34 /* <word> ( name vocabulary -- word ) */
35 inline void factorvm::vmprim_word()
39 dpush(tag<word>(allot_word(vocab,name)));
44 PRIMITIVE_GETVM()->vmprim_word();
47 /* word-xt ( word -- start end ) */
48 inline void factorvm::vmprim_word_xt()
50 word *w = untag_check<word>(dpop());
51 code_block *code = (profiling_p ? w->profiling : w->code);
52 dpush(allot_cell((cell)code->xt()));
53 dpush(allot_cell((cell)code + code->size));
58 PRIMITIVE_GETVM()->vmprim_word_xt();
61 /* Allocates memory */
62 void factorvm::update_word_xt(cell w_)
64 gc_root<word> w(w_,this);
69 w->profiling = compile_profiling_stub(w.value());
71 w->xt = w->profiling->xt();
74 w->xt = w->code->xt();
77 inline void factorvm::vmprim_optimized_p()
79 drepl(tag_boolean(word_optimized_p(untag_check<word>(dpeek()))));
82 PRIMITIVE(optimized_p)
84 PRIMITIVE_GETVM()->vmprim_optimized_p();
87 inline void factorvm::vmprim_wrapper()
89 wrapper *new_wrapper = allot<wrapper>(sizeof(wrapper));
90 new_wrapper->object = dpeek();
91 drepl(tag<wrapper>(new_wrapper));
96 PRIMITIVE_GETVM()->vmprim_wrapper();