-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);
- cell frame_size = untag_fixnum(array_nth(compiled_data,5));
-
- code_block *compiled = add_code_block(
- code_block_optimized,
- code,
- labels,
- word.value(),
- relocation,
- parameters,
- literals,
- frame_size);
-
- word->entry_point = compiled->entry_point();
- }
- break;
- default:
- critical_error("Expected a quotation or an array",data.value());
- break;
- }
- }
-
- if(update_existing_words)
- update_code_heap_words(reset_inline_caches);
- else
- initialize_code_blocks();
+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);
+ cell frame_size = untag_fixnum(array_nth(compiled_data, 5));
+
+ code_block* compiled =
+ add_code_block(code_block_optimized, code, labels, word.value(),
+ relocation, parameters, literals, frame_size);
+
+ word->entry_point = compiled->entry_point();
+ } break;
+ default:
+ critical_error("Expected a quotation or an array", data.value());
+ break;
+ }
+ }
+
+ if (update_existing_words)
+ update_code_heap_words(reset_inline_caches);
+ else
+ initialize_code_blocks();