}
}
+/* Allocates memory */
/* make an alien */
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()
{
ctx->push(library.value());
}
+/* Allocates memory */
/* look up a symbol in a native library */
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()
{
namespace factor
{
+/* Allocates memory */
array *factor_vm::allot_array(cell capacity, cell fill_)
{
data_root<object> fill(fill_,this);
return new_array;
}
+/* Allocates memory */
void factor_vm::primitive_array()
{
data_root<object> fill(ctx->pop(),this);
ctx->push(tag<array>(new_array));
}
+/* Allocates memory */
cell factor_vm::allot_array_1(cell obj_)
{
data_root<object> obj(obj_,this);
return a.value();
}
+/* Allocates memory */
cell factor_vm::allot_array_2(cell v1_, cell v2_)
{
data_root<object> v1(v1_,this);
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);
return a.value();
}
+/* Allocates memory */
void factor_vm::primitive_resize_array()
{
data_root<array> a(ctx->pop(),this);
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();
return objects.value();
}
+/* Allocates memory */
void growable_array::add(cell elt_)
{
factor_vm *parent = elements.parent;
parent->set_array_nth(elements.untagged(),count++,elt.value());
}
+/* Allocates memory */
void growable_array::append(array *elts_)
{
factor_vm *parent = elements.parent;
parent->set_array_nth(elements.untagged(),count++,array_nth(elts.untagged(),index));
}
+/* Allocates memory */
void growable_array::trim()
{
factor_vm *parent = elements.parent;
namespace factor
{
+/* Allocates memory */
byte_array *factor_vm::allot_byte_array(cell size)
{
byte_array *array = allot_uninitialized_array<byte_array>(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);
ctx->push(tag<byte_array>(reallot_array(array.untagged(),capacity)));
}
+/* Allocates memory */
void growable_byte_array::grow_bytes(cell len)
{
count += 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;
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);
count += len;
}
+/* Allocates memory */
void growable_byte_array::trim()
{
factor_vm *parent = elements.parent;
each_callback(updater);
}
+/* Allocates memory */
void factor_vm::primitive_callback()
{
cell return_rewind = to_cell(ctx->pop());
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();
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);
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));
abort();
}
+/* Allocates memory */
void factor_vm::general_error(vm_error_type error, cell arg1_, cell arg2_)
{
data_root<object> arg1(arg1_,this);
true /* trace contexts? */);
}
+/* Allocates memory */
/*
* It is up to the caller to fill in the object's fields in a meaningful
* fashion!
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);
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);
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);
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)
set_sampling_profiler(to_fixnum(ctx->pop()));
}
+/* Allocates memory */
void factor_vm::primitive_get_samples()
{
if (atomic::load(&sampling_profiler_p) || samples.empty()) {