X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=boehm-gc%2Fdarwin_stop_world.c;h=719b1b02d35ee474f7e4b0d9242c410fa59dc559;hb=7cad077c4e9c6726fbefeae8f3a4ff7db515a758;hp=895fdb61a6472cece4dfd056580313bfc6300f5a;hpb=168c58e0bbae3def1c0ee17e7a226c4e3d9081ff;p=pf3gnuchains%2Fgcc-fork.git diff --git a/boehm-gc/darwin_stop_world.c b/boehm-gc/darwin_stop_world.c index 895fdb61a64..719b1b02d35 100644 --- a/boehm-gc/darwin_stop_world.c +++ b/boehm-gc/darwin_stop_world.c @@ -10,7 +10,7 @@ be allocated, is called the red zone. This area as shown in Figure 3-2 may be used for any purpose as long as a new stack frame does not need to be added to the stack." - + Page 50: "If a leaf procedure's red zone usage would exceed 224 bytes, then it must set up a stack frame just like routines that call other routines." */ @@ -20,39 +20,6 @@ # define PPC_RED_ZONE_SIZE 320 #endif -/* Try to work out the right way to access thread state structure members. - The structure has changed its definition in different Darwin versions. */ -#if defined(__ppc__) -# define THREAD_STATE ppc_thread_state_t -# if defined (HAS_PPC_THREAD_STATE_R0) -# define THREAD_FLD(x) x -# elif defined (HAS_PPC_THREAD_STATE___R0) -# define THREAD_FLD(x) __ ## x -# else -# error can not work out how to access fields of ppc_thread_state_t -# endif -#elif defined(__ppc64__) -# define THREAD_STATE ppc_thread_state64_t -# if defined (HAS_PPC_THREAD_STATE64_R0) -# define THREAD_FLD(x) x -# elif defined (HAS_PPC_THREAD_STATE64___R0) -# define THREAD_FLD(x) __ ## x -# else -# error can not work out how to access fields of ppc_thread_state64_t -# endif -#elif defined(__i386__) -# define THREAD_STATE i386_thread_state_t -# if defined (HAS_I386_THREAD_STATE_EAX) -# define THREAD_FLD(x) x -# elif defined (HAS_I386_THREAD_STATE___EAX) -# define THREAD_FLD(x) __ ## x -# else -# error can not work out how to access fields of i386_thread_state_t -# endif -#else -# error unknown architecture -#endif - typedef struct StackFrame { unsigned long savedSP; unsigned long savedCR; @@ -61,7 +28,7 @@ typedef struct StackFrame { unsigned long savedRTOC; } StackFrame; -unsigned long FindTopOfStack(unsigned int stack_start) { +unsigned long FindTopOfStack(unsigned long stack_start) { StackFrame *frame; if (stack_start == 0) { @@ -106,8 +73,8 @@ void GC_push_all_stacks() { GC_thread p; pthread_t me; ptr_t lo, hi; - THREAD_STATE state; - mach_msg_type_number_t thread_state_count = MACHINE_THREAD_STATE_COUNT; + GC_THREAD_STATE_T state; + mach_msg_type_number_t thread_state_count = GC_MACH_THREAD_STATE_COUNT; me = pthread_self(); if (!GC_thr_initialized) GC_thr_init(); @@ -119,13 +86,47 @@ void GC_push_all_stacks() { lo = GC_approx_sp(); } else { /* Get the thread state (registers, etc) */ - r = thread_get_state( - p->stop_info.mach_thread, - MACHINE_THREAD_STATE, - (natural_t*)&state, - &thread_state_count); + r = thread_get_state(p->stop_info.mach_thread, GC_MACH_THREAD_STATE, + (natural_t*)&state, &thread_state_count); if(r != KERN_SUCCESS) ABORT("thread_get_state failed"); - + +#if defined(I386) + lo = (void*)state . THREAD_FLD (esp); + + GC_push_one(state . THREAD_FLD (eax)); + GC_push_one(state . THREAD_FLD (ebx)); + GC_push_one(state . THREAD_FLD (ecx)); + GC_push_one(state . THREAD_FLD (edx)); + GC_push_one(state . THREAD_FLD (edi)); + GC_push_one(state . THREAD_FLD (esi)); + GC_push_one(state . THREAD_FLD (ebp)); + +#elif defined(X86_64) + lo = (void*)state . THREAD_FLD (rsp); + + GC_push_one(state . THREAD_FLD (rax)); + GC_push_one(state . THREAD_FLD (rbx)); + GC_push_one(state . THREAD_FLD (rcx)); + GC_push_one(state . THREAD_FLD (rdx)); + GC_push_one(state . THREAD_FLD (rdi)); + GC_push_one(state . THREAD_FLD (rsi)); + GC_push_one(state . THREAD_FLD (rbp)); + GC_push_one(state . THREAD_FLD (rsp)); + GC_push_one(state . THREAD_FLD (r8)); + GC_push_one(state . THREAD_FLD (r9)); + GC_push_one(state . THREAD_FLD (r10)); + GC_push_one(state . THREAD_FLD (r11)); + GC_push_one(state . THREAD_FLD (r12)); + GC_push_one(state . THREAD_FLD (r13)); + GC_push_one(state . THREAD_FLD (r14)); + GC_push_one(state . THREAD_FLD (r15)); + GC_push_one(state . THREAD_FLD (rip)); + GC_push_one(state . THREAD_FLD (rflags)); + GC_push_one(state . THREAD_FLD (cs)); + GC_push_one(state . THREAD_FLD (fs)); + GC_push_one(state . THREAD_FLD (gs)); + +#elif defined(POWERPC) lo = (void*)(state . THREAD_FLD (r1) - PPC_RED_ZONE_SIZE); GC_push_one(state . THREAD_FLD (r0)); @@ -159,6 +160,9 @@ void GC_push_all_stacks() { GC_push_one(state . THREAD_FLD (r29)); GC_push_one(state . THREAD_FLD (r30)); GC_push_one(state . THREAD_FLD (r31)); +#else +# error FIXME for non-x86 || ppc architectures +#endif } /* p != me */ if(p->flags & MAIN_THREAD) hi = GC_stackbottom; @@ -198,9 +202,9 @@ void GC_push_all_stacks() { hi = (ptr_t)FindTopOfStack(0); } else { # if defined(__ppc__) || defined(__ppc64__) - THREAD_STATE info; + GC_THREAD_STATE_T info; mach_msg_type_number_t outCount = THREAD_STATE_MAX; - r = thread_get_state(thread, MACHINE_THREAD_STATE, + r = thread_get_state(thread, GC_MACH_THREAD_STATE, (natural_t *)&info, &outCount); if(r != KERN_SUCCESS) ABORT("task_get_state failed"); @@ -241,10 +245,10 @@ void GC_push_all_stacks() { # else /* FIXME: Remove after testing: */ WARN("This is completely untested and likely will not work\n", 0); - THREAD_STATE info; + GC_THREAD_STATE_T info; mach_msg_type_number_t outCount = THREAD_STATE_MAX; - r = thread_get_state(thread, MACHINE_THREAD_STATE, - (natural_t *)&info, &outCount); + r = thread_get_state(thread, GC_MACH_THREAD_STATE, (natural_t *)&info, + &outCount); if(r != KERN_SUCCESS) ABORT("task_get_state failed"); lo = (void*)info . THREAD_FLD (esp);