diff --git a/vm/code_heap.cpp b/vm/code_heap.cpp index a4561391af..c7f69cc545 100644 --- a/vm/code_heap.cpp +++ b/vm/code_heap.cpp @@ -92,7 +92,6 @@ code_block* code_heap::code_block_for_address(cell address) { cell code_heap::frame_predecessor(cell frame_top) { cell addr = *(cell*)frame_top; FACTOR_ASSERT(seg->in_segment_p(addr)); - //FACTOR_ASSERT(addr != 0); code_block* owner = code_block_for_address(addr); cell frame_size = owner->stack_frame_size_for_address(addr); return frame_top + frame_size; @@ -111,8 +110,8 @@ void code_heap::initialize_all_blocks_set() { } /* Update pointers to words referenced from all code blocks. -Only needed after redefining an existing word. -If generic words were redefined, inline caches need to be reset. */ + Only needed after redefining an existing word. + If generic words were redefined, inline caches need to be reset. */ void factor_vm::update_code_heap_words(bool reset_inline_caches) { auto word_updater = [&](code_block* block, cell size) { update_word_references(block, reset_inline_caches); diff --git a/vm/contexts.cpp b/vm/contexts.cpp index c1cbe7539a..3df7227b4c 100644 --- a/vm/contexts.cpp +++ b/vm/contexts.cpp @@ -2,16 +2,15 @@ namespace factor { -context::context(cell datastack_size, cell retainstack_size, - cell callstack_size) +context::context(cell ds_size, cell rs_size, cell cs_size) : callstack_top(0), callstack_bottom(0), datastack(0), retainstack(0), callstack_save(0), - datastack_seg(new segment(datastack_size, false)), - retainstack_seg(new segment(retainstack_size, false)), - callstack_seg(new segment(callstack_size, false)) { + datastack_seg(new segment(ds_size, false)), + retainstack_seg(new segment(rs_size, false)), + callstack_seg(new segment(cs_size, false)) { reset(); } diff --git a/vm/contexts.hpp b/vm/contexts.hpp index f86e830de7..6bf115b6a4 100644 --- a/vm/contexts.hpp +++ b/vm/contexts.hpp @@ -1,8 +1,7 @@ namespace factor { -// Context object count and identifiers must be kept in sync with: -// core/kernel/kernel.factor - +/* Context object count and identifiers must be kept in sync with: + core/kernel/kernel.factor */ static const cell context_object_count = 4; enum context_object { @@ -20,7 +19,7 @@ static const cell stack_reserved = 16384; struct context { - // First 4 fields accessed directly by compiler. See basis/vm/vm.factor + /* First 5 fields accessed directly by compiler. See basis/vm/vm.factor */ /* Factor callstack pointers */ cell callstack_top; @@ -43,7 +42,7 @@ struct context { set-context-object primitives */ cell context_objects[context_object_count]; - context(cell datastack_size, cell retainstack_size, cell callstack_size); + context(cell ds_size, cell rs_size, cell cs_size); ~context(); void reset_datastack(); diff --git a/vm/free_list.cpp b/vm/free_list.cpp index 8bdff892d1..78d66920a6 100644 --- a/vm/free_list.cpp +++ b/vm/free_list.cpp @@ -33,8 +33,9 @@ void free_list::add_to_free_list(free_heap_block* block) { free_heap_block* free_list::find_free_block(cell size) { /* Check small free lists */ - if (size / data_alignment < free_list_count) { - std::vector& blocks = small_blocks[size / data_alignment]; + cell bucket = size / data_alignment; + if (bucket < free_list_count) { + std::vector& blocks = small_blocks[bucket]; if (blocks.size() == 0) { /* Round up to a multiple of 'size' */ cell large_block_size = ((allocation_page_size + size - 1) / size) * size; diff --git a/vm/free_list.hpp b/vm/free_list.hpp index ab7c17e119..2d9c9f179a 100644 --- a/vm/free_list.hpp +++ b/vm/free_list.hpp @@ -109,8 +109,8 @@ template Block* free_list_allocator::allot(cell size) { if (block) { block = free_blocks.split_free_block(block, size); return (Block*)block; - } else - return NULL; + } + return NULL; } template void free_list_allocator::free(Block* block) { diff --git a/vm/jit.cpp b/vm/jit.cpp index 77340f2fd3..c70ddd4407 100644 --- a/vm/jit.cpp +++ b/vm/jit.cpp @@ -3,11 +3,12 @@ namespace factor { /* Simple code generator used by: -- quotation compiler (quotations.cpp), -- megamorphic caches (dispatch.cpp), -- polymorphic inline caches (inline_cache.cpp) */ + - quotation compiler (quotations.cpp), + - megamorphic caches (dispatch.cpp), + - polymorphic inline caches (inline_cache.cpp) */ -/* Allocates memory (`code` and `relocation` initializers create growable_byte_array) */ +/* Allocates memory (`code` and `relocation` initializers create + growable_byte_array) */ jit::jit(code_block_type type, cell owner, factor_vm* vm) : type(type), owner(owner, vm), @@ -105,8 +106,8 @@ bool jit::emit_subprimitive(cell word_, bool tail_call_p, bool stack_frame_p) { } /* Facility to convert compiled code offsets to quotation offsets. -Call jit_compute_offset() with the compiled code offset, then emit -code, and at the end jit->position is the quotation position. */ + Call jit_compute_offset() with the compiled code offset, then emit + code, and at the end jit->position is the quotation position. */ void jit::compute_position(cell offset_) { computing_offset_p = true; position = 0; diff --git a/vm/quotations.hpp b/vm/quotations.hpp index 4f3f11c6a1..a5a5f71f68 100644 --- a/vm/quotations.hpp +++ b/vm/quotations.hpp @@ -14,10 +14,8 @@ struct quotation_jit : public jit { cell nth(cell index); void init_quotation(cell quot); - void emit_mega_cache_lookup(cell methods, fixnum index, cell cache); + bool primitive_call_p(cell i, cell length); - void emit_quotation(cell quot); - void emit_epilog(bool needed); bool fast_if_p(cell i, cell length); bool fast_dip_p(cell i, cell length); bool fast_2dip_p(cell i, cell length); @@ -25,6 +23,11 @@ struct quotation_jit : public jit { bool mega_lookup_p(cell i, cell length); bool declare_p(cell i, cell length); bool special_subprimitive_p(cell obj); + + void emit_mega_cache_lookup(cell methods, fixnum index, cell cache); + void emit_quotation(cell quot); + void emit_epilog(bool needed); + cell word_stack_frame_size(cell obj); bool stack_frame_p(); void iterate_quotation(); diff --git a/vm/slot_visitor.hpp b/vm/slot_visitor.hpp index 142b607b9a..c9753029b7 100644 --- a/vm/slot_visitor.hpp +++ b/vm/slot_visitor.hpp @@ -178,19 +178,6 @@ void slot_visitor::visit_object_array(cell* start, cell* end) { visit_handle(start++); } -template -void slot_visitor::visit_partial_objects(cell start, - cell card_start, - cell card_end) { - cell *scan_start = (cell*)start + 1; - cell *scan_end = scan_start + ((object*)start)->slot_count(); - - scan_start = std::max(scan_start, (cell*)card_start); - scan_end = std::min(scan_end, (cell*)card_end); - - visit_object_array(scan_start, scan_end); -} - template void slot_visitor::visit_slots(object* obj) { if (obj->type() == CALLSTACK_TYPE) visit_callstack_object((callstack*)obj); @@ -533,6 +520,19 @@ void slot_visitor::visit_instruction_operands(code_block* block, block->each_instruction_operand(visit_func); } +template +void slot_visitor::visit_partial_objects(cell start, + cell card_start, + cell card_end) { + cell *scan_start = (cell*)start + 1; + cell *scan_end = scan_start + ((object*)start)->slot_count(); + + scan_start = std::max(scan_start, (cell*)card_start); + scan_end = std::min(scan_end, (cell*)card_end); + + visit_object_array(scan_start, scan_end); +} + template template cell slot_visitor::visit_card(SourceGeneration* gen,