Update of /cvsroot/sbcl/sbcl/src/runtime
In directory sc8-pr-cvs1:/tmp/cvs-serv8845/src/runtime
Modified Files:
backtrace.c cheneygc.c interrupt.c ppc-arch.c ppc-linux-os.c
ppc-linux-os.h purify.c thread.c thread.h validate.c
x86-arch.c
Log Message:
0.pre8.33
=== Threads merge, 12.5 metres ===
Added ppc vop for CURRENT-THREAD-OFFSET-SAP : note that other
ports (alpha, sparc, etc) wil need this too
Fix the PPC symbol hashing problem with symbol names < 4
characters long (thanks CSR)
Replace CONTROL_STACK_FOO with thread-> or SymbolValue as
appropriate in various non-x86 places (cheneygc, ldb backtrace
etc)
get_spinlock defn moved into $arch-arch.c, as unlikely to vary
much between one OS and another on a given arch. Other arches
need to add this too, but for non-threaded ports the dummy
version in ppc-arch.c will do fine.
Stub arch_os_get_current_thread, arch_os_thread_{init,cleanup}
added for Linux/PPC: needs adding to other ports
Add missing UNIX-SETSID definition, used in MAKE-LISTENER-THREAD
Index: backtrace.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/backtrace.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- backtrace.c 2 Apr 2003 11:15:20 -0000 1.11
+++ backtrace.c 3 Apr 2003 18:27:22 -0000 1.12
@@ -26,6 +26,7 @@
#endif
#include "genesis/static-symbols.h"
#include "genesis/primitive-objects.h"
+#include "thread.h"
#ifndef __i386__
@@ -95,7 +96,8 @@
static boolean
cs_valid_pointer_p(struct call_frame *pointer)
{
- return (((char *) CONTROL_STACK_START <= (char *) pointer) &&
+ struct thread *thread=arch_os_get_current_thread();
+ return (((char *) thread->control_stack_start <= (char *) pointer) &&
((char *) pointer < (char *) current_control_stack_pointer));
}
Index: cheneygc.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/cheneygc.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- cheneygc.c 28 Feb 2003 19:26:25 -0000 1.4
+++ cheneygc.c 3 Apr 2003 18:27:24 -0000 1.5
@@ -29,6 +29,7 @@
#include "interr.h"
#include "genesis/static-symbols.h"
#include "genesis/primitive-objects.h"
+#include "thread.h"
/* So you need to debug? */
#if 0
@@ -47,6 +48,7 @@
static void scavenge_newspace(void);
static void scavenge_interrupt_contexts(void);
+extern struct interrupt_data * global_interrupt_data;
/* collecting garbage */
@@ -120,6 +122,10 @@
unsigned long static_space_size;
unsigned long control_stack_size, binding_stack_size;
sigset_t tmp, old;
+ struct thread *th=arch_os_get_current_thread();
+ struct interrupt_data *data=
+ th ? th->interrupt_data : global_interrupt_data;
+
#ifdef PRINTNOISE
printf("[Collecting garbage ... \n");
@@ -134,7 +140,7 @@
current_static_space_free_pointer =
(lispobj *) ((unsigned long)
- SymbolValue(STATIC_SPACE_FREE_POINTER));
+ SymbolValue(STATIC_SPACE_FREE_POINTER,0));
/* Set up from space and new space pointers. */
@@ -169,30 +175,30 @@
printf("Scavenging interrupt handlers (%d bytes) ...\n",
(int)sizeof(interrupt_handlers));
#endif
- scavenge((lispobj *) interrupt_handlers,
- sizeof(interrupt_handlers) / sizeof(lispobj));
+ scavenge((lispobj *) data->interrupt_handlers,
+ sizeof(data->interrupt_handlers) / sizeof(lispobj));
/* _size quantities are in units of sizeof(lispobj) - i.e. 4 */
control_stack_size =
current_control_stack_pointer-
- (lispobj *)CONTROL_STACK_START;
+ (lispobj *)th->control_stack_start;
#ifdef PRINTNOISE
printf("Scavenging the control stack at %p (%ld words) ...\n",
- ((lispobj *)CONTROL_STACK_START),
+ ((lispobj *)th->control_stack_start),
control_stack_size);
#endif
- scavenge(((lispobj *)CONTROL_STACK_START), control_stack_size);
+ scavenge(((lispobj *)th->control_stack_start), control_stack_size);
binding_stack_size =
current_binding_stack_pointer -
- (lispobj *)BINDING_STACK_START;
+ (lispobj *)th->binding_stack_start;
#ifdef PRINTNOISE
printf("Scavenging the binding stack %x - %x (%d words) ...\n",
- BINDING_STACK_START,current_binding_stack_pointer,
+ th->binding_stack_start,current_binding_stack_pointer,
(int)(binding_stack_size));
#endif
- scavenge(((lispobj *)BINDING_STACK_START), binding_stack_size);
+ scavenge(((lispobj *)th->binding_stack_start), binding_stack_size);
static_space_size =
current_static_space_free_pointer - (lispobj *) STATIC_SPACE_START;
@@ -414,13 +420,18 @@
int i, index;
os_context_t *context;
- index = fixnum_value(SymbolValue(FREE_INTERRUPT_CONTEXT_INDEX));
+ struct thread *th=arch_os_get_current_thread();
+ struct interrupt_data *data=
+ th ? th->interrupt_data : global_interrupt_data;
+
+ index = fixnum_value(SymbolValue(FREE_INTERRUPT_CONTEXT_INDEX,0));
+
#ifdef DEBUG_SCAVENGE_VERBOSE
fprintf(stderr, "%d interrupt contexts to scan\n",index);
#endif
for (i = 0; i < index; i++) {
- context = lisp_interrupt_contexts[i];
+ context = th->interrupt_contexts[i];
scavenge_interrupt_context(context);
}
}
Index: interrupt.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/interrupt.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- interrupt.c 2 Apr 2003 11:15:21 -0000 1.34
+++ interrupt.c 3 Apr 2003 18:27:24 -0000 1.35
@@ -571,6 +571,9 @@
interrupt_maybe_gc(int signal, siginfo_t *info, void *void_context)
{
os_context_t *context=(os_context_t *) void_context;
+ struct thread *th=arch_os_get_current_thread();
+ struct interrupt_data *data=
+ th ? th->interrupt_data : global_interrupt_data;
if (!foreign_function_call_active
#ifndef LISP_FEATURE_GENCGC
@@ -589,11 +592,11 @@
* will detect pending_signal==0 and know to do a GC with the
* signal context instead of calling a Lisp-level handler */
maybe_gc_pending = 1;
- if (pending_signal == 0) {
+ if (data->pending_signal == 0) {
/* FIXME: This copy-pending_mask-then-sigaddset_blockable
* idiom occurs over and over. It should be factored out
* into a function with a descriptive name. */
- memcpy(&pending_mask,
+ memcpy(&(data->pending_mask),
os_context_sigmask_addr(context),
sizeof(sigset_t));
sigaddset_blockable(os_context_sigmask_addr(context));
Index: ppc-arch.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/ppc-arch.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ppc-arch.c 19 Aug 2002 12:14:04 -0000 1.3
+++ ppc-arch.c 3 Apr 2003 18:27:25 -0000 1.4
@@ -98,6 +98,14 @@
}
void
+get_spinlock(lispobj *word,int value)
+{
+ /* FIXME */
+ *word=value;
+}
+
+
+void
arch_remove_breakpoint(void *pc, unsigned long orig_inst)
{
*(unsigned long *)pc = orig_inst;
Index: ppc-linux-os.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/ppc-linux-os.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ppc-linux-os.c 6 Aug 2002 11:46:33 -0000 1.4
+++ ppc-linux-os.c 3 Apr 2003 18:27:26 -0000 1.5
@@ -38,6 +38,16 @@
#include "validate.h"
size_t os_vm_page_size;
+struct thread *arch_os_get_current_thread() {
+ return all_threads;
+}
+struct thread *arch_os_thread_init() {
+ return 1; /* success */
+}
+struct thread *arch_os_thread_cleanup() {
+ return 1; /* success */
+}
+
os_context_register_t *
os_context_register_addr(os_context_t *context, int offset)
{
Index: ppc-linux-os.h
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/ppc-linux-os.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ppc-linux-os.h 1 Sep 2002 22:34:18 -0000 1.4
+++ ppc-linux-os.h 3 Apr 2003 18:27:27 -0000 1.5
@@ -10,5 +10,6 @@
unsigned long os_context_fp_control(os_context_t *context);
void os_restore_fp_control(os_context_t *context);
+extern struct thread *arch_os_get_current_thread();
#endif /* _PPC_LINUX_OS_H */
Index: purify.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/purify.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- purify.c 3 Apr 2003 15:33:33 -0000 1.24
+++ purify.c 3 Apr 2003 18:27:28 -0000 1.25
@@ -1339,11 +1339,12 @@
fflush(stdout);
#endif
+#if (defined(LISP_FEATURE_GENCGC) && defined(LISP_FEATURE_X86))
#if 0
- /* can't do this unless the threads in question are suspended with
- * ptrace
+ /* This is what we should do, but can't unless the threads in
+ * question are suspended with ptrace. That's right, purify is not
+ * threadsafe
*/
-#if (defined(LISP_FEATURE_GENCGC) && defined(LISP_FEATURE_X86))
for_each_thread(thread) {
void **ptr;
struct user_regs_struct regs;
@@ -1354,11 +1355,11 @@
setup_i386_stack_scav(regs.ebp,
((void *)thread->control_stack_end));
}
-#endif
-#endif
+#endif /* 0 */
+ /* stopgap until we can set things up as in preceding comment */
setup_i386_stack_scav(((&static_roots)-2),
((void *)all_threads->control_stack_end));
-
+#endif
pscav(&static_roots, 1, 0);
pscav(&read_only_roots, 1, 1);
@@ -1377,8 +1378,9 @@
fflush(stdout);
#endif
#ifndef __i386__
- pscav((lispobj *)CONTROL_STACK_START,
- current_control_stack_pointer - (lispobj *)CONTROL_STACK_START,
+ pscav((lispobj *)all_threads->control_stack_start,
+ current_control_stack_pointer -
+ all_threads->control_stack_start,
0);
#else
#ifdef LISP_FEATURE_GENCGC
@@ -1391,8 +1393,9 @@
fflush(stdout);
#endif
#if !defined(__i386__)
- pscav( (lispobj *)BINDING_STACK_START,
- (lispobj *)current_binding_stack_pointer - (lispobj *)BINDING_STACK_START,
+ pscav( (lispobj *)all_threads->binding_stack_start,
+ (lispobj *)current_binding_stack_pointer -
+ all_threads->binding_stack_start,
0);
#else
for_each_thread(thread) {
@@ -1471,10 +1474,10 @@
* calling SCRUB-CONTROL-STACK - this zeros the stack on the x86. */
#ifndef __i386__
os_zero((os_vm_address_t) current_control_stack_pointer,
- (os_vm_size_t) (CONTROL_STACK_SIZE -
+ (os_vm_size_t) (THREAD_CONTROL_STACK_SIZE -
((current_control_stack_pointer -
- (lispobj *)CONTROL_STACK_START) *
- sizeof(lispobj))));
+ all_threads->control_stack_start)
+ * sizeof(lispobj))));
#endif
/* It helps to update the heap free pointers so that free_heap can
Index: thread.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/thread.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- thread.c 3 Apr 2003 15:33:35 -0000 1.4
+++ thread.c 3 Apr 2003 18:27:30 -0000 1.5
@@ -55,10 +55,10 @@
if(arch_os_thread_init(th)==0)
return 1; /* failure. no, really */
-#ifdef LISP_FEATURE_SB_THREAD
- return call_into_lisp(function,args,0);
-#else
+#if !defined(LISP_FEATURE_SB_THREAD) && defined(LISP_FEATURE_X86)
return call_into_lisp_first_time(function,args,0);
+#else
+ return funcall0(function);
#endif
}
@@ -95,6 +95,7 @@
memcpy(per_thread,arch_os_get_current_thread(),
dynamic_values_bytes);
} else {
+#ifdef LISP_FEATURE_SB_THREAD
int i;
for(i=0;i<(dynamic_values_bytes/sizeof(lispobj));i++)
per_thread->dynamic_values[i]=UNBOUND_MARKER_WIDETAG;
@@ -104,7 +105,6 @@
make_fixnum(MAX_INTERRUPTS+
sizeof(struct thread)/sizeof(lispobj)),
0);
-#ifdef LISP_FEATURE_SB_THREAD
#define STATIC_TLS_INIT(sym,field) \
((struct symbol *)(sym-OTHER_POINTER_LOWTAG))->tls_index= \
make_fixnum(THREAD_SLOT_OFFSET_WORDS(field))
@@ -139,7 +139,9 @@
/* runtime.c used to set PSEUDO_ATOMIC_ATOMIC =1 globally. I'm not
* sure why, but it appears to help */
th->pseudo_atomic_atomic=make_fixnum(1);
+#ifdef LISP_FEATURE_GENCGC
gc_set_region_empty(&th->alloc_region);
+#endif
#ifndef LISP_FEATURE_SB_THREAD
/* the tls-points-into-struct-thread trick is only good for threaded
@@ -149,13 +151,18 @@
* variable quantities from the C runtime. It's not quite OAOOM,
* it just feels like it */
SetSymbolValue(BINDING_STACK_START,th->binding_stack_start,th);
- SetSymbolValue(BINDING_STACK_POINTER,th->binding_stack_pointer,th);
SetSymbolValue(CONTROL_STACK_START,th->control_stack_start,th);
+ SetSymbolValue(CONTROL_STACK_END,th->control_stack_end,th);
+#ifdef LISP_FEATURE_X86
+ SetSymbolValue(BINDING_STACK_POINTER,th->binding_stack_pointer,th);
SetSymbolValue(ALIEN_STACK,th->alien_stack_pointer,th);
SetSymbolValue(PSEUDO_ATOMIC_ATOMIC,th->pseudo_atomic_atomic,th);
SetSymbolValue(PSEUDO_ATOMIC_INTERRUPTED,th->pseudo_atomic_interrupted,th);
+#else
+ current_binding_stack_pointer=th->binding_stack_pointer;
+ current_control_stack_pointer=th->control_stack_start;
#endif
-
+#endif
bind_variable(CURRENT_CATCH_BLOCK,make_fixnum(0),th);
bind_variable(CURRENT_UNWIND_PROTECT_BLOCK,make_fixnum(0),th);
bind_variable(FREE_INTERRUPT_CONTEXT_INDEX,make_fixnum(0),th);
@@ -164,7 +171,8 @@
th->interrupt_data=malloc(sizeof (struct interrupt_data));
if(all_threads)
- memcpy(th->interrupt_data,arch_os_get_current_thread()->interrupt_data,
+ memcpy(th->interrupt_data,
+ arch_os_get_current_thread()->interrupt_data,
sizeof (struct interrupt_data));
else
memcpy(th->interrupt_data,global_interrupt_data,
@@ -213,7 +221,9 @@
{
/* precondition: the unix task has already been killed and exited.
* This is called by the parent */
+#ifdef LISP_FEATURE_GENCGC
gc_alloc_update_page_tables(0, &th->alloc_region);
+#endif
get_spinlock(&all_threads_lock,th->pid);
if(th==all_threads)
all_threads=th->next;
@@ -240,16 +250,6 @@
}
-void get_spinlock(lispobj *word,int value)
-{
- u32 eax=0;
- do {
- asm ("xor %0,%0;cmpxchg %1,%2"
- : "=a" (eax)
- : "r" (value), "m" (*word)
- : "memory", "cc");
- } while(eax!=0);
-}
void block_sigcont(void)
{
Index: thread.h
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/thread.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- thread.h 2 Apr 2003 11:15:23 -0000 1.3
+++ thread.h 3 Apr 2003 18:27:31 -0000 1.4
@@ -11,7 +11,7 @@
#ifdef LISP_FEATURE_GENCGC
#include "gencgc-alloc-region.h"
#else
-#error "threading doesn't work with cheney gc yet"
+struct alloc_region { };
#endif
#include "genesis/symbol.h"
#include "genesis/static-symbols.h"
Index: validate.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/validate.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- validate.c 2 Apr 2003 11:15:23 -0000 1.14
+++ validate.c 3 Apr 2003 18:27:32 -0000 1.15
@@ -87,8 +87,10 @@
void protect_control_stack_guard_page(pid_t t_id, int protect_p) {
struct thread *th= find_thread_by_pid(t_id);
+#if 0
os_protect(CONTROL_STACK_GUARD_PAGE(th),
os_vm_page_size,protect_p ?
(OS_VM_PROT_READ|OS_VM_PROT_EXECUTE) : OS_VM_PROT_ALL);
+#endif
}
Index: x86-arch.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/x86-arch.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- x86-arch.c 2 Apr 2003 11:15:23 -0000 1.18
+++ x86-arch.c 3 Apr 2003 18:27:32 -0000 1.19
@@ -141,6 +141,18 @@
return result;
}
+void
+get_spinlock(lispobj *word,int value)
+{
+ u32 eax=0;
+ do {
+ asm ("xor %0,%0;cmpxchg %1,%2"
+ : "=a" (eax)
+ : "r" (value), "m" (*word)
+ : "memory", "cc");
+ } while(eax!=0);
+}
+
void
arch_remove_breakpoint(void *pc, unsigned long orig_inst)
{
|