From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Noah Lavine Newsgroups: gmane.lisp.guile.devel Subject: Re: GNU Guile branch, wip-peval-predicates, created. v2.0.5-100-g59c5570 Date: Fri, 13 Apr 2012 11:18:36 -0400 Message-ID: References: <87zkaf4sov.fsf@netris.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1334330331 17210 80.91.229.3 (13 Apr 2012 15:18:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 13 Apr 2012 15:18:51 +0000 (UTC) Cc: Andy Wingo , guile-devel@gnu.org To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Apr 13 17:18:50 2012 Return-path: Envelope-to: guile-devel@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 1SIiGv-0002GF-Ep for guile-devel@m.gmane.org; Fri, 13 Apr 2012 17:18:49 +0200 Original-Received: from localhost ([::1]:56048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIiGu-0006sK-MC for guile-devel@m.gmane.org; Fri, 13 Apr 2012 11:18:48 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIiGr-0006sF-7j for guile-devel@gnu.org; Fri, 13 Apr 2012 11:18:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SIiGl-0004va-Tk for guile-devel@gnu.org; Fri, 13 Apr 2012 11:18:44 -0400 Original-Received: from mail-yw0-f41.google.com ([209.85.213.41]:56172) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIiGl-0004vE-Mm for guile-devel@gnu.org; Fri, 13 Apr 2012 11:18:39 -0400 Original-Received: by yhr47 with SMTP id 47so2019483yhr.0 for ; Fri, 13 Apr 2012 08:18:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=h/npoV39AvnOy1rvzZD/VGIYdtNVyhB3qk8qSN+Be2g=; b=xeAIjnMdwwFDX6soX1dE0o6CWgjU/JdJbAV069++E5PcSZ5unLQLH7iaUF4d1O7LE0 gK1SCxMnMzGNL2bST0ZufjWLi7wrpl6CmpmeJivbx9TLL2dSuH5FtXnSwTjb/fOum96S LpxB+9bmKM58TgT9RsLjKKISwkiyygdAXS9oSyNBbFoI4N4OMruzrfmiNoGcvHirVyl4 5UNtATst84zlEgNTV4GICYoBeYilI07a9pGetRHB1uIUYa1tAS2O9BuwEwiwQwOM2thq e+/a7/SIrYrETe6lhBSDo5Wyt/tQhanmWT8quwhCIq5EChvaJW950p7miwNFT1QWDr99 GSpA== Original-Received: by 10.50.154.169 with SMTP id vp9mr1839403igb.71.1334330316740; Fri, 13 Apr 2012 08:18:36 -0700 (PDT) Original-Received: by 10.42.29.200 with HTTP; Fri, 13 Apr 2012 08:18:36 -0700 (PDT) In-Reply-To: <87zkaf4sov.fsf@netris.org> X-Google-Sender-Auth: y_XqBrjcS7Tas711a0zWoqiwQfE X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.213.41 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:14262 Archived-At: At first I thought you were right. But then I realized there's an even deeper problem here. Imagine implementing a record mutator like this: (define (set-foo-a! foo new-value) (if (is-foo? foo) (%unsafe-set-foo-a! foo new-value) (error))) That code is incorrect, by the same logic you used: something could change the class of foo in between the is-foo? call and the %unsafe-set-foo-a! call. You need some atomic check-and-set operation in order to do this safely. Unfortunately, I don't see a correct way short of some sort of mutex. A mutex for each record would be a lot of overhead, but what about a mutex per class, that has to be acquired to change any instance of the class to or from a different class? Changing a class is a rare enough operation that we should not optimize for it, I think. Also, if we had such a mutex, we could use it to eliminate redundant struct-vtable checks correctly, by acquiring it at the beginning of a function and releasing it at the end. I'm somewhat afraid, however, that the real solution is changing how we deal with parallelism, and that is a much bigger problem. Noah On Fri, Apr 13, 2012 at 10:22 AM, Mark H Weaver wrote: > Hi Andy, > >> commit 59c557056cff1ce6146b4d689eeee922300b6278 >> Author: Andy Wingo >> Date: =A0 Tue Apr 10 15:56:23 2012 -0700 >> >> =A0 =A0 peval: elide redundant predicates; eliminate some common subexpr= essions >> >> =A0 =A0 * module/language/tree-il/peval.scm (fold-constants): Returns #f= instead >> =A0 =A0 =A0 of the expression, as all continuations handle #f themselves= . >> =A0 =A0 =A0 (negate, bailout?, extract-facts, infer, infer-defined?) >> =A0 =A0 =A0 (infer-struct-vtable): New helpers. > > I haven't looked at the code, but it sounds like you are trying to > eliminate redundant 'struct-vtable' checks. =A0Unfortunately, it seems to > me that this cannot be done safely. =A0In practice, the checks look like: > > =A0(eq? (struct-vtable s) ) > > Both of the values being compared here are fetched from mutable > locations. =A0The 'struct-vtable' field is mutable, and is usually = a > top-level variable that is also mutable. =A0Furthermore, both of these > things are mutated in practice when a GOOPS class is redefined, IIUC. > > Am I missing something? > > =A0 =A0Thanks, > =A0 =A0 =A0Mark >