]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: Add more comments about functions that allocate.
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 16 Aug 2012 05:00:08 +0000 (22:00 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 16 Aug 2012 05:00:08 +0000 (22:00 -0700)
vm/alien.cpp
vm/arrays.cpp
vm/byte_arrays.cpp
vm/callbacks.cpp
vm/contexts.cpp
vm/errors.cpp
vm/gc.cpp
vm/jit.cpp
vm/sampling_profiler.cpp

index 52b8a7800d41935d715d048c3d9c1008d3c85926..d0fdec6312151ed7b5c3618d332a214ade0e2a2f 100755 (executable)
@@ -27,6 +27,7 @@ char *factor_vm::pinned_alien_offset(cell obj)
        }
 }
 
+/* Allocates memory */
 /* make an alien */
 cell factor_vm::allot_alien(cell delegate_, cell displacement)
 {
@@ -52,11 +53,13 @@ cell factor_vm::allot_alien(cell delegate_, cell displacement)
        return new_alien.value();
 }
 
+/* Allocates memory */
 cell factor_vm::allot_alien(void *address)
 {
        return allot_alien(false_object,(cell)address);
 }
 
+/* Allocates memory */
 /* make an alien pointing at an offset of another alien */
 void factor_vm::primitive_displaced_alien()
 {
@@ -117,6 +120,7 @@ void factor_vm::primitive_dlopen()
        ctx->push(library.value());
 }
 
+/* Allocates memory */
 /* look up a symbol in a native library */
 void factor_vm::primitive_dlsym()
 {
@@ -139,6 +143,7 @@ void factor_vm::primitive_dlsym()
                ctx->push(allot_alien(ffi_dlsym(NULL,sym)));
 }
 
+/* Allocates memory */
 /* look up a symbol in a native library */
 void factor_vm::primitive_dlsym_raw()
 {
index 0d599a6c96bffcbed71a21c9c40e2c9d87221b82..5896325bbc56118e2a36aa75920054c6220375ea 100644 (file)
@@ -3,6 +3,7 @@
 namespace factor
 {
 
+/* Allocates memory */
 array *factor_vm::allot_array(cell capacity, cell fill_)
 {
        data_root<object> fill(fill_,this);
@@ -11,6 +12,7 @@ array *factor_vm::allot_array(cell capacity, cell fill_)
        return new_array;
 }
 
+/* Allocates memory */
 void factor_vm::primitive_array()
 {
        data_root<object> fill(ctx->pop(),this);
@@ -20,6 +22,7 @@ void factor_vm::primitive_array()
        ctx->push(tag<array>(new_array));
 }
 
+/* Allocates memory */
 cell factor_vm::allot_array_1(cell obj_)
 {
        data_root<object> obj(obj_,this);
@@ -28,6 +31,7 @@ cell factor_vm::allot_array_1(cell obj_)
        return a.value();
 }
 
+/* Allocates memory */
 cell factor_vm::allot_array_2(cell v1_, cell v2_)
 {
        data_root<object> v1(v1_,this);
@@ -38,6 +42,7 @@ cell factor_vm::allot_array_2(cell v1_, cell v2_)
        return a.value();
 }
 
+/* Allocates memory */
 cell factor_vm::allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_)
 {
        data_root<object> v1(v1_,this);
@@ -52,6 +57,7 @@ cell factor_vm::allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_)
        return a.value();
 }
 
+/* Allocates memory */
 void factor_vm::primitive_resize_array()
 {
        data_root<array> a(ctx->pop(),this);
@@ -60,6 +66,7 @@ void factor_vm::primitive_resize_array()
        ctx->push(tag<array>(reallot_array(a.untagged(),capacity)));
 }
 
+/* Allocates memory */
 cell factor_vm::std_vector_to_array(std::vector<cell> &elements)
 {
        cell element_count = elements.size();
@@ -73,6 +80,7 @@ cell factor_vm::std_vector_to_array(std::vector<cell> &elements)
        return objects.value();
 }
 
+/* Allocates memory */
 void growable_array::add(cell elt_)
 {
        factor_vm *parent = elements.parent;
@@ -83,6 +91,7 @@ void growable_array::add(cell elt_)
        parent->set_array_nth(elements.untagged(),count++,elt.value());
 }
 
+/* Allocates memory */
 void growable_array::append(array *elts_)
 {
        factor_vm *parent = elements.parent;
@@ -98,6 +107,7 @@ void growable_array::append(array *elts_)
                parent->set_array_nth(elements.untagged(),count++,array_nth(elts.untagged(),index));
 }
 
+/* Allocates memory */
 void growable_array::trim()
 {
        factor_vm *parent = elements.parent;
index 467e41029df8e6ead037d5676046b1e159be8a28..907cf3ee631cd3067d54ccec5f7f6ca365c78513 100644 (file)
@@ -3,6 +3,7 @@
 namespace factor
 {
 
+/* Allocates memory */
 byte_array *factor_vm::allot_byte_array(cell size)
 {
        byte_array *array = allot_uninitialized_array<byte_array>(size);
@@ -10,18 +11,21 @@ byte_array *factor_vm::allot_byte_array(cell size)
        return array;
 }
 
+/* Allocates memory */
 void factor_vm::primitive_byte_array()
 {
        cell size = unbox_array_size();
        ctx->push(tag<byte_array>(allot_byte_array(size)));
 }
 
+/* Allocates memory */
 void factor_vm::primitive_uninitialized_byte_array()
 {
        cell size = unbox_array_size();
        ctx->push(tag<byte_array>(allot_uninitialized_array<byte_array>(size)));
 }
 
+/* Allocates memory */
 void factor_vm::primitive_resize_byte_array()
 {
        data_root<byte_array> array(ctx->pop(),this);
@@ -30,6 +34,7 @@ void factor_vm::primitive_resize_byte_array()
        ctx->push(tag<byte_array>(reallot_array(array.untagged(),capacity)));
 }
 
+/* Allocates memory */
 void growable_byte_array::grow_bytes(cell len)
 {
        count += len;
@@ -37,6 +42,7 @@ void growable_byte_array::grow_bytes(cell len)
                elements = elements.parent->reallot_array(elements.untagged(),count * 2);
 }
 
+/* Allocates memory */
 void growable_byte_array::append_bytes(void *elts, cell len)
 {
        cell old_count = count;
@@ -44,6 +50,7 @@ void growable_byte_array::append_bytes(void *elts, cell len)
        memcpy(&elements->data<u8>()[old_count],elts,len);
 }
 
+/* Allocates memory */
 void growable_byte_array::append_byte_array(cell byte_array_)
 {
        data_root<byte_array> byte_array(byte_array_,elements.parent);
@@ -59,6 +66,7 @@ void growable_byte_array::append_byte_array(cell byte_array_)
        count += len;
 }
 
+/* Allocates memory */
 void growable_byte_array::trim()
 {
        factor_vm *parent = elements.parent;
index fafcbef54f5a4ff53f887da58b901c74b1376715..70058dad77d807cf1491ac2da7c6461e0237c9bc 100755 (executable)
@@ -125,6 +125,7 @@ void callback_heap::update()
        each_callback(updater);
 }
 
+/* Allocates memory */
 void factor_vm::primitive_callback()
 {
        cell return_rewind = to_cell(ctx->pop());
index fc10e3d8c82638453bd563ba2e9f6e5fcb47cb34..4c3480e96196f2ac137aa3d824212aea41f1791d 100644 (file)
@@ -143,11 +143,13 @@ context *factor_vm::new_context()
        return new_context;
 }
 
+/* Allocates memory */
 void factor_vm::init_context(context *ctx)
 {
        ctx->context_objects[OBJ_CONTEXT] = allot_alien(ctx);
 }
 
+/* Allocates memory */
 context *new_context(factor_vm *parent)
 {
        context *new_context = parent->new_context();
@@ -173,12 +175,14 @@ VM_C_API void delete_context(factor_vm *parent, context *old_context)
        parent->delete_context(old_context);
 }
 
+/* Allocates memory */
 VM_C_API void reset_context(factor_vm *parent, context *ctx)
 {
        ctx->reset();
        parent->init_context(ctx);
 }
 
+/* Allocates memory */
 cell factor_vm::begin_callback(cell quot_)
 {
        data_root<object> quot(quot_,this);
@@ -233,6 +237,7 @@ void factor_vm::primitive_context_object_for()
        ctx->push(other_ctx->context_objects[n]);
 }
 
+/* Allocates memory */
 cell factor_vm::stack_to_array(cell bottom, cell top)
 {
        fixnum depth = (fixnum)(top - bottom + sizeof(cell));
index 5fc9b1d200c814563980450948a6d2947889f260..c1d66dde0ab4c33045d0c19159ebe9406dbbe8db 100755 (executable)
@@ -41,6 +41,7 @@ void out_of_memory()
        abort();
 }
 
+/* Allocates memory */
 void factor_vm::general_error(vm_error_type error, cell arg1_, cell arg2_)
 {
        data_root<object> arg1(arg1_,this);
index aa0fe224e43ea6d0a017662c5a6d6b15ccd93c5a..e7367cbcb3817eb233bb7896b108ca84122ad7d1 100755 (executable)
--- a/vm/gc.cpp
+++ b/vm/gc.cpp
@@ -290,6 +290,7 @@ void factor_vm::primitive_compact_gc()
                true /* trace contexts? */);
 }
 
+/* Allocates memory */
 /*
  * It is up to the caller to fill in the object's fields in a meaningful
  * fashion!
index 9f3d7b5ed765549492d32e654f05c98b42ba6cc9..2b27539e7f1a4e09034acf0ca1a03eefdacdeefc 100644 (file)
@@ -78,6 +78,7 @@ void jit::emit(cell code_template_)
        code.append_byte_array(insns.value());
 }
 
+/* Allocates memory */
 void jit::emit_with_literal(cell code_template_, cell argument_) {
        data_root<array> code_template(code_template_,parent);
        data_root<object> argument(argument_,parent);
@@ -85,6 +86,7 @@ void jit::emit_with_literal(cell code_template_, cell argument_) {
        emit(code_template.value());
 }
 
+/* Allocates memory */
 void jit::emit_with_parameter(cell code_template_, cell argument_) {
        data_root<array> code_template(code_template_,parent);
        data_root<object> argument(argument_,parent);
@@ -92,6 +94,7 @@ void jit::emit_with_parameter(cell code_template_, cell argument_) {
        emit(code_template.value());
 }
 
+/* Allocates memory */
 bool jit::emit_subprimitive(cell word_, bool tail_call_p, bool stack_frame_p)
 {
        data_root<word> word(word_,parent);
@@ -99,6 +102,7 @@ bool jit::emit_subprimitive(cell word_, bool tail_call_p, bool stack_frame_p)
        parameters.append(untag<array>(array_nth(code_template.untagged(),0)));
        literals.append(untag<array>(array_nth(code_template.untagged(),1)));
        emit(array_nth(code_template.untagged(),2));
+
        if(array_capacity(code_template.untagged()) == 5)
        {
                if(tail_call_p)
index aa3f6a7dbe87575d869a590ddffb6febd07cb2e0..caf349f1a07d3d05a4607f3cd8bfd8d469961cb3 100644 (file)
@@ -122,6 +122,7 @@ void factor_vm::primitive_sampling_profiler()
        set_sampling_profiler(to_fixnum(ctx->pop()));
 }
 
+/* Allocates memory */
 void factor_vm::primitive_get_samples()
 {
        if (atomic::load(&sampling_profiler_p) || samples.empty()) {