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

wilson@cs.utexas.edu (Paul Wilson)
12 May 1997 00:24:44 -0400

          From comp.compilers

Related articles
[2 earlier articles]
how to generate code for (a,b):=(b,a) Dave@occl-cam.demon.co.uk (Dave Lloyd) (1997-05-08)
Re: how to generate code for (a,b):=(b,a) bart@time.cirl.uoregon.edu (1997-05-08)
Re: how to generate code for (a,b):=(b,a) Robert.Harley@inria.fr (1997-05-08)
Re: how to generate code for (a,b):=(b,a) dlmoore@ix.netcom.com (David L Moore) (1997-05-08)
Re: how to generate code for (a,b):=(b,a) preston@cs.rice.edu (1997-05-08)
Re: how to generate code for (a,b):=(b,a) cliffc@risc.sps.mot.com (Cliff Click) (1997-05-12)
Re: how to generate code for (a,b):=(b,a) wilson@cs.utexas.edu (1997-05-12)
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)
[10 later articles]
| List of all articles for this month |
From: wilson@cs.utexas.edu (Paul Wilson)
Newsgroups: comp.compilers
Date: 12 May 1997 00:24:44 -0400
Organization: CS Dept, University of Texas at Austin
References: 97-05-058 97-05-129
Keywords: optimize, code, GC

David L Moore <dlmoore@ix.netcom.com> wrote:
>Anton Ertl wrote:
>
>[Exchange contents of several registers quickly]
>
>When you don't have any free registers, it should be possible to achieve
>the same result with a series of xors instead of moves. For example, two
>registers can be exchanged with the sequence:
> xor a,b
> xor b,a
> xor a,b


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.


Hans Boehm et al. have gone to a lot of trouble to make it practical
to garbage collect languages that weren't designed for GC. (Please
provide a flag to turn off pointer-mangling optimizations. A
conservative GC can handle common forms of pointer arithmetic, but if
you split a pointer into two pieces, or xor it so that it doesn't
point anywhere near the actual object, horrible bugs can happen. (In
either case, if the original pointer is somewhere on the stack or in
registers, it's okay, but if the only pointer to a live object is
mangled beyond recognition, conservative GC's will fail.)


--
| Paul R. Wilson, Comp. Sci. Dept., U of Texas @ Austin (wilson@cs.utexas.edu)
| Papers on memory allocators, garbage collection, memory hierarchies,
| persistence and Scheme interpreters and compilers available via ftp from
| ftp.cs.utexas.edu, in pub/garbage (or http://www.cs.utexas.edu/users/wilson/)
--


Post a followup to this message

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