From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26977 invoked by alias); 18 Feb 2010 22:13:34 -0000 Received: (qmail 26955 invoked by uid 22791); 18 Feb 2010 22:13:33 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,HK_OBFDOM,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-bw0-f214.google.com (HELO mail-bw0-f214.google.com) (209.85.218.214) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Feb 2010 22:13:29 +0000 Received: by bwz6 with SMTP id 6so357963bwz.16 for ; Thu, 18 Feb 2010 14:13:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.239.161.76 with SMTP id g12mr1120877hbd.182.1266531206130; Thu, 18 Feb 2010 14:13:26 -0800 (PST) In-Reply-To: <4B7DA9FA.1020307@gmail.com> References: <4B6C9B26.3010106@gmail.com> <4B6D0C67.5030500@gmail.com> <4B78BA6D.5000603@gmail.com> <7230133d1002150504r23738e28if92303426c349661@mail.gmail.com> <4B7CC61E.1050709@gmail.com> <4B7D631B.8030401@gmail.com> <4B7DA9FA.1020307@gmail.com> Date: Thu, 18 Feb 2010 22:13:00 -0000 Message-ID: <7230133d1002181413h5c6abcf8ge7a989349e0fa3c0@mail.gmail.com> Subject: Re: Two quick GC questions [was Re: [REVIVED: PATCH PR42811,4.5 regression] java.lang.ExceptionInInitializerError in ecj1] From: Bryce McKinlay To: Dave Korn Cc: GCC Java Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2010-02/txt/msg00006.txt.bz2 On Thu, Feb 18, 2010 at 8:58 PM, Dave Korn wrote: > On 18/02/2010 15:56, Dave Korn wrote: > >>>> Running /gnu/gcc/gcc/libjava/testsuite/libjava.loader/loader.exp ... >>>> FAIL: /gnu/gcc/obj-pr42811-3/i686-pc-cygwin/libjava/testsuite/TestEarl= yGC.exe output - /gnu/gcc/obj-pr42811-3/i686-pc-cygwin/libjava/testsuite/Te= stEarlyGC.exe >>> *sigh*, and it turns out to be because some memory is getting released = by the >>> garbage collector when its still in use. =A0I'm busy trying to learn ho= w the GC >>> works real fast so I can figure out what's going wrong. > > =A0Well, it turns out to be fairly straightforward: there is no code to > register the .data and .bss sections of the main executable as static data > regions with the GC, so it has no idea there's a live pointer to an objec= t(*) > in there, and happily frees it up. > > =A0This leads me to two quick questions about the GC: > > 1- There's no call to GC_INIT anywhere under libjava/, and I can't find > anything in boehm.cc that even looks suitable for the purpose. =A0Does an= yone > know how the main exe's data/bss sections are supposed to get registered = on a > posixy system? GC_init_gcj_malloc() is called from boehm.cc:_Jv_InitGC(), and that in turn calls GC_init() if required. > 2- Libgcj statically links its own personal private copy of boehm-gc, rat= her > than using a shared library; does anyone know why it was designed this wa= y? Early on, the GC actually was in its own shared library (as was libffi). The main reason to put these into libgcj was that it avoids weird, hard-to-debug problems if you accidentally end up with the wrong version of one library or the other. That's probably not such a big deal now, but (windows limitations aside) I think its generally better to have less shared libraries rather than more. In theory, there could also be a performance advantage to having a single library because a smart linker / linker script could optimize internal calls to things like GC_malloc, speeding up the allocation path by avoiding PLT indirection. Bryce