#include "master.hpp"
+static void check_frame(F_STACK_FRAME *frame)
+{
+#ifdef FACTOR_DEBUG
+ check_code_pointer(frame->xt);
+ assert(frame->size != 0);
+#endif
+}
+
/* called before entry into Factor code. */
F_FASTCALL void save_callstack_bottom(F_STACK_FRAME *callstack_bottom)
{
F_CODE_BLOCK *frame_code(F_STACK_FRAME *frame)
{
+ check_frame(frame);
return (F_CODE_BLOCK *)frame->xt - 1;
}
F_STACK_FRAME *frame_successor(F_STACK_FRAME *frame)
{
- if(frame->size == 0)
- critical_error("Stack frame has zero size",(CELL)frame);
+ check_frame(frame);
return (F_STACK_FRAME *)((CELL)frame - frame->size);
}
/* GC is off during heap walking */
extern bool gc_off;
-INLINE bool in_data_heap_p(CELL ptr)
-{
- return (ptr >= data_heap->segment->start
- && ptr <= data_heap->segment->end);
-}
-
INLINE void *allot_zone(F_ZONE *z, CELL a)
{
CELL h = z->here;
general_error(ERROR_DIVIDE_BY_ZERO,F,F,NULL);
}
-void memory_signal_handler_impl(void)
+void primitive_call_clear(void)
{
- memory_protection_error(signal_fault_addr,signal_callstack_top);
+ throw_impl(dpop(),stack_chain->callstack_bottom);
}
-void misc_signal_handler_impl(void)
+/* For testing purposes */
+void primitive_unimplemented(void)
{
- signal_error(signal_number,signal_callstack_top);
+ not_implemented_error();
}
-void primitive_call_clear(void)
+void memory_signal_handler_impl(void)
{
- throw_impl(dpop(),stack_chain->callstack_bottom);
+ memory_protection_error(signal_fault_addr,signal_callstack_top);
}
-/* For testing purposes */
-void primitive_unimplemented(void)
+void misc_signal_handler_impl(void)
{
- not_implemented_error();
+ signal_error(signal_number,signal_callstack_top);
}
return untag_##name##_fast(obj); \
} \
+void primitive_unimplemented(void);
+
/* Global variables used to pass fault handler state from signal handler to
user-space */
extern CELL signal_number;
void memory_signal_handler_impl(void);
void misc_signal_handler_impl(void);
-
-void primitive_unimplemented(void);
load_image(p);
init_c_io();
init_inline_caching(p->max_pic_size);
-
-#ifndef FACTOR_DEBUG
init_signals();
-#endif
if(p->console)
open_console();
/* Handle an exception by invoking the user's fault handler and/or forwarding
the duty to the previously installed handlers. */
+extern "C"
kern_return_t
catch_exception_raise (mach_port_t exception_port,
mach_port_t thread,
/* http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/catch_exception_raise.html
These functions are defined in this file, and called by exc_server.
FIXME: What needs to be done when this code is put into a shared library? */
+extern "C"
kern_return_t
catch_exception_raise (mach_port_t exception_port,
mach_port_t thread,
exception_type_t exception,
exception_data_t code,
mach_msg_type_number_t code_count);
+extern "C"
kern_return_t
catch_exception_raise_state (mach_port_t exception_port,
exception_type_t exception,
mach_msg_type_number_t in_state_count,
thread_state_t out_state,
mach_msg_type_number_t *out_state_count);
+
+extern "C"
kern_return_t
catch_exception_raise_state_identity (mach_port_t exception_port,
mach_port_t thread,
void primitive_byte_array_to_bignum(void)
{
- type_check(BYTE_ARRAY_TYPE,dpeek());
- CELL n_digits = array_capacity(untag_byte_array_fast(dpeek())) / CELLS;
- F_BIGNUM * bignum = digit_stream_to_bignum(
- n_digits,bignum_producer,0x100,0);
+ CELL n_digits = array_capacity(untag_byte_array(dpeek()));
+ F_BIGNUM * bignum = digit_stream_to_bignum(n_digits,bignum_producer,0x100,0);
drepl(tag_bignum(bignum));
}