Re: how to generate code for (a,b):=(b,a)

Hans-Juergen Boehm <boehm@mti.mti.sgi.com>
17 May 1997 00:10:50 -0400

          From comp.compilers

Related articles
[9 earlier articles]
Re: how to generate code for (a,b):=(b,a) tim@wfn-shop.Princeton.EDU (1997-05-13)
Re: how to generate code for (a,b):=(b,a) cdg@nullstone.com (Christopher Glaeser) (1997-05-13)
Re: how to generate code for (a,b):=(b,a) genew@vip.net (1997-05-13)
Re: how to generate code for (a,b):=(b,a) bobduff@world.std.com (1997-05-13)
Re: how to generate code for (a,b):=(b,a) will@ccs.neu.edu (William D Clinger) (1997-05-17)
Re: how to generate code for (a,b):=(b,a) wilson@cs.utexas.edu (1997-05-17)
Re: how to generate code for (a,b):=(b,a) boehm@mti.mti.sgi.com (Hans-Juergen Boehm) (1997-05-17)
Re: how to generate code for (a,b):=(b,a) boehm@mti.mti.sgi.com (Hans-Juergen Boehm) (1997-05-17)
Re: how to generate code for (a,b):=(b,a) Dave@occl-cam.demon.co.uk (Dave Lloyd) (1997-05-22)
Re: how to generate code for (a,b):=(b,a) Dave@occl-cam.demon.co.uk (Dave Lloyd) (1997-05-22)
Re: how to generate code for (a,b):=(b,a) boehm@mti.mti.sgi.com (Hans-Juergen Boehm) (1997-05-25)
Re: how to generate code for (a,b):=(b,a) Dave@occl-cam.demon.co.uk (Dave Lloyd) (1997-05-27)
Re: how to generate code for (a,b):=(b,a) fjh@murlibobo.cs.mu.OZ.AU (1997-05-30)
[2 later articles]
| List of all articles for this month |

From: Hans-Juergen Boehm <boehm@mti.mti.sgi.com>
Newsgroups: comp.compilers
Date: 17 May 1997 00:10:50 -0400
Organization: Silicon Graphics Inc., Mountain View, CA
References: 97-05-058 97-05-129 97-05-148 97-05-164
Keywords: code, GC

>
> >registers can be exchanged with the sequence:
> > xor a,b
> > xor b,a
> > xor a,b


> wilson@cs.utexas.edu writes:
> > This is very likely to confuse a conservative garbage collector if
> > these are pointer variables. I'd hope that compiler writers wouldn't
> > use such optimizations casually, especially if they're not clearly
> > better than the alternatives.


tim@wfn-shop.Princeton.EDU wrote:
> That's not a problem in this case unless the GC is running as a
> preemptive thread and can get control in the middle of the xors though
> right? ... I don't see any
> reason why Boehm's GC would have a problem with this construct.


Except that it may be running in a different thread and get control in
the middle of the XORs. There are now versions of the collector that
support most of the common thread packages. The collector only runs
during allocation calls, but other threads can be anywhere.


(I could also point out that there are probably cases in which the
xor's could get split across a procedure call for scheduling reasons.
But that wouldn't give me a chance to advertise the thread ports of my
collector :-))


Note that this doesn't absolutely prohibit use of the above sequence.
But it should only be used if either:


1) Neither register contains a pointer, or


2) Equivalent pointers are known to also be stored elsewhere, e.g. in
memory.


--
Hans-Juergen Boehm
boehm@sgi.com
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.