This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ivopts vs. garbage collection

On January 11, 2016 8:35:25 PM GMT+01:00, Michael Matz <> wrote:
>On Mon, 11 Jan 2016, Ian Lance Taylor wrote:
>> > Well, that's a hack.  A solution is to design something that works 
>> > generally for garbage collected languages with such requirements 
>> > instead of arbitrarily limiting transformations here and there.  It
>> > could be something like the notion of derived pointers, where the
>> > pointer needs to stay alive as long as the derived pointers are. 
>> > potential GC points where a derived pointer is alive also needs to 
>> > have the base pointer be alive (they could explicitely add uses of
>> > base pointers, or alternatively anthing computing liveness needs to
>> > deal with this).  For normal transformation that don't deal with 
>> > explicit liveness sets (i.e. most of our SSA transforms) it's
>> > if the instruction creating the derived pointer from the base can't
>> > looked through, i.e. is an optimization barrier.
>> What do you suggest we do for GCC 6?
>Realistically?  The hack of course.
>> Your suggestion of every derived pointer keeping the base pointer
>> sounds too strong to me; it certainly sounds too strong for Go. For
>> it should be sufficient to ensure that every derived pointer points 
>> within the bounds of the object.
>Okay, that's a certain type of GC.  Others might need exact offset-zero
>base pointers.
>> It's also not obvious to me that making a pointer transformation into
>> an optimization barrier would be a win overall.
>It will almost always be a pessimization (the additional live value
>at least a place on the stack).
>> For something like
>> ivopts it seems better to simply not introduce the pointer
>> transformation--to apply ivopts only to non-pointers when GC matters
>Of course that deals only with ivopts.  In practice that might be
>even for a long time, but it's not really a full solution, there are
>transformations on pointers (e.g. the vectorizer fiddling with
>some of them creating out of object pointers (e.g. chopping off the
>few bits).
>Another problem is to define "when GC matters".  With LTO you can't
>on anything from the frontend, so it needs to be encoded in the IL, or
>the very least in a per-function item, with corresponding avoidance of 
>inlining of GC into non-GC aware functions.

Here you can extend the hack to apply said flag to the final link if it is in at least one LTO object.  As we do for some already.

And yes, avoiding IVOPTs on pointer values is certainly the easiest fix.


>> (I'm still puzzled by the fact that Java has apparently not
>> this problem in all these years.)
>Probably it just so happened that the base pointer for some derived 
>pointer was lying around in some memory location.  It's not very likely
>that the only reference is in a register, it can happen only shortly
>allocating the new block, but before it's actually stored into some
>structure (or freed, i.e. when it's only temporary, but then the base 
>pointer would be live as well), perhaps this pattern doesn't happen
>often in java code.  Obviously it does in Go.  Perhaps we can limit the
>ivopts hack also to pointers that are problematic.  Only if the base 
>pointer comes from a new allocation (is not loaded from memory) and
>stored into memory before use do we need to avoid manipulating it too 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]