From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Price Newsgroups: gmane.lisp.guile.bugs Subject: bug#15533: optimizing away noticeable effects Date: Tue, 08 Oct 2013 18:13:05 +0100 Message-ID: <8738obd6u6.fsf@Kagami.home> References: <87bo33cybo.fsf@Kagami.home> <87ioxba2el.fsf@netris.org> <87eh7za1ko.fsf@netris.org> <871u3yaoor.fsf@netris.org> <87siwe97gy.fsf@netris.org> <877gdpc96f.fsf@Kagami.home> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1381252452 21081 80.91.229.3 (8 Oct 2013 17:14:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 8 Oct 2013 17:14:12 +0000 (UTC) Cc: 15533@debbugs.gnu.org To: Mark H Weaver Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Oct 08 19:14:16 2013 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VTarQ-0003xW-Fe for guile-bugs@m.gmane.org; Tue, 08 Oct 2013 19:14:16 +0200 Original-Received: from localhost ([::1]:38023 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTarP-0004ID-JF for guile-bugs@m.gmane.org; Tue, 08 Oct 2013 13:14:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTarH-0004I3-LF for bug-guile@gnu.org; Tue, 08 Oct 2013 13:14:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTarC-00064R-Rc for bug-guile@gnu.org; Tue, 08 Oct 2013 13:14:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTarC-00064L-NC for bug-guile@gnu.org; Tue, 08 Oct 2013 13:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VTarC-0002Hy-7O for bug-guile@gnu.org; Tue, 08 Oct 2013 13:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ian Price Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 08 Oct 2013 17:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15533 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 15533-submit@debbugs.gnu.org id=B15533.13812523978730 (code B ref 15533); Tue, 08 Oct 2013 17:14:02 +0000 Original-Received: (at 15533) by debbugs.gnu.org; 8 Oct 2013 17:13:17 +0000 Original-Received: from localhost ([127.0.0.1]:35321 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VTaqS-0002Gj-HX for submit@debbugs.gnu.org; Tue, 08 Oct 2013 13:13:17 -0400 Original-Received: from mail-wi0-f177.google.com ([209.85.212.177]:51008) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VTaqP-0002Ga-MR for 15533@debbugs.gnu.org; Tue, 08 Oct 2013 13:13:14 -0400 Original-Received: by mail-wi0-f177.google.com with SMTP id hq15so1162743wib.10 for <15533@debbugs.gnu.org>; Tue, 08 Oct 2013 10:13:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=REOFLzZ/Chij3M8jI5IHjVFTko0rG3XXTvCsGleCqiA=; b=tewd+g14xmbQezkpMHeNOhSYUkSx06Ie9wIKFVKNqc1ZjqSFnXahDxHu9VMGo1Y6ia 4PPMagPeb6fi4ZpvYIg8OLD0q+v4i9Xd5eJZC3jO7tGU9hbOE8k6qmA4/Oous+/ytUpp jnclOIC48mtPDVv4pVyVjbaxEGVtQVYw86vCU+sC6qbemw7mSFPbWowXwJ2mJuX+sZ5M o8hsnLCoShS5BaXOK20+g8Ca2PM11/W/1TqiCkewRyOQY11vq68Gt99qajUvp3Hb2HKm DluZOMCHA0nHcNOF3rZoerZIKguXTWzoseUpFl+BHIPkHb0XjfKZJ180fDq2/5VNXFGA D9SQ== X-Received: by 10.180.12.45 with SMTP id v13mr24339758wib.57.1381252392866; Tue, 08 Oct 2013 10:13:12 -0700 (PDT) Original-Received: from Kagami.home (host86-132-92-201.range86-132.btcentralplus.com. [86.132.92.201]) by mx.google.com with ESMTPSA id e1sm6990023wij.6.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 08 Oct 2013 10:13:11 -0700 (PDT) In-Reply-To: <877gdpc96f.fsf@Kagami.home> (Ian Price's message of "Mon, 07 Oct 2013 17:55:36 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7300 Archived-At: Ian Price writes: > Does it make sense to add it to find-definition? or should we add it > before the use in that case? I've decided that it does, and I've made the following (tentative) change on my own guile install. (cond ((lookup (lexical-ref-gensym x)) => (lambda (op) - (let ((y (or (operand-residual-value op) - (visit-operand op counter 'value 10 10) - (operand-source op)))) - (cond - ((and (lexical-ref? y) - (= (lexical-refcount (lexical-ref-gensym x)) 1)) - ;; X is a simple alias for Y. Recurse, regardless of - ;; the number of aliases we were expecting. - (find-definition y n-aliases)) - ((= (lexical-refcount (lexical-ref-gensym x)) n-aliases) - ;; We found a definition that is aliased the right - ;; number of times. We still recurse in case it is a - ;; lexical. - (values (find-definition y 1) - op)) - (else - ;; We can't account for our aliases. - (values #f #f)))))) + (if (var-set? (operand-var op)) + (values #f #f) + + ;; var-set? (operand-var ) => #f #f ? + (let ((y (or (operand-residual-value op) + (visit-operand op counter 'value 10 10) + (operand-source op)))) + (cond + ((and (lexical-ref? y) + (= (lexical-refcount (lexical-ref-gensym x)) 1)) + ;; X is a simple alias for Y. Recurse, regardless of + ;; the number of aliases we were expecting. + (find-definition y n-aliases)) + ((= (lexical-refcount (lexical-ref-gensym x)) n-aliases) + ;; We found a definition that is aliased the right + ;; number of times. We still recurse in case it is a + ;; lexical. + (values (find-definition y 1) + op)) + (else + ;; We can't account for our aliases. + (values #f #f))))))) It's a little invasive because of the 'if', but the meat of it is + (if (var-set? (operand-var op)) + (values #f #f) The check for mutability needs to come before the let, since that's where we do the lookup for a value, so it would be too late. If Andy is happy with this change, I'll add a test, and push a commit, but I'm going leave it to his discretion. -- Ian Price -- shift-reset.com "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled"