diff --git a/vm/compaction.cpp b/vm/compaction.cpp index 3cdf005e03..7a062998a7 100644 --- a/vm/compaction.cpp +++ b/vm/compaction.cpp @@ -155,6 +155,34 @@ struct code_block_compaction_updater { } }; +/* After a compaction, invalidate any code heap roots which are not +marked, and also slide the valid roots up so that call sites can be updated +correctly in case an inline cache compilation triggered compaction. */ +void factor_vm::update_code_roots_for_compaction() +{ + std::vector::const_iterator iter = code_roots.begin(); + std::vector::const_iterator end = code_roots.end(); + + mark_bits *state = &code->allocator->state; + + for(; iter < end; iter++) + { + code_root *root = *iter; + code_block *block = (code_block *)(root->value & -data_alignment); + + /* Offset of return address within 16-byte allocation line */ + cell offset = root->value - (cell)block; + + if(root->valid && state->marked_p(block)) + { + block = state->forward_block(block); + root->value = (cell)block + offset; + } + else + root->valid = false; + } +} + /* Compact data and code heaps */ void factor_vm::collect_compact_impl(bool trace_contexts_p) { diff --git a/vm/full_collector.cpp b/vm/full_collector.cpp index 7ee4f41413..4de2814f1d 100644 --- a/vm/full_collector.cpp +++ b/vm/full_collector.cpp @@ -57,34 +57,6 @@ void factor_vm::update_code_roots_for_sweep() } } -/* After a compaction, invalidate any code heap roots which are not -marked as above, and also slide the valid roots up so that call sites -can be updated correctly. */ -void factor_vm::update_code_roots_for_compaction() -{ - std::vector::const_iterator iter = code_roots.begin(); - std::vector::const_iterator end = code_roots.end(); - - mark_bits *state = &code->allocator->state; - - for(; iter < end; iter++) - { - code_root *root = *iter; - code_block *block = (code_block *)(root->value & -data_alignment); - - /* Offset of return address within 16-byte allocation line */ - cell offset = root->value - (cell)block; - - if(root->valid && state->marked_p(block)) - { - block = state->forward_block(block); - root->value = (cell)block + offset; - } - else - root->valid = false; - } -} - void factor_vm::collect_mark_impl(bool trace_contexts_p) { full_collector collector(this); diff --git a/vm/words.cpp b/vm/words.cpp index ec5db15095..4b3dad71df 100644 --- a/vm/words.cpp +++ b/vm/words.cpp @@ -34,7 +34,6 @@ void factor_vm::compile_all_words() jit_compile_word(word.value(),word->def,false); update_word_xt(word.untagged()); - } }