void factor_vm::primitive_modify_code_heap() { bool reset_inline_caches = to_boolean(ctx->pop()); bool update_existing_words = to_boolean(ctx->pop()); data_root<array> alist(ctx->pop(),this); cell count = array_capacity(alist.untagged()); if(count == 0) return; for(cell i = 0; i < count; i++) { data_root<array> pair(array_nth(alist.untagged(),i),this); data_root<word> word(array_nth(pair.untagged(),0),this); data_root<object> data(array_nth(pair.untagged(),1),this); switch(data.type()) { case QUOTATION_TYPE: jit_compile_word(word.value(),data.value(),false); break; case ARRAY_TYPE: { array *compiled_data = data.as<array>().untagged(); cell parameters = array_nth(compiled_data,0); cell literals = array_nth(compiled_data,1); cell relocation = array_nth(compiled_data,2); cell labels = array_nth(compiled_data,3); cell code = array_nth(compiled_data,4); code_block *compiled = add_code_block( code_block_optimized, code, labels, word.value(), relocation, parameters, literals); word->code = compiled; } break; default: critical_error("Expected a quotation or an array",data.value()); break; } update_word_entry_point(word.untagged()); } if(update_existing_words) update_code_heap_words(reset_inline_caches); else initialize_code_blocks(); }
void factor_vm::primitive_modify_code_heap() { gc_root<array> alist(dpop(),this); cell count = array_capacity(alist.untagged()); if(count == 0) return; cell i; for(i = 0; i < count; i++) { gc_root<array> pair(array_nth(alist.untagged(),i),this); gc_root<word> word(array_nth(pair.untagged(),0),this); gc_root<object> data(array_nth(pair.untagged(),1),this); switch(data.type()) { case QUOTATION_TYPE: jit_compile_word(word.value(),data.value(),false); break; case ARRAY_TYPE: { array *compiled_data = data.as<array>().untagged(); cell owner = array_nth(compiled_data,0); cell literals = array_nth(compiled_data,1); cell relocation = array_nth(compiled_data,2); cell labels = array_nth(compiled_data,3); cell code = array_nth(compiled_data,4); code_block *compiled = add_code_block( WORD_TYPE, code, labels, owner, relocation, literals); word->code = compiled; } break; default: critical_error("Expected a quotation or an array",data.value()); break; } update_word_xt(word.value()); } update_code_heap_words(); }