Code formatting fix.
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());
cell cells[3];
};
+/* Allocates memory (frames.trim()), iterate_callstack_object() */
void factor_vm::primitive_callstack_to_array() {
data_root<callstack> callstack(ctx->peek(), this);
}
/* 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_;
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);
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);
return quot.value();
}
+/* Allocates memory */
cell begin_callback(factor_vm* parent, cell quot) {
return parent->begin_callback(quot);
}
}
}
+/* 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) {
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) {
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));
/* 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);
}
}
+/* 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);
}
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) {
}
}
+/* 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());
fp_trap_error(signal_fpu_status);
}
+/* Allocates memory */
void fp_signal_handler_impl() { current_vm()->fp_signal_handler_impl(); }
}
}
/* 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);
(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
special_objects[OBJ_STDERR] = allot_alien(false_object, (cell)stderr);
}
+/* Allocates memory */
void factor_vm::io_error() {
if (errno == EINTR)
return;
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());
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));
/* 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
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());
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())));
}
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));
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());
/* 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());
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());
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++;
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());