]> gitweb.factorcode.org Git - factor.git/commitdiff
Fix various issues from C++ port
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 3 May 2009 01:01:54 +0000 (20:01 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 3 May 2009 01:01:54 +0000 (20:01 -0500)
vmpp/callstack.cpp
vmpp/data_heap.hpp
vmpp/errors.cpp
vmpp/errors.hpp
vmpp/factor.cpp
vmpp/mach_signal.cpp
vmpp/mach_signal.hpp
vmpp/math.cpp

index ff50186a7d093685a62d2bb5ec147ba1d3ef9095..1bbcdff9c56a320302bcc514a44e52272226f58d 100755 (executable)
@@ -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);
 }
 
index 3b4231d98f214ae54139fe174f89bcf65233f506..db3cbd52f8e0576b1dc2d9bc5d4c72e77b3dfa88 100644 (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;
index 9ffc22d454f8a6098647d64ccc527e3a81a19c9e..260f4e04c320b051569ed9c36fbe685c6e927fa6 100755 (executable)
@@ -135,23 +135,23 @@ void divide_by_zero_error(void)
        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);
 }
index 8a202da48bce85aeed03c48a192dd4e635819800..0fc024de5e6c70544fce990327863f4caa53834d 100755 (executable)
@@ -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);
index d7512e807aec0a7aeef297b61ee71e5105f3f899..59263e1da88e8a7fa9e845132bfabf215d18ba9d 100755 (executable)
@@ -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();
index 3230c944d110a6f09a47baf0e3eef9b795a5ee2e..74f2e724ca87ce611bc721645ecec6c4d9589581 100644 (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,
index ee58a3acee02ac1da064bc6af53254b08aecb8e1..fdeef7b2a5ec72580141f16954cd4daed5b61b2c 100644 (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,
index 435270d21b8b70ee453ef9e49354488b44b04b72..928f7dab7ef7b5bcb092ce7c0799e59d0f121a2d 100644 (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));
 }