diff --git a/vm/arrays.hpp b/vm/arrays.hpp index 772a0afb3f..8db65414e5 100644 --- a/vm/arrays.hpp +++ b/vm/arrays.hpp @@ -18,6 +18,7 @@ struct growable_array { cell count; data_root elements; + /* Allocates memory */ growable_array(factor_vm* parent, cell capacity = 10) : count(0), elements(parent->allot_array(capacity, false_object), parent) {} diff --git a/vm/byte_arrays.hpp b/vm/byte_arrays.hpp index e3cbf520ce..44becd7e93 100644 --- a/vm/byte_arrays.hpp +++ b/vm/byte_arrays.hpp @@ -4,6 +4,7 @@ struct growable_byte_array { cell count; data_root elements; + /* Allocates memory */ growable_byte_array(factor_vm* parent, cell capacity = 40) : count(0), elements(parent->allot_byte_array(capacity), parent) {} diff --git a/vm/callstack.cpp b/vm/callstack.cpp index fb146108ab..edcf842e4d 100644 --- a/vm/callstack.cpp +++ b/vm/callstack.cpp @@ -2,6 +2,7 @@ namespace factor { +/* Allocates memory (allot) */ callstack* factor_vm::allot_callstack(cell size) { callstack* stack = allot(callstack_object_size(size)); stack->length = tag_fixnum(size); @@ -27,6 +28,7 @@ void* factor_vm::second_from_top_stack_frame(context* ctx) { return frame_top; } +/* Allocates memory (allot_callstack) */ cell factor_vm::capture_callstack(context* ctx) { void* top = second_from_top_stack_frame(ctx); void* bottom = ctx->callstack_bottom; @@ -38,8 +40,10 @@ cell factor_vm::capture_callstack(context* ctx) { return tag(stack); } +/* Allocates memory (capture_callstack) */ void factor_vm::primitive_callstack() { ctx->push(capture_callstack(ctx)); } +/* Allocates memory (capture_callstack) */ void factor_vm::primitive_callstack_for() { context* other_ctx = (context*)pinned_alien_offset(ctx->peek()); ctx->replace(capture_callstack(other_ctx)); @@ -57,9 +61,12 @@ struct stack_frame_accumulator { factor_vm* parent; growable_array frames; + /* Allocates memory (frames is a growable_array, constructor allocates) */ explicit stack_frame_accumulator(factor_vm* parent) : parent(parent), frames(parent) {} + + /* Allocates memory (frames.add()) */ void operator()(void* frame_top, cell frame_size, code_block* owner, void* addr) { data_root executing_quot(owner->owner_quot(), parent); @@ -109,6 +116,7 @@ void factor_vm::primitive_innermost_stack_frame_scan() { ctx->replace(code->code_block_for_address((cell)addr)->scan(this, addr)); } +/* Allocates memory (jit_compile_quot) */ void factor_vm::primitive_set_innermost_stack_frame_quot() { data_root stack(ctx->pop(), this); data_root quot(ctx->pop(), this); @@ -125,6 +133,7 @@ void factor_vm::primitive_set_innermost_stack_frame_quot() { set_frame_return_address(inner, (char*)quot->entry_point + offset); } +/* Allocates memory (allot_alien) */ void factor_vm::primitive_callstack_bounds() { ctx->push(allot_alien((void*)ctx->callstack_seg->start)); ctx->push(allot_alien((void*)ctx->callstack_seg->end)); diff --git a/vm/callstack.hpp b/vm/callstack.hpp index 52f5c59d06..2e8b6b7c4c 100644 --- a/vm/callstack.hpp +++ b/vm/callstack.hpp @@ -6,6 +6,7 @@ inline static cell callstack_object_size(cell size) { /* This is a little tricky. The iterator may allocate memory, so we keep the callstack in a GC root and use relative offsets */ +/* Allocates memory */ template inline void factor_vm::iterate_callstack_object(callstack* stack_, Iterator& iterator, @@ -29,6 +30,7 @@ inline void factor_vm::iterate_callstack_object(callstack* stack_, } } +/* Allocates memory */ template inline void factor_vm::iterate_callstack_object(callstack* stack, Iterator& iterator) { @@ -36,6 +38,7 @@ inline void factor_vm::iterate_callstack_object(callstack* stack, iterate_callstack_object(stack, iterator, none); } +/* Allocates memory */ template inline void factor_vm::iterate_callstack(context* ctx, Iterator& iterator, Fixup& fixup) { @@ -66,6 +69,7 @@ inline void factor_vm::iterate_callstack(context* ctx, Iterator& iterator, } } +/* Allocates memory */ template inline void factor_vm::iterate_callstack(context* ctx, Iterator& iterator) { no_fixup none; diff --git a/vm/dispatch.cpp b/vm/dispatch.cpp index be3ae38774..1c522bfb68 100644 --- a/vm/dispatch.cpp +++ b/vm/dispatch.cpp @@ -126,6 +126,7 @@ void factor_vm::primitive_dispatch_stats() { ctx->push(tag(byte_array_from_value(&dispatch_stats))); } +/* Allocates memory */ void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index, cell cache_) { data_root methods(methods_, parent); diff --git a/vm/factor.cpp b/vm/factor.cpp index fccdeb17c3..1343114973 100644 --- a/vm/factor.cpp +++ b/vm/factor.cpp @@ -167,7 +167,7 @@ void factor_vm::init_factor(vm_parameters* p) { } -/* May allocate memory */ +/* Allocates memory */ void factor_vm::pass_args_to_factor(int argc, vm_char** argv) { growable_array args(this); diff --git a/vm/gc.cpp b/vm/gc.cpp index 200842e781..6dce41083d 100644 --- a/vm/gc.cpp +++ b/vm/gc.cpp @@ -274,7 +274,7 @@ void factor_vm::primitive_enable_gc_events() { gc_events = new std::vector(); } -/* Allocates memory */ +/* Allocates memory (byte_array_from_value, result.add) */ void factor_vm::primitive_disable_gc_events() { if (gc_events) { growable_array result(this); diff --git a/vm/inline_cache.cpp b/vm/inline_cache.cpp index d5e2159645..eaef447204 100644 --- a/vm/inline_cache.cpp +++ b/vm/inline_cache.cpp @@ -52,6 +52,7 @@ struct inline_cache_jit : public jit { cell cache_entries_, bool tail_call_p); }; +/* Allocates memory */ void inline_cache_jit::emit_check(cell klass) { cell code_template; if (TAG(klass) == FIXNUM_TYPE) @@ -64,6 +65,7 @@ void inline_cache_jit::emit_check(cell klass) { /* index: 0 = top of stack, 1 = item underneath, etc cache_entries: array of class/method pairs */ +/* Allocates memory */ void inline_cache_jit::compile_inline_cache(fixnum index, cell generic_word_, cell methods_, cell cache_entries_, bool tail_call_p) { @@ -113,6 +115,7 @@ void inline_cache_jit::compile_inline_cache(fixnum index, cell generic_word_, true); /* stack_frame_p */ } +/* Allocates memory */ code_block* factor_vm::compile_inline_cache(fixnum index, cell generic_word_, cell methods_, cell cache_entries_, bool tail_call_p) { @@ -167,6 +170,7 @@ void factor_vm::update_pic_transitions(cell pic_size) { compaction; also, the block containing the return address may now be dead. Use a code_root to take care of the details. */ +/* Allocates memory */ void* factor_vm::inline_cache_miss(cell return_address_) { code_root return_address(return_address_, this); check_code_pointer(return_address.value); @@ -224,6 +228,7 @@ void* factor_vm::inline_cache_miss(cell return_address_) { return xt; } +/* Allocates memory */ VM_C_API void* inline_cache_miss(cell return_address, factor_vm* parent) { return parent->inline_cache_miss(return_address); } diff --git a/vm/jit.cpp b/vm/jit.cpp index a377af536c..e39164f308 100644 --- a/vm/jit.cpp +++ b/vm/jit.cpp @@ -7,7 +7,7 @@ namespace factor { - megamorphic caches (dispatch.cpp), - polymorphic inline caches (inline_cache.cpp) */ -/* Allocates memory */ +/* 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), @@ -30,6 +30,7 @@ jit::~jit() { (void)old_count; } +/* Allocates memory */ void jit::emit_relocation(cell relocation_template_) { data_root relocation_template(relocation_template_, parent); cell capacity = diff --git a/vm/jit.hpp b/vm/jit.hpp index a2247e5b1c..e440135399 100644 --- a/vm/jit.hpp +++ b/vm/jit.hpp @@ -20,9 +20,11 @@ struct jit { void emit_relocation(cell relocation_template); void emit(cell code_template); + /* Allocates memory */ void parameter(cell parameter) { parameters.add(parameter); } void emit_with_parameter(cell code_template_, cell parameter_); + /* Allocates memory */ void literal(cell literal) { literals.add(literal); } void emit_with_literal(cell code_template_, cell literal_); @@ -30,6 +32,7 @@ struct jit { emit_with_literal(parent->special_objects[JIT_PUSH_IMMEDIATE], literal); } + /* Allocates memory */ void word_jump(cell word_) { data_root word(word_, parent); #ifndef FACTOR_AMD64 @@ -39,6 +42,7 @@ struct jit { emit(parent->special_objects[JIT_WORD_JUMP]); } + /* Allocates memory */ void word_call(cell word) { emit_with_literal(parent->special_objects[JIT_WORD_CALL], word); } diff --git a/vm/quotations.cpp b/vm/quotations.cpp index 445f88e424..b7cecae444 100644 --- a/vm/quotations.cpp +++ b/vm/quotations.cpp @@ -138,6 +138,7 @@ bool quotation_jit::trivial_quotation_p(array* elements) { tagged(array_nth(elements, 0)).type_p(WORD_TYPE); } +/* Allocates memory (emit) */ void quotation_jit::emit_prolog(bool safepoint, bool stack_frame) { if (safepoint) emit(parent->special_objects[JIT_SAFEPOINT]); @@ -145,6 +146,7 @@ void quotation_jit::emit_prolog(bool safepoint, bool stack_frame) { emit(parent->special_objects[JIT_PROLOG]); } +/* Allocates memory (emit) */ void quotation_jit::emit_epilog(bool safepoint, bool stack_frame) { if (safepoint) emit(parent->special_objects[JIT_SAFEPOINT]); @@ -169,7 +171,7 @@ void quotation_jit::emit_quot(cell quot_) { } } -/* Allocates memory */ +/* Allocates memory (parameter(), literal(), emit_prolog, emit_with_literal)*/ void quotation_jit::iterate_quotation() { bool safepoint = safepoint_p(); bool stack_frame = stack_frame_p();