VM: refactors the prepare_boot_image method

easier to read if the methods compile_all_words and
initialize_all_quotations which are only used once are "inlined"
db4
Björn Lindqvist 2015-12-04 13:57:57 +01:00
parent bf8fe25271
commit d911bc45fd
4 changed files with 22 additions and 34 deletions

View File

@ -95,9 +95,29 @@ void factor_vm::init_parameters_from_args(vm_parameters* p, int argc,
void factor_vm::prepare_boot_image() {
std::cout << "*** Stage 2 early init... " << std::flush;
compile_all_words();
// Compile all words.
data_root<array> words(instances(WORD_TYPE), this);
cell n_words = array_capacity(words.untagged());
for (cell i = 0; i < n_words; i++) {
data_root<word> word(array_nth(words.untagged(), i), this);
FACTOR_ASSERT(!word->entry_point);
jit_compile_word(word.value(), word->def, false);
}
update_code_heap_words(true);
initialize_all_quotations();
// Initialize all quotations
data_root<array> quotations(instances(QUOTATION_TYPE), this);
cell n_quots = array_capacity(quotations.untagged());
for (cell i = 0; i < n_quots; i++) {
data_root<quotation> quot(array_nth(quotations.untagged(), i), this);
if (!quot->entry_point)
quot->entry_point = lazy_jit_compile_entry_point();
}
special_objects[OBJ_STAGE2] = true_object;
std::cout << "done" << std::endl;

View File

@ -364,17 +364,4 @@ void factor_vm::primitive_quotation_compiled_p() {
ctx->push(tag_boolean(quotation_compiled_p(quot)));
}
/* Allocates memory */
void factor_vm::initialize_all_quotations() {
cell all_quots = instances(QUOTATION_TYPE);
data_root<array> quotations(all_quots, this);
cell length = array_capacity(quotations.untagged());
for (cell i = 0; i < length; i++) {
data_root<quotation> quot(array_nth(quotations.untagged(), i), this);
if (!quot->entry_point)
quot.untagged()->entry_point = lazy_jit_compile_entry_point();
}
}
}

View File

@ -461,8 +461,6 @@ struct factor_vm {
void primitive_word_optimized_p();
void primitive_wrapper();
void jit_compile_word(cell word_, cell def_, bool relocating);
cell find_all_words();
void compile_all_words();
// math
void primitive_bignum_to_fixnum();
@ -683,7 +681,6 @@ struct factor_vm {
cell lazy_jit_compile(cell quot);
bool quotation_compiled_p(quotation* quot);
void primitive_quotation_compiled_p();
void initialize_all_quotations();
// dispatch
cell search_lookup_alist(cell table, cell klass);

View File

@ -24,22 +24,6 @@ void factor_vm::jit_compile_word(cell word_, cell def_, bool relocating) {
jit_compile_quotation(word->pic_tail_def, relocating);
}
/* Allocates memory */
cell factor_vm::find_all_words() { return instances(WORD_TYPE); }
/* Allocates memory */
void factor_vm::compile_all_words() {
data_root<array> words(find_all_words(), this);
cell length = array_capacity(words.untagged());
for (cell i = 0; i < length; i++) {
data_root<word> word(array_nth(words.untagged(), i), this);
if (!word->entry_point || !word->code()->optimized_p())
jit_compile_word(word.value(), word->def, false);
}
}
/* Allocates memory */
word* factor_vm::allot_word(cell name_, cell vocab_, cell hashcode_) {
data_root<object> vocab(vocab_, this);