]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: Annotate more places where we can gc.
authorDoug Coleman <doug.coleman@gmail.com>
Tue, 25 Nov 2014 09:12:45 +0000 (01:12 -0800)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 30 Nov 2014 01:25:46 +0000 (19:25 -0600)
Code formatting fix.

12 files changed:
vm/callbacks.cpp
vm/callstack.cpp
vm/contexts.cpp
vm/errors.cpp
vm/gc.cpp
vm/image.cpp
vm/io.cpp
vm/jit.cpp
vm/jit.hpp
vm/math.cpp
vm/objects.cpp
vm/quotations.cpp

index 9cccd1b933ee864793fdaefc3d203cffe2de1e9f..5dde871fbd90c1eb166c450b97125b5d8b487ca4 100644 (file)
@@ -124,7 +124,7 @@ void callback_heap::update() {
   allocator->iterate(updater);
 }
 
-/* Allocates memory */
+/* Allocates memory (add(), allot_alien())*/
 void factor_vm::primitive_callback() {
   cell return_rewind = to_cell(ctx->pop());
   tagged<word> w(ctx->pop());
index edcf842e4d986295e279de961042443f8ef97726..7044cddabd342f6b076f623185f7718fc3b3b505 100644 (file)
@@ -83,6 +83,7 @@ struct stack_frame_in_array {
   cell cells[3];
 };
 
+/* Allocates memory (frames.trim()), iterate_callstack_object() */
 void factor_vm::primitive_callstack_to_array() {
   data_root<callstack> callstack(ctx->peek(), this);
 
index 162be34c85f3bee2f113c2f9f1a85e0262f47005..41133e0839cf2254549a82825b98a65bc11077f5 100644 (file)
@@ -56,6 +56,7 @@ context::~context() {
 }
 
 /* called on startup */
+/* Allocates memory (new_context()) */
 void factor_vm::init_contexts(cell datastack_size_, cell retainstack_size_,
                               cell callstack_size_) {
   datastack_size = datastack_size_;
@@ -98,7 +99,7 @@ void factor_vm::init_context(context* ctx) {
   ctx->context_objects[OBJ_CONTEXT] = allot_alien(ctx);
 }
 
-/* Allocates memory */
+/* Allocates memory (init_context(), but not parent->new_context() */
 context* new_context(factor_vm* parent) {
   context* new_context = parent->new_context();
   parent->init_context(new_context);
@@ -120,7 +121,7 @@ VM_C_API void delete_context(factor_vm* parent, context* old_context) {
   parent->delete_context(old_context);
 }
 
-/* Allocates memory */
+/* Allocates memory (init_context()) */
 VM_C_API void reset_context(factor_vm* parent, context* ctx) {
   ctx->reset();
   parent->init_context(ctx);
@@ -139,6 +140,7 @@ cell factor_vm::begin_callback(cell quot_) {
   return quot.value();
 }
 
+/* Allocates memory */
 cell begin_callback(factor_vm* parent, cell quot) {
   return parent->begin_callback(quot);
 }
@@ -184,6 +186,7 @@ cell factor_vm::stack_to_array(cell bottom, cell top) {
   }
 }
 
+/* Allocates memory */
 cell factor_vm::datastack_to_array(context* ctx) {
   cell array = stack_to_array(ctx->datastack_seg->start, ctx->datastack);
   if (array == false_object) {
@@ -193,13 +196,16 @@ cell factor_vm::datastack_to_array(context* ctx) {
     return array;
 }
 
+/* Allocates memory */
 void factor_vm::primitive_datastack() { ctx->push(datastack_to_array(ctx)); }
 
+/* Allocates memory */
 void factor_vm::primitive_datastack_for() {
   context* other_ctx = (context*)pinned_alien_offset(ctx->peek());
   ctx->replace(datastack_to_array(other_ctx));
 }
 
+/* Allocates memory */
 cell factor_vm::retainstack_to_array(context* ctx) {
   cell array = stack_to_array(ctx->retainstack_seg->start, ctx->retainstack);
   if (array == false_object) {
@@ -209,10 +215,12 @@ cell factor_vm::retainstack_to_array(context* ctx) {
     return array;
 }
 
+/* Allocates memory */
 void factor_vm::primitive_retainstack() {
   ctx->push(retainstack_to_array(ctx));
 }
 
+/* Allocates memory */
 void factor_vm::primitive_retainstack_for() {
   context* other_ctx = (context*)pinned_alien_offset(ctx->peek());
   ctx->replace(retainstack_to_array(other_ctx));
index 61364b5bcfec8e9f1996c3097057b51df14f4292..0e27d9938aefc8d01e1df68d41b75d15c46edcf2 100644 (file)
@@ -39,7 +39,6 @@ void out_of_memory(const char *msg) {
 /* Allocates memory */
 void factor_vm::general_error(vm_error_type error, cell arg1_, cell arg2_) {
 
-
   data_root<object> arg1(arg1_, this);
   data_root<object> arg2(arg2_, this);
 
@@ -91,10 +90,12 @@ void factor_vm::general_error(vm_error_type error, cell arg1_, cell arg2_) {
   }
 }
 
+/* Allocates memory */
 void factor_vm::type_error(cell type, cell tagged) {
   general_error(ERROR_TYPE, tag_fixnum(type), tagged);
 }
 
+/* Allocates memory */
 void factor_vm::not_implemented_error() {
   general_error(ERROR_NOT_IMPLEMENTED, false_object, false_object);
 }
@@ -137,17 +138,21 @@ void factor_vm::signal_error(cell signal) {
   general_error(ERROR_SIGNAL, from_unsigned_cell(signal), false_object);
 }
 
+/* Allocates memory */
 void factor_vm::divide_by_zero_error() {
   general_error(ERROR_DIVIDE_BY_ZERO, false_object, false_object);
 }
 
+/* Allocates memory */
 void factor_vm::fp_trap_error(unsigned int fpu_status) {
   general_error(ERROR_FP_TRAP, tag_fixnum(fpu_status), false_object);
 }
 
 /* For testing purposes */
+/* Allocates memory */
 void factor_vm::primitive_unimplemented() { not_implemented_error(); }
 
+/* Allocates memory */
 void factor_vm::memory_signal_handler_impl() {
   memory_protection_error(signal_fault_pc, signal_fault_addr);
   if (!signal_resumable) {
@@ -157,18 +162,22 @@ void factor_vm::memory_signal_handler_impl() {
   }
 }
 
+/* Allocates memory */
 void memory_signal_handler_impl() {
   current_vm()->memory_signal_handler_impl();
 }
 
+/* Allocates memory */
 void factor_vm::synchronous_signal_handler_impl() {
   signal_error(signal_number);
 }
 
+/* Allocates memory */
 void synchronous_signal_handler_impl() {
   current_vm()->synchronous_signal_handler_impl();
 }
 
+/* Allocates memory (fp_trap_error())*/
 void factor_vm::fp_signal_handler_impl() {
   /* Clear pending exceptions to avoid getting stuck in a loop */
   set_fpu_state(get_fpu_state());
@@ -176,5 +185,6 @@ void factor_vm::fp_signal_handler_impl() {
   fp_trap_error(signal_fpu_status);
 }
 
+/* Allocates memory */
 void fp_signal_handler_impl() { current_vm()->fp_signal_handler_impl(); }
 }
index 3e24f1e11ec1e6096673ee9c3cc64f6f289ac301..a2a972954948bff905b75d71123d363582281002 100644 (file)
--- a/vm/gc.cpp
+++ b/vm/gc.cpp
@@ -235,6 +235,7 @@ void factor_vm::primitive_enable_gc_events() {
 }
 
 /* Allocates memory (byte_array_from_value, result.add) */
+/* XXX: Remember that growable_array has a data_root already */
 void factor_vm::primitive_disable_gc_events() {
   if (gc_events) {
     growable_array result(this);
index 3a58b950b817084116bcb70cd9f520aca958b1b7..f102c1ba23736a6e5bfae2e0da38e7c4b84a0765 100644 (file)
@@ -334,6 +334,7 @@ void factor_vm::primitive_save_image() {
              (vm_char*)(path2.untagged() + 1));
 }
 
+/* Allocates memory */
 void factor_vm::primitive_save_image_and_exit() {
   /* We unbox this before doing anything else. This is the only point
      where we might throw an error, so we have to throw an error here since
index 180d4f0f45a8b61b62400233a94993441db35cf0..a2474a00e9f02ee7b2840220255bc0dbc9dc0edb 100644 (file)
--- a/vm/io.cpp
+++ b/vm/io.cpp
@@ -19,6 +19,7 @@ void factor_vm::init_c_io() {
   special_objects[OBJ_STDERR] = allot_alien(false_object, (cell)stderr);
 }
 
+/* Allocates memory */
 void factor_vm::io_error() {
   if (errno == EINTR)
     return;
@@ -176,7 +177,7 @@ void factor_vm::primitive_fgetc() {
     ctx->replace(tag_fixnum(c));
 }
 
-/* Allocates memory */
+/* Allocates memory (from_unsigned_cell())*/
 void factor_vm::primitive_fread() {
   FILE* file = pop_file_handle();
   void* buf = (void*)alien_offset(ctx->pop());
index e39164f308a0dc59b796b86104360280b660e548..ad13d08747c7497d94901fc806ac7d2fd495d1b4 100644 (file)
@@ -113,7 +113,7 @@ void jit::compute_position(cell offset_) {
   offset = offset_;
 }
 
-/* Allocates memory */
+/* Allocates memory (trim(), add_code_block) */
 code_block* jit::to_code_block(cell frame_size) {
   /* Emit dummy GC info */
   code.grow_bytes(alignment_for(code.count + 4, data_alignment));
index e4401353994b199ec78fe22302507a5d7c130c17..98950467b8d437cea7bec2ae54d6440596af7dd2 100644 (file)
@@ -22,17 +22,20 @@ struct jit {
 
   /* Allocates memory */
   void parameter(cell parameter) { parameters.add(parameter); }
+  /* Allocates memory */
   void emit_with_parameter(cell code_template_, cell parameter_);
 
   /* Allocates memory */
   void literal(cell literal) { literals.add(literal); }
+  /* Allocates memory */
   void emit_with_literal(cell code_template_, cell literal_);
 
+  /* Allocates memory */
   void push(cell literal) {
     emit_with_literal(parent->special_objects[JIT_PUSH_IMMEDIATE], literal);
   }
 
-  /* Allocates memory */
+  /* Allocates memory (literal(), emit())*/
   void word_jump(cell word_) {
     data_root<word> word(word_, parent);
 #ifndef FACTOR_AMD64
index 0306ed20eff20d9ef5cb477f112a4193adf78626..35610186e00be452afeaad7c163833d774f33e65 100644 (file)
@@ -60,6 +60,7 @@ inline fixnum factor_vm::branchless_abs(fixnum x) {
   return (x ^ sign_mask(x)) - sign_mask(x);
 }
 
+/* Allocates memory */
 void factor_vm::primitive_fixnum_shift() {
   fixnum y = untag_fixnum(ctx->pop());
   fixnum x = untag_fixnum(ctx->peek());
@@ -81,10 +82,12 @@ void factor_vm::primitive_fixnum_shift() {
   ctx->replace(tag<bignum>(bignum_arithmetic_shift(fixnum_to_bignum(x), y)));
 }
 
+/* Allocates memory */
 void factor_vm::primitive_fixnum_to_bignum() {
   ctx->replace(tag<bignum>(fixnum_to_bignum(untag_fixnum(ctx->peek()))));
 }
 
+/* Allocates memory */
 void factor_vm::primitive_float_to_bignum() {
   ctx->replace(tag<bignum>(float_to_bignum(ctx->peek())));
 }
@@ -98,26 +101,31 @@ void factor_vm::primitive_bignum_eq() {
   ctx->replace(tag_boolean(bignum_equal_p(x, y)));
 }
 
+/* Allocates memory */
 void factor_vm::primitive_bignum_add() {
   POP_BIGNUMS(x, y);
   ctx->replace(tag<bignum>(bignum_add(x, y)));
 }
 
+/* Allocates memory */
 void factor_vm::primitive_bignum_subtract() {
   POP_BIGNUMS(x, y);
   ctx->replace(tag<bignum>(bignum_subtract(x, y)));
 }
 
+/* Allocates memory */
 void factor_vm::primitive_bignum_multiply() {
   POP_BIGNUMS(x, y);
   ctx->replace(tag<bignum>(bignum_multiply(x, y)));
 }
 
+/* Allocates memory */
 void factor_vm::primitive_bignum_divint() {
   POP_BIGNUMS(x, y);
   ctx->replace(tag<bignum>(bignum_quotient(x, y)));
 }
 
+/* Allocates memory */
 void factor_vm::primitive_bignum_divmod() {
   cell* s0 = (cell*)(ctx->datastack);
   cell* s1 = (cell*)(ctx->datastack - sizeof(cell));
@@ -154,6 +162,7 @@ void factor_vm::primitive_bignum_xor() {
   ctx->replace(tag<bignum>(bignum_bitwise_xor(x, y)));
 }
 
+/* Allocates memory */
 void factor_vm::primitive_bignum_shift() {
   fixnum y = untag_fixnum(ctx->pop());
   bignum* x = untag<bignum>(ctx->peek());
index 6d97ab719988c18ce07724e14ad3aea91c48182f..3211f7ec6106606c4e9065382c28006f5e4d8101 100644 (file)
@@ -121,6 +121,7 @@ struct code_block_write_barrier_visitor {
 
 /* classes.tuple uses this to reshape tuples; tools.deploy.shaker uses this
    to coalesce equal but distinct quotations and wrappers. */
+/* Calls gc */
 void factor_vm::primitive_become() {
   primitive_minor_gc();
   array* new_objects = untag_check<array>(ctx->pop());
index 2d5e7ed2bc9877fbac95bd0d056a98fd53fb271c..c5a480d05ba3cb9ad22aac9b8d03cf060b4e07d1 100644 (file)
@@ -197,7 +197,7 @@ void quotation_jit::iterate_quotation() {
                                         i == length - 1, /* tail_call_p */
                                         stack_frame);    /* stack_frame_p */
         }                                                /* Everything else */
-            else if (i == length - 1) {
+        else if (i == length - 1) {
           emit_epilog(safepoint, stack_frame);
           tail_call = true;
           word_jump(obj.value());
@@ -241,17 +241,17 @@ void quotation_jit::iterate_quotation() {
 
           i += 2;
         } /* dip */
-            else if (fast_dip_p(i, length)) {
+        else if (fast_dip_p(i, length)) {
           emit_quot(obj.value());
           emit(parent->special_objects[JIT_DIP]);
           i++;
         } /* 2dip */
-            else if (fast_2dip_p(i, length)) {
+        else if (fast_2dip_p(i, length)) {
           emit_quot(obj.value());
           emit(parent->special_objects[JIT_2DIP]);
           i++;
         } /* 3dip */
-            else if (fast_3dip_p(i, length)) {
+        else if (fast_3dip_p(i, length)) {
           emit_quot(obj.value());
           emit(parent->special_objects[JIT_3DIP]);
           i++;
@@ -272,7 +272,7 @@ void quotation_jit::iterate_quotation() {
                                  array_nth(elements.untagged(), i + 2));
           i += 3;
         } /* Non-optimizing compiler ignores declarations */
-            else if (declare_p(i, length))
+        else if (declare_p(i, length))
           i++;
         else
           push(obj.value());