1.0.12.19: runtime cleanups by Daniel Lowe
authorNikodemus Siivola <nikodemus@random-state.net>
Sun, 9 Dec 2007 15:04:48 +0000 (15:04 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Sun, 9 Dec 2007 15:04:48 +0000 (15:04 +0000)
* 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
src/runtime/gc-common.c
src/runtime/gencgc.c
src/runtime/interrupt.c
src/runtime/runtime.h
src/runtime/thread.h
src/runtime/win32-os.c
src/runtime/x86-64-darwin-os.c
src/runtime/x86-darwin-os.c
version.lisp-expr

index c678192..846fa77 100644 (file)
@@ -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));
 
index a615b66..f39495f 100644 (file)
@@ -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;
 }
index 719e127..a43d374 100644 (file)
@@ -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");
     }
index 7faea8b..e72bdd9 100644 (file)
@@ -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");
 }
 
index eaa233a..8304b77 100644 (file)
@@ -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))
-#define fixnum_value(n) (((long)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. */
index ca50539..8134ff0 100644 (file)
@@ -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)
 {
index eab029e..b0e9b6f 100644 (file)
@@ -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. */
index 83a1f1e..5a05656 100644 (file)
@@ -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
index 1650517..248e782 100644 (file)
@@ -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
index 74b1c70..5a962c4 100644 (file)
@@ -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"