From patchwork Thu Dec 2 10:22:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 73950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id BC7BAB70A7 for ; Thu, 2 Dec 2010 21:22:59 +1100 (EST) Received: (qmail 11606 invoked by alias); 2 Dec 2010 10:22:52 -0000 Received: (qmail 11566 invoked by uid 22791); 2 Dec 2010 10:22:48 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL, BAYES_40, TW_IB, TW_LW, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (140.186.70.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Dec 2010 10:22:41 +0000 Received: from eggs.gnu.org ([140.186.70.92]:41957) by fencepost.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1PO6JB-0007be-Rx for gcc-patches@gnu.org; Thu, 02 Dec 2010 05:22:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PO6JC-0005gm-HE for gcc-patches@gnu.org; Thu, 02 Dec 2010 05:22:39 -0500 Received: from c2beaomr10.btconnect.com ([213.123.26.188]:39730 helo=mail.btconnect.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PO6JC-0005cF-7Y for gcc-patches@gnu.org; Thu, 02 Dec 2010 05:22:38 -0500 Received: from host81-138-1-83.in-addr.btopenworld.com (EHLO thor.office) ([81.138.1.83]) by c2beaomr10.btconnect.com with ESMTP id AWD41767; Thu, 02 Dec 2010 10:22:32 +0000 (GMT) Message-Id: <0DA938AC-A8F4-403C-8218-CCA4D9E8937D@sandoe-acoustics.co.uk> From: IainS To: gcc-patches@gnu.org Mime-Version: 1.0 (Apple Message framework v936) Subject: [Patch, Darwin/PPC64] Fix boehm-gc for PPC64 Date: Thu, 2 Dec 2010 10:22:17 +0000 Cc: Mike Stump X-Mirapoint-IP-Reputation: reputation=Fair-1, source=Queried, refid=tid=0001.0A0B0302.4CF77359.0236, actions=tag X-Junkmail-Signature-Raw: score=unknown, refid=str=0001.0A0B0209.4CF77369.0071, ss=1, fgs=0, ip=0.0.0.0, so=2010-07-22 22:03:31, dmn=2009-09-10 00:05:08, mode=single engine X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org well, I imagine this has never worked ... ... unfortunately, 'make check' doesn't seem to exercise the multi- lib for boehm-gc ... (unless one does it by hand) Anyway the patch turns a bunch of seg-faults into working tests for 'make check' in the ppc64/boehm-gc dir. (and, incidentally, allows the ppc libjava build to proceed with fewer errors for m64). tested only on powerpc-darwin9. I'd welcome comments on whether the eh could be done better/more automatically, OK for trunk? Iain boehm-gc: * powerpc_darwin_mach_dep.s: Update for m64. Add eh frames. Do not build or use the picsymbol stub for Darwin >= 9. * tests/test.c (reverse_test): Modify count for ppc64. * pthread_support.c (GC_get_thread_stack_base): Correct a debug statement. Index: boehm-gc/powerpc_darwin_mach_dep.s =================================================================== --- boehm-gc/powerpc_darwin_mach_dep.s (revision 167325) +++ boehm-gc/powerpc_darwin_mach_dep.s (working copy) @@ -4,12 +4,38 @@ #define MODE_CHOICE(x, y) x #endif -#define lgu MODE_CHOICE(lwzu, ldu) +#define machine_choice MODE_CHOICE(ppc7400,ppc64) -#define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */ +; Define some pseudo-opcodes for size-independent load & store of GPRs ... +#define lgu MODE_CHOICE(lwzu, ldu) +#define lg MODE_CHOICE(lwz,ld) +#define sg MODE_CHOICE(stw,std) +#define sgu MODE_CHOICE(stwu,stdu) -#define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */ +; ... and the size of GPRs and their storage indicator. +#define GPR_BYTES MODE_CHOICE(4,8) +#define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */ +#define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */ +; From the ABI doc: "Mac OS X ABI Function Call Guide" Version 2009-02-04. +#define LINKAGE_SIZE MODE_CHOICE(24,48) +#define PARAM_AREA MODE_CHOICE(32,64) +#define SAVED_LR_OFFSET MODE_CHOICE(8,16) /* save position for lr */ + +; The whole stack frame **MUST** be 16byte-aligned. +#define SAVE_SIZE (LINKAGE_SIZE+PARAM_AREA) + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 +; We no longer need the pic symbol stub for Darwin >= 9. +#define BLGCP1 _GC_push_one +#undef WANT_STUB +#else +#define BLGCP1 L_GC_push_one$stub +#define WANT_STUB +#endif + + .machine machine_choice + ; GC_push_regs function. Under some optimization levels GCC will clobber ; some of the non-volatile registers before we get a chance to save them ; therefore, this cannot be inline asm. @@ -21,61 +47,116 @@ _GC_push_regs: ; Prolog mflr r0 - stw r0,8(r1) - stwu r1,-80(r1) + sg r0,SAVED_LR_OFFSET(r1) + sgu r1,-SAVE_SIZE(r1) - ; Push r13-r31 +L_body: + ; 'Push' r13-r31 mr r3,r13 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r14 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r15 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r16 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r17 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r18 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r19 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r20 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r21 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r22 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r23 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r24 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r25 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r26 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r27 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r28 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r29 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r30 - bl L_GC_push_one$stub + bl BLGCP1 mr r3,r31 - bl L_GC_push_one$stub + bl BLGCP1 - ; - lwz r0,88(r1) - addi r1,r1,80 +L_epilog: + ; Epilog + lg r0,SAVE_SIZE+SAVED_LR_OFFSET(r1) + addi r1,r1,SAVE_SIZE mtlr r0 - ; Return + ; Return blr +LFE0: -; PIC stuff, generated by GCC +; eh frames, for those that want 'em. -.data -.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 +#define EH_DATA_ALIGN_FACT MODE_CHOICE(0x7c,0x78) +#define EH_FRAME_OFFSET MODE_CHOICE(0x40,0x70) + + .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support +EH_frame1: + .set L$set$0,LECIE1-LSCIE1 + .long L$set$0 ; Length of Common Information Entry +LSCIE1: + .long 0 ; CIE Identifier Tag + .byte 0x1 ; CIE Version + .ascii "zR\0" ; CIE Augmentation + .byte 0x1 ; uleb128 0x1; CIE Code Alignment Factor + .byte EH_DATA_ALIGN_FACT ; sleb128 -4/-8; CIE Data Alignment Factor + .byte 0x41 ; CIE RA Column + .byte 0x1 ; uleb128 0x1; Augmentation size + .byte 0x10 ; FDE Encoding (pcrel) + .byte 0xc ; DW_CFA_def_cfa + .byte 0x1 ; uleb128 0x1 + .byte 0 ; uleb128 0 + .align LOG2_GPR_BYTES +LECIE1: + + .globl _GC_push_regs.eh +_GC_push_regs.eh: +LSFDE1: + .set L$set$1,LEFDE1-LASFDE1 + .long L$set$1 ; FDE Length +LASFDE1: + .long LASFDE1-EH_frame1 ; FDE CIE offset + .g_long _GC_push_regs-. ; FDE initial location + .set L$set$2,LFE0-_GC_push_regs + .g_long L$set$2 ; FDE address range + .byte 0 ; uleb128 0; Augmentation size + .byte 0x4 ; DW_CFA_advance_loc4 + .set L$set$3,L_body-_GC_push_regs + .long L$set$3 + .byte 0xe ; DW_CFA_def_cfa_offset + .byte EH_FRAME_OFFSET ; uleb128 0x40/0x70 + .byte 0x11 ; DW_CFA_offset_extended_sf + .byte 0x41 ; uleb128 0x41 + .byte 0x7e ; sleb128 -2 + .byte 0x4 ; DW_CFA_advance_loc4 + .set L$set$4,L_epilog-L_body + .long L$set$4 + .byte 0xe ; DW_CFA_def_cfa_offset + .byte 0 ; uleb128 0 + .align LOG2_GPR_BYTES +LEFDE1: + + .data +#ifdef WANT_STUB +; PIC stub stuff, generated by GCC + + .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 .align LOG2_GPR_BYTES L_GC_push_one$stub: .indirect_symbol _GC_push_one @@ -88,8 +169,10 @@ L0$_GC_push_one: lgu r12,lo16(L_GC_push_one$lazy_ptr-L0$_GC_push_one)(r11) mtctr r12 bctr -.data -.lazy_symbol_pointer + + .data + .lazy_symbol_pointer L_GC_push_one$lazy_ptr: .indirect_symbol _GC_push_one .g_long dyld_stub_binding_helper +#endif Index: boehm-gc/tests/test.c =================================================================== --- boehm-gc/tests/test.c (revision 167325) +++ boehm-gc/tests/test.c (working copy) @@ -624,7 +624,12 @@ void reverse_test() /* OSF has limited stack space by default, and large frames. */ # define BIG 200 # else -# define BIG 4500 +# if defined(__MACH__) && defined(__ppc64__) + /* Small stack and largish frames. */ +# define BIG 2500 +# else +# define BIG 4500 +# endif # endif # endif # endif Index: boehm-gc/pthread_support.c =================================================================== --- boehm-gc/pthread_support.c (revision 167325) +++ boehm-gc/pthread_support.c (working copy) @@ -1158,7 +1158,7 @@ GC_PTR GC_get_thread_stack_base() # else # ifdef DEBUG_THREADS - GC_printf1("Can not determine stack base for attached thread"); + GC_printf0("Can not determine stack base for attached thread"); # endif return 0; # endif