Fix various issues from C++ port

db4
Slava Pestov 2009-05-02 20:01:54 -05:00
parent a63ad6a7a5
commit 0614f54ba3
8 changed files with 29 additions and 27 deletions

View File

@ -1,5 +1,13 @@
#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)
{
@ -90,6 +98,7 @@ void primitive_set_callstack(void)
F_CODE_BLOCK *frame_code(F_STACK_FRAME *frame)
{
check_frame(frame);
return (F_CODE_BLOCK *)frame->xt - 1;
}
@ -112,8 +121,7 @@ CELL frame_executing(F_STACK_FRAME *frame)
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);
}

View File

@ -99,12 +99,6 @@ void primitive_end_scan(void);
/* 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;

View File

@ -135,16 +135,6 @@ void divide_by_zero_error(void)
general_error(ERROR_DIVIDE_BY_ZERO,F,F,NULL);
}
void memory_signal_handler_impl(void)
{
memory_protection_error(signal_fault_addr,signal_callstack_top);
}
void misc_signal_handler_impl(void)
{
signal_error(signal_number,signal_callstack_top);
}
void primitive_call_clear(void)
{
throw_impl(dpop(),stack_chain->callstack_bottom);
@ -155,3 +145,13 @@ void primitive_unimplemented(void)
{
not_implemented_error();
}
void memory_signal_handler_impl(void)
{
memory_protection_error(signal_fault_addr,signal_callstack_top);
}
void misc_signal_handler_impl(void)
{
signal_error(signal_number,signal_callstack_top);
}

View File

@ -50,6 +50,8 @@ INLINE void type_check(CELL type, CELL tagged)
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;
@ -58,5 +60,3 @@ extern F_STACK_FRAME *signal_callstack_top;
void memory_signal_handler_impl(void);
void misc_signal_handler_impl(void);
void primitive_unimplemented(void);

View File

@ -122,10 +122,7 @@ void init_factor(F_PARAMETERS *p)
load_image(p);
init_c_io();
init_inline_caching(p->max_pic_size);
#ifndef FACTOR_DEBUG
init_signals();
#endif
if(p->console)
open_console();

View File

@ -60,6 +60,7 @@ static void call_fault_handler(exception_type_t exception,
/* 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,

View File

@ -42,6 +42,7 @@ extern "C" boolean_t exc_server (mach_msg_header_t *request_msg, mach_msg_header
/* 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,
@ -49,6 +50,7 @@ catch_exception_raise (mach_port_t exception_port,
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,
@ -59,6 +61,8 @@ catch_exception_raise_state (mach_port_t exception_port,
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,

View File

@ -255,10 +255,8 @@ unsigned int bignum_producer(unsigned int digit)
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));
}