Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!think.com!barmar From: barmar@think.com (Barry Margolin) Newsgroups: comp.lang.lisp Subject: Re: avoiding the retention of trash Message-ID: <1991Jun13.210829.8799@Think.COM> Date: 13 Jun 91 21:08:29 GMT References: Sender: news@Think.COM Reply-To: barmar@think.com Distribution: comp Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 26 In article kers@hplb.hpl.hp.com (Chris Dollin) writes: >[c] Shortly after a local becomes unused (ie, there are no further references >to it), zap it (unnecessary if the compiler can prove it's not a heap value). >In the limit, zap them all at exit. Cost: much like [1], but possibly easier to >optimise. Loops are still a problem. This is a bit more work, but seems like the best solution to me. It solves not only this particular problem, but also the problem of retained garbage in active procedures. For instance, consider the following: (let* ((big-temp (compute-big-thing)) (little-temp (f big-temp))) ;; body only uses little-temp ) Once you put this type of variable lifetime analysis into the compiler, it can be used for other things as well. For instance, in the above code, the same stack location could actually be used for both big-temp and little-temp, because their lifetimes don't overlap. Big-temp's value would be zapped automatically when you store into little-temp (a peephole optimizer could remove the redundant store of nil, if necessary). -- Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar