From e2b2b8f2156ede16d70a0bdd0cfad29ea31b8ccc Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Sun, 9 Dec 2007 15:04:48 +0000 Subject: [PATCH] 1.0.12.19: runtime cleanups by Daniel Lowe * Rename SymbolFunction to StaticSymbolFunction, and implement it as an inline function instead of a macro. * Implement make_lispobj, make_fixnum, and fixnum_value as inline functions. --- src/runtime/breakpoint.c | 6 +++--- src/runtime/gc-common.c | 2 +- src/runtime/gencgc.c | 2 +- src/runtime/interrupt.c | 14 +++++++------- src/runtime/runtime.h | 29 +++++++++++++++++------------ src/runtime/thread.h | 8 ++++++++ src/runtime/win32-os.c | 2 +- src/runtime/x86-64-darwin-os.c | 4 ++-- src/runtime/x86-darwin-os.c | 4 ++-- version.lisp-expr | 2 +- 10 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/runtime/breakpoint.c b/src/runtime/breakpoint.c index c67819208..846fa777c 100644 --- a/src/runtime/breakpoint.c +++ b/src/runtime/breakpoint.c @@ -139,7 +139,7 @@ void handle_breakpoint(os_context_t *context) thread_sigmask(SIG_SETMASK, os_context_sigmask_addr(context), 0); #endif - funcall3(SymbolFunction(HANDLE_BREAKPOINT), + funcall3(StaticSymbolFunction(HANDLE_BREAKPOINT), compute_offset(context, code), code, context_sap); @@ -164,7 +164,7 @@ void *handle_fun_end_breakpoint(os_context_t *context) thread_sigmask(SIG_SETMASK, os_context_sigmask_addr(context), 0); #endif - funcall3(SymbolFunction(HANDLE_BREAKPOINT), + funcall3(StaticSymbolFunction(HANDLE_BREAKPOINT), compute_offset(context, code), code, context_sap); @@ -194,7 +194,7 @@ handle_single_step_trap (os_context_t *context, int kind, int register_offset) thread_sigmask(SIG_SETMASK, os_context_sigmask_addr(context), 0); #endif - funcall2(SymbolFunction(HANDLE_SINGLE_STEP_TRAP), + funcall2(StaticSymbolFunction(HANDLE_SINGLE_STEP_TRAP), make_fixnum(kind), make_fixnum(register_offset)); diff --git a/src/runtime/gc-common.c b/src/runtime/gc-common.c index a615b6693..f39495fb8 100644 --- a/src/runtime/gc-common.c +++ b/src/runtime/gc-common.c @@ -2451,7 +2451,7 @@ maybe_gc(os_context_t *context) /* SIG_STOP_FOR_GC needs to be enabled before we can call lisp: * otherwise two threads racing here may deadlock: the other will * wait on the GC lock, and the other cannot stop the first one... */ - funcall0(SymbolFunction(SUB_GC)); + funcall0(StaticSymbolFunction(SUB_GC)); undo_fake_foreign_function_call(context); return 1; } diff --git a/src/runtime/gencgc.c b/src/runtime/gencgc.c index 719e127fc..a43d374a8 100644 --- a/src/runtime/gencgc.c +++ b/src/runtime/gencgc.c @@ -1097,7 +1097,7 @@ gc_heap_exhausted_error_or_lose (long available, long requested) else { /* FIXME: assert free_pages_lock held */ (void)thread_mutex_unlock(&free_pages_lock); - funcall2(SymbolFunction(HEAP_EXHAUSTED_ERROR), + funcall2(StaticSymbolFunction(HEAP_EXHAUSTED_ERROR), alloc_number(available), alloc_number(requested)); lose("HEAP-EXHAUSTED-ERROR fell through"); } diff --git a/src/runtime/interrupt.c b/src/runtime/interrupt.c index 7faea8b8b..e72bdd979 100644 --- a/src/runtime/interrupt.c +++ b/src/runtime/interrupt.c @@ -370,7 +370,7 @@ interrupt_internal_error(os_context_t *context, boolean continuable) * confused, we have a chance to determine what's going on. */ describe_internal_error(context); #endif - funcall2(SymbolFunction(INTERNAL_ERROR), context_sap, + funcall2(StaticSymbolFunction(INTERNAL_ERROR), context_sap, continuable ? T : NIL); undo_fake_foreign_function_call(context); /* blocks signals again */ @@ -1002,7 +1002,7 @@ interrupt_thread_handler(int num, siginfo_t *info, void *v_context) /* let the handler enable interrupts again when it sees fit */ sigaddset_deferrable(os_context_sigmask_addr(context)); - arrange_return_to_lisp_function(context, SymbolFunction(RUN_INTERRUPTION)); + arrange_return_to_lisp_function(context, StaticSymbolFunction(RUN_INTERRUPTION)); } #endif @@ -1016,7 +1016,7 @@ interrupt_thread_handler(int num, siginfo_t *info, void *v_context) void undefined_alien_function(void) { - funcall0(SymbolFunction(UNDEFINED_ALIEN_FUNCTION_ERROR)); + funcall0(StaticSymbolFunction(UNDEFINED_ALIEN_FUNCTION_ERROR)); } boolean @@ -1036,7 +1036,7 @@ handle_guard_page_triggered(os_context_t *context,os_vm_address_t addr) protect_control_stack_return_guard_page(1); arrange_return_to_lisp_function - (context, SymbolFunction(CONTROL_STACK_EXHAUSTED_ERROR)); + (context, StaticSymbolFunction(CONTROL_STACK_EXHAUSTED_ERROR)); return 1; } else if(addr >= CONTROL_STACK_RETURN_GUARD_PAGE(th) && @@ -1052,7 +1052,7 @@ handle_guard_page_triggered(os_context_t *context,os_vm_address_t addr) else if (addr >= undefined_alien_address && addr < undefined_alien_address + os_vm_page_size) { arrange_return_to_lisp_function - (context, SymbolFunction(UNDEFINED_ALIEN_VARIABLE_ERROR)); + (context, StaticSymbolFunction(UNDEFINED_ALIEN_VARIABLE_ERROR)); return 1; } else return 0; @@ -1287,7 +1287,7 @@ lisp_memory_fault_error(os_context_t *context, os_vm_address_t addr) * now -- some address is better then no address in this case. */ current_memory_fault_address = addr; - arrange_return_to_lisp_function(context, SymbolFunction(MEMORY_FAULT_ERROR)); + arrange_return_to_lisp_function(context, StaticSymbolFunction(MEMORY_FAULT_ERROR)); } #endif @@ -1300,7 +1300,7 @@ unhandled_trap_error(os_context_t *context) #ifndef LISP_FEATURE_WIN32 thread_sigmask(SIG_SETMASK, os_context_sigmask_addr(context), 0); #endif - funcall1(SymbolFunction(UNHANDLED_TRAP_ERROR), context_sap); + funcall1(StaticSymbolFunction(UNHANDLED_TRAP_ERROR), context_sap); lose("UNHANDLED-TRAP-ERROR fell through"); } diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index eaa233a7f..8304b77bb 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -132,14 +132,24 @@ native_pointer(lispobj obj) } /* inverse operation: create a suitably tagged lispobj from a native - * pointer or integer. Needs to be a macro due to the tedious C type - * system */ -#define make_lispobj(o,low_tag) ((lispobj)(LOW_WORD(o)|low_tag)) + * pointer or integer.*/ +static inline lispobj +make_lispobj(void *o, int low_tag) +{ + return LOW_WORD(o) | low_tag; +} + +static inline lispobj +make_fixnum(long n) +{ + return n << N_FIXNUM_TAG_BITS; +} -/* FIXME: There seems to be no reason that make_fixnum and fixnum_value - * can't be implemented as (possibly inline) functions. */ -#define make_fixnum(n) ((lispobj)((n)<>N_FIXNUM_TAG_BITS) +static inline long +fixnum_value(lispobj n) +{ + return n >> N_FIXNUM_TAG_BITS; +} #if defined(LISP_FEATURE_WIN32) /* KLUDGE: Avoid double definition of boolean by rpcndr.h included via @@ -156,11 +166,6 @@ native_pointer(lispobj obj) #endif typedef int boolean; -/* This only works for static symbols. */ -/* FIXME: should be called StaticSymbolFunction, right? */ -#define SymbolFunction(sym) \ - (((struct fdefn *)(native_pointer(SymbolValue(sym,0))))->fun) - /* KLUDGE: As far as I can tell there's no ANSI C way of saying * "this function never returns". This is the way that you do it * in GCC later than version 2.5 or so. */ diff --git a/src/runtime/thread.h b/src/runtime/thread.h index ca50539e5..8134ff01f 100644 --- a/src/runtime/thread.h +++ b/src/runtime/thread.h @@ -17,6 +17,7 @@ struct alloc_region { }; #include "genesis/symbol.h" #include "genesis/static-symbols.h" #include "genesis/thread.h" +#include "genesis/fdefn.h" #define STATE_RUNNING (make_fixnum(1)) #define STATE_SUSPENDED (make_fixnum(2)) @@ -102,6 +103,13 @@ SetTlSymbolValue(u64 tagged_symbol_pointer,lispobj val, void *thread) #endif } +/* This only works for static symbols. */ +static inline lispobj +StaticSymbolFunction(lispobj sym) +{ + return ((struct fdefn *)native_pointer(SymbolValue(sym, 0)))->fun; +} + static inline os_context_t *get_interrupt_context_for_thread(struct thread *th) { diff --git a/src/runtime/win32-os.c b/src/runtime/win32-os.c index eab029e1c..b0e9b6faa 100644 --- a/src/runtime/win32-os.c +++ b/src/runtime/win32-os.c @@ -418,7 +418,7 @@ handle_exception(EXCEPTION_RECORD *exception_record, _clearfp(); /* Call into lisp to handle things. */ - funcall2(SymbolFunction(HANDLE_WIN32_EXCEPTION), context_sap, + funcall2(StaticSymbolFunction(HANDLE_WIN32_EXCEPTION), context_sap, exception_record_sap); /* If Lisp doesn't nlx, we need to put things back. */ diff --git a/src/runtime/x86-64-darwin-os.c b/src/runtime/x86-64-darwin-os.c index 83a1f1e1a..5a0565611 100644 --- a/src/runtime/x86-64-darwin-os.c +++ b/src/runtime/x86-64-darwin-os.c @@ -281,7 +281,7 @@ control_stack_exhausted_handler(int signal, siginfo_t *siginfo, void *void_conte os_context_t *context = arch_os_get_context(&void_context); arrange_return_to_lisp_function - (context, SymbolFunction(CONTROL_STACK_EXHAUSTED_ERROR)); + (context, StaticSymbolFunction(CONTROL_STACK_EXHAUSTED_ERROR)); } void @@ -289,7 +289,7 @@ undefined_alien_handler(int signal, siginfo_t *siginfo, void *void_context) { os_context_t *context = arch_os_get_context(&void_context); arrange_return_to_lisp_function - (context, SymbolFunction(UNDEFINED_ALIEN_VARIABLE_ERROR)); + (context, StaticSymbolFunction(UNDEFINED_ALIEN_VARIABLE_ERROR)); } kern_return_t diff --git a/src/runtime/x86-darwin-os.c b/src/runtime/x86-darwin-os.c index 1650517fc..248e782dc 100644 --- a/src/runtime/x86-darwin-os.c +++ b/src/runtime/x86-darwin-os.c @@ -386,7 +386,7 @@ control_stack_exhausted_handler(int signal, siginfo_t *siginfo, void *void_conte os_context_t *context = arch_os_get_context(&void_context); arrange_return_to_lisp_function - (context, SymbolFunction(CONTROL_STACK_EXHAUSTED_ERROR)); + (context, StaticSymbolFunction(CONTROL_STACK_EXHAUSTED_ERROR)); } void @@ -394,7 +394,7 @@ undefined_alien_handler(int signal, siginfo_t *siginfo, void *void_context) { os_context_t *context = arch_os_get_context(&void_context); arrange_return_to_lisp_function - (context, SymbolFunction(UNDEFINED_ALIEN_VARIABLE_ERROR)); + (context, StaticSymbolFunction(UNDEFINED_ALIEN_VARIABLE_ERROR)); } kern_return_t diff --git a/version.lisp-expr b/version.lisp-expr index 74b1c7024..5a962c4f3 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.12.18" +"1.0.12.19" -- 2.11.4.GIT