From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: GNU Guile branch, stable-2.0, updated. v2.0.2-101-gd851e32 Date: Mon, 26 Sep 2011 13:20:26 +0200 Message-ID: <8762kfy2h1.fsf@pobox.com> References: <87wrcxpz1c.fsf@yeeloong.netris.org> <87d3eo5pk0.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1317036054 26512 80.91.229.12 (26 Sep 2011 11:20:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 26 Sep 2011 11:20:54 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Sep 26 13:20:49 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R89Ev-0002AD-8t for guile-devel@m.gmane.org; Mon, 26 Sep 2011 13:20:49 +0200 Original-Received: from localhost ([::1]:53803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R89Eu-0006ql-Re for guile-devel@m.gmane.org; Mon, 26 Sep 2011 07:20:48 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:35651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R89Er-0006qg-Fw for guile-devel@gnu.org; Mon, 26 Sep 2011 07:20:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R89Eh-0006Xb-T6 for guile-devel@gnu.org; Mon, 26 Sep 2011 07:20:45 -0400 Original-Received: from a-pb-sasl-sd.pobox.com ([74.115.168.62]:42495 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R89Eh-0006XR-QY; Mon, 26 Sep 2011 07:20:35 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 8D5005B14; Mon, 26 Sep 2011 07:20:34 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=99wkIqInd6FB /sJFVDncRQKQdXk=; b=tuLFTOOOJXr/jQNcJ3WoKo38S3mzeX1DrmvPL7ItldH4 lEGm6sBjU+HaYH6s5Rs2XylLBpIcJu4dr12Ka4Zo4re7n6kzWa4NZY1NUS0XZ3Qw oI96h/+FzbdSAMJsrXf4ZdGr+1YDhnOSGVgXQguP+oaBnACOKr8Z5QTvxoW27ok= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=YwnUwA g9dpVFdCBoduqA/rrDupPqn8t/PWbLy078MkhiSpCG6r5MsWZGwkBLP15TDcj00S ZwG2IqLE4ctGz+YYyErgoV/Cf2iyHx3AMzsJDFqzlhXrlk344NX6Ch3qVgfGLTPe qy6++KZ1BMqF9iq/vfR3TF/q/7Pmpgafrzo3I= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 86AF05B13; Mon, 26 Sep 2011 07:20:34 -0400 (EDT) Original-Received: from badger (unknown [90.164.198.39]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id D91155B12; Mon, 26 Sep 2011 07:20:33 -0400 (EDT) In-Reply-To: <87d3eo5pk0.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Sun, 25 Sep 2011 22:34:39 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-Pobox-Relay-ID: 8D277BF6-E831-11E0-BB8E-65B1DE995924-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 74.115.168.62 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:12803 Archived-At: Hello! On Sun 25 Sep 2011 22:34, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Mark H Weaver skribis: > >>> commit d851e32fdc3d14804108f0389faa75a57599ced4 >>> Author: Andy Wingo >>> Date: Fri Sep 23 18:02:05 2011 +0200 >>> >>> prevent propagation for memory-dependent operations like `car' >>>=20=20=20=20=20 >>> * module/language/tree-il/primitives.scm (*primitive-constructors*): >>> Record car, cdr, vector-ref, and struct-ref as "constructors". >>> Comment to come later. >> >> If car, cdr, vector-ref and struct-ref are to be included in this set of >> operations, it seems to me that the set should be renamed to something >> other than "constructors". I think that Ludovic and I were a bit confused about some things, as was evident. Specifically we were confusing identity, constant functions, and pure functions. Regarding identity, `cons' needs to return objects with identity. These expressions expressions are not the same: (define f (let ((pair (cons 1 2))) (lambda () pair))) (define f (lambda () (cons 1 2))) Here we cannot propagate `pair' because then we would break (eq? (f) (f)). It's a question of identity. Now, "constant functions". Quoth GCC: `const' Many functions do not examine any values except their arguments, and have no effects except the return value. Basically this is just slightly more strict class than the `pure' attribute below, since function is not allowed to read global memory. This is the case for `+', for example. If + is applied to constant expressions then it is safe to propagate, because it computes the same value, and doesn't reorder effects: (define g (let ((sum (+ 1 2))) (lambda () sum))) (define g (lambda () (+ 1 2))) And of course this can fold to (lambda () 3). Note, however, that `car' is *not* constant! Its result depends on mutable values, specifically, its argument. For instance: (define h (let* ((pair (cons 1 2)) (one (car pair))) (lambda () one))) (define h (let ((pair (cons 1 2))) (lambda () (car pair)))) Is this a correct transformation? In this case, yes. (If we can prove that this is safe, then it can fold to (lambda () 1).) But in general to do this propagation we need to prove that nothing that can alias `pair' will mutate its value. `car' is pure -- if its argument is indeed a pair, then it has no side effects -- but it is not constant. >> Instead of moving those operations into the *primitive-constructors* >> set, perhaps we should make a new set of primitives called something >> like *primitive-mutable-accessors* ? > > Yes, though it=E2=80=99s not the accessor that=E2=80=99s mutable. :-) > > =E2=80=98mutable-object-returning-primitive=E2=80=99 would be descriptive= but is hard to > read... I think the real concern is not the mutability of the return value, but rather of the arguments. >> Also, if I'm correct in guessing the reason for this change (accessing >> mutable memory), shouldn't the bytevector-*-ref operations go as well? > > No because they return an immutable object. I think we got this wrong, Ludo, and we should probably create some list of pure accessors for mutable data and put bytevector-*-ref in it, for the same reason given above for `h'. WDYT? Andy --=20 http://wingolog.org/