]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: jit::jit is a c++ constructor but it does not allocate objects to the Factor...
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 14 Feb 2014 04:42:44 +0000 (20:42 -0800)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 15 Feb 2014 04:29:26 +0000 (20:29 -0800)
Add annotations for gc allocating.

vm/arrays.hpp
vm/byte_arrays.hpp
vm/callstack.cpp
vm/callstack.hpp
vm/dispatch.cpp
vm/factor.cpp
vm/gc.cpp
vm/inline_cache.cpp
vm/jit.cpp
vm/jit.hpp
vm/quotations.cpp

index 772a0afb3f89c47ca4b96e2902754447257923cb..8db65414e52e852b992708c0c609c2ed62ee83a5 100644 (file)
@@ -18,6 +18,7 @@ struct growable_array {
   cell count;
   data_root<array> elements;
 
+  /* Allocates memory */
   growable_array(factor_vm* parent, cell capacity = 10)
       : count(0),
         elements(parent->allot_array(capacity, false_object), parent) {}
index e3cbf520ce340193e30b43a99a3763558cb42cb6..44becd7e939d9081d834b200d30f7712e96587da 100644 (file)
@@ -4,6 +4,7 @@ struct growable_byte_array {
   cell count;
   data_root<byte_array> elements;
 
+  /* Allocates memory */
   growable_byte_array(factor_vm* parent, cell capacity = 40)
       : count(0), elements(parent->allot_byte_array(capacity), parent) {}
 
index fb146108ab12319e7ff559d9f75e342e519fe5fc..edcf842e4d986295e279de961042443f8ef97726 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace factor {
 
+/* Allocates memory (allot) */
 callstack* factor_vm::allot_callstack(cell size) {
   callstack* stack = allot<callstack>(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<callstack>(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<object> 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<callstack> stack(ctx->pop(), this);
   data_root<quotation> 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));
index 52f5c59d060cc59cc47817a8d384b5663153db28..2e8b6b7c4cad412c1d615e83e5342e00ddb3f3ce 100644 (file)
@@ -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 <typename Iterator, typename Fixup>
 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 <typename Iterator>
 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 <typename Iterator, typename Fixup>
 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 <typename Iterator>
 inline void factor_vm::iterate_callstack(context* ctx, Iterator& iterator) {
   no_fixup none;
index be3ae38774b7c53777a088dd8e8da31be7b9c89c..1c522bfb6816734d1f6ab0b5547737c416bbde66 100644 (file)
@@ -126,6 +126,7 @@ void factor_vm::primitive_dispatch_stats() {
   ctx->push(tag<byte_array>(byte_array_from_value(&dispatch_stats)));
 }
 
+/* Allocates memory */
 void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index,
                                            cell cache_) {
   data_root<array> methods(methods_, parent);
index fccdeb17c3b9e3e38e7c50b15e616237274da637..1343114973c24feac275443d60b3dcbe04e49f13 100644 (file)
@@ -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);
 
index 200842e78168b6e3d385ac509c7eedad1a3ae80e..6dce41083d6cffcaf8662008f8c89f0e74173230 100644 (file)
--- a/vm/gc.cpp
+++ b/vm/gc.cpp
@@ -274,7 +274,7 @@ void factor_vm::primitive_enable_gc_events() {
   gc_events = new std::vector<gc_event>();
 }
 
-/* Allocates memory */
+/* Allocates memory (byte_array_from_value, result.add) */
 void factor_vm::primitive_disable_gc_events() {
   if (gc_events) {
     growable_array result(this);
index d5e2159645ea14f26834eb769140c39fd29c73b2..eaef447204fb0669bc4090510d0e2a474a2c3e71 100644 (file)
@@ -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);
 }
index a377af536c1b65156cbd610498457d4ec7600459..e39164f308a0dc59b796b86104360280b660e548 100644 (file)
@@ -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<byte_array> relocation_template(relocation_template_, parent);
   cell capacity =
index a2247e5b1cbfb1c150678e01407882396ab926b5..e4401353994b199ec78fe22302507a5d7c130c17 100644 (file)
@@ -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(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);
   }
index 445f88e424b0d6abe5319d030191a0c9e8d4de24..b7cecae4448a0cc17f02c4e4cb6d945d52355dac 100644 (file)
@@ -138,6 +138,7 @@ bool quotation_jit::trivial_quotation_p(array* elements) {
          tagged<object>(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();