diff --git a/vm/code_blocks.cpp b/vm/code_blocks.cpp index aa14eb8cb6..9c915d2d5b 100644 --- a/vm/code_blocks.cpp +++ b/vm/code_blocks.cpp @@ -2,7 +2,7 @@ namespace factor { -cell code_block_owner(code_block* compiled) { +static cell code_block_owner(code_block* compiled) { cell owner = compiled->owner; /* Cold generic word call sites point to quotations that call the @@ -18,7 +18,7 @@ cell code_block_owner(code_block* compiled) { return wrap->object; } -cell compute_entry_point_address(cell obj) { +static cell compute_entry_point_address(cell obj) { switch (TAG(obj)) { case WORD_TYPE: return untag(obj)->entry_point; @@ -30,6 +30,13 @@ cell compute_entry_point_address(cell obj) { } } +static cell compute_here_address(cell arg, cell offset, code_block* compiled) { + fixnum n = untag_fixnum(arg); + if (n >= 0) + return compiled->entry_point() + offset + n; + return compiled->entry_point() - n; +} + cell code_block::owner_quot() const { if (!optimized_p() && TAG(owner) == WORD_TYPE) return untag(owner)->def; @@ -37,7 +44,8 @@ cell code_block::owner_quot() const { } /* If the code block is an unoptimized quotation, we can calculate the - scan offset. In all other cases -1 is returned. */ + scan offset. In all other cases -1 is returned. + Allocates memory (quot_code_offset_to_scan) */ cell code_block::scan(factor_vm* vm, cell addr) const { if (type() != code_block_unoptimized) { return tag_fixnum(-1); @@ -212,14 +220,6 @@ cell factor_vm::compute_external_address(instruction_operand op) { return ext_addr; } -cell factor_vm::compute_here_address(cell arg, cell offset, - code_block* compiled) { - fixnum n = untag_fixnum(arg); - if (n >= 0) - return compiled->entry_point() + offset + n; - return compiled->entry_point() - n; -} - struct initial_code_block_visitor { factor_vm* parent; cell literals; @@ -243,7 +243,7 @@ struct initial_code_block_visitor { case RT_ENTRY_POINT_PIC_TAIL: return parent->compute_entry_point_pic_tail_address(next_literal()); case RT_HERE: - return parent->compute_here_address( + return compute_here_address( next_literal(), op.rel.offset(), op.compiled); case RT_UNTAGGED: return untag_fixnum(next_literal()); diff --git a/vm/dispatch.cpp b/vm/dispatch.cpp index 0434bce5f4..1d6506de99 100644 --- a/vm/dispatch.cpp +++ b/vm/dispatch.cpp @@ -82,7 +82,7 @@ cell factor_vm::object_class(cell obj) { return tag_fixnum(tag); } -cell factor_vm::method_cache_hashcode(cell klass, array* array) { +static cell method_cache_hashcode(cell klass, array* array) { cell capacity = (array_capacity(array) >> 1) - 1; return ((klass >> TAG_BITS) & capacity) << 1; } diff --git a/vm/inline_cache.cpp b/vm/inline_cache.cpp index 506b2e153d..2542c186b7 100644 --- a/vm/inline_cache.cpp +++ b/vm/inline_cache.cpp @@ -16,7 +16,7 @@ void factor_vm::deallocate_inline_cache(cell return_address) { /* Figure out what kind of type check the PIC needs based on the methods it contains */ -cell factor_vm::determine_inline_cache_type(array* cache_entries) { +static cell determine_inline_cache_type(array* cache_entries) { for (cell i = 0; i < array_capacity(cache_entries); i += 2) { /* Is it a tuple layout? */ if (TAG(array_nth(cache_entries, i)) == ARRAY_TYPE) { @@ -62,7 +62,7 @@ void inline_cache_jit::compile_inline_cache(fixnum index, cell generic_word_, data_root cache_entries(cache_entries_, parent); cell inline_cache_type = - parent->determine_inline_cache_type(cache_entries.untagged()); + determine_inline_cache_type(cache_entries.untagged()); parent->update_pic_count(inline_cache_type); /* Generate machine code to determine the object's class. */ @@ -72,8 +72,7 @@ void inline_cache_jit::compile_inline_cache(fixnum index, cell generic_word_, /* Generate machine code to check, in turn, if the class is one of the cached * entries. */ - cell i; - for (i = 0; i < array_capacity(cache_entries.untagged()); i += 2) { + for (cell i = 0; i < array_capacity(cache_entries.untagged()); i += 2) { /* Class equal? */ cell klass = array_nth(cache_entries.untagged(), i); emit_check(klass); @@ -119,10 +118,6 @@ code_block* factor_vm::compile_inline_cache(fixnum index, cell generic_word_, return code; } -cell factor_vm::inline_cache_size(cell cache_entries) { - return array_capacity(untag_check(cache_entries)) / 2; -} - /* Allocates memory */ cell factor_vm::add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_) { @@ -172,7 +167,7 @@ cell factor_vm::inline_cache_miss(cell return_address_) { data_root generic_word(ctx->pop(), this); data_root object(((cell*)ctx->datastack)[-index], this); - cell pic_size = inline_cache_size(cache_entries.value()); + cell pic_size = array_capacity(cache_entries.untagged()) / 2; update_pic_transitions(pic_size); diff --git a/vm/quotations.cpp b/vm/quotations.cpp index 36fa01fbd3..07ceb4d823 100644 --- a/vm/quotations.cpp +++ b/vm/quotations.cpp @@ -104,7 +104,7 @@ bool quotation_jit::stack_frame_p() { return true; } -bool quotation_jit::trivial_quotation_p(array* elements) { +static bool trivial_quotation_p(array* elements) { return array_capacity(elements) == 1 && TAG(array_nth(elements, 0)) == WORD_TYPE; } diff --git a/vm/quotations.hpp b/vm/quotations.hpp index 0f794be1e4..7177279dd6 100644 --- a/vm/quotations.hpp +++ b/vm/quotations.hpp @@ -14,7 +14,6 @@ struct quotation_jit : public jit { void init_quotation(cell quot); void emit_mega_cache_lookup(cell methods, fixnum index, cell cache); bool primitive_call_p(cell i, cell length); - bool trivial_quotation_p(array* elements); void emit_quotation(cell quot); void emit_epilog(bool needed); bool fast_if_p(cell i, cell length); diff --git a/vm/vm.hpp b/vm/vm.hpp index 1f186ff6b3..1245bd7683 100644 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -566,7 +566,6 @@ struct factor_vm { code_block* compiled, array* parameters, cell index); - cell compute_here_address(cell arg, cell offset, code_block* compiled); void initialize_code_block(code_block* compiled, cell literals); void initialize_code_block(code_block* compiled); void fixup_labels(array* labels, code_block* compiled); @@ -664,7 +663,6 @@ struct factor_vm { cell lookup_method(cell obj, cell methods); void primitive_lookup_method(); cell object_class(cell obj); - cell method_cache_hashcode(cell klass, array* array); void update_method_cache(cell cache, cell klass, cell method); void primitive_mega_cache_miss(); void primitive_reset_dispatch_stats(); @@ -673,12 +671,10 @@ struct factor_vm { // inline cache void init_inline_caching(int max_size); void deallocate_inline_cache(cell return_address); - cell determine_inline_cache_type(array* cache_entries); void update_pic_count(cell type); code_block* compile_inline_cache(fixnum index, cell generic_word_, cell methods_, cell cache_entries_, bool tail_call_p); - cell inline_cache_size(cell cache_entries); cell add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_); void update_pic_transitions(cell pic_size); cell inline_cache_miss(cell return_address);