From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Raeburn Newsgroups: gmane.emacs.devel Subject: Re: advice needed for multi-threading patch Date: Wed, 26 Aug 2009 03:06:38 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1251270440 28470 80.91.229.12 (26 Aug 2009 07:07:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 26 Aug 2009 07:07:20 +0000 (UTC) Cc: Emacs development discussions To: Tom Tromey Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 26 09:07:13 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MgCbA-00054N-Ke for ged-emacs-devel@m.gmane.org; Wed, 26 Aug 2009 09:07:12 +0200 Original-Received: from localhost ([127.0.0.1]:46234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgCb9-0007T9-SO for ged-emacs-devel@m.gmane.org; Wed, 26 Aug 2009 03:07:11 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MgCb3-0007T4-Bj for emacs-devel@gnu.org; Wed, 26 Aug 2009 03:07:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MgCay-0007RU-4T for emacs-devel@gnu.org; Wed, 26 Aug 2009 03:07:04 -0400 Original-Received: from [199.232.76.173] (port=58847 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgCax-0007RR-Vd for emacs-devel@gnu.org; Wed, 26 Aug 2009 03:07:00 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:3624) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MgCax-0000u3-9H for emacs-devel@gnu.org; Wed, 26 Aug 2009 03:06:59 -0400 Original-Received: from splat.raeburn.org ([69.25.196.39] helo=raeburn.org) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MgCah-0008TI-Lf for emacs-devel@gnu.org; Wed, 26 Aug 2009 03:06:55 -0400 Original-Received: from [10.0.0.172] (squish.raeburn.org [10.0.0.172]) by raeburn.org (8.14.3/8.14.1) with ESMTP id n7Q76ccw022787; Wed, 26 Aug 2009 03:06:38 -0400 (EDT) In-Reply-To: X-Mailer: Apple Mail (2.936) X-Detected-Operating-System: by mx20.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:114607 Archived-At: On Aug 26, 2009, at 00:38, Tom Tromey wrote: > In particular I've (initially) implemented cooperative multi- > threading. Interesting! (BTW, my guile-emacs work is also coming along slowly [1], and Guile supports multithreading, though my current variable-binding support isn't thread-safe. OTOH, Daniel Kraft has been working on loading/ compiling basic elisp in Guile, with thread-safe dynamic bindings. We've got some work to do to make these development projects converge though. I hope you and Daniel and I aren't doing redundant work.) > I managed to handle the V* global variables by writing some elisp that > changed every declaration of a variable mentioned in a DEFVAR_LISP > [....] I've written similar elisp code for doing transformations of patterns within the Emacs code -- mostly more localized things like "XCONS (expr)->car" to "XCAR (expr)", but with support for somewhat complex values of "expr" that have to have balanced parens, etc. I wonder if anyone's looking at collecting elisp tools for C refactoring somewhere. > This was pretty simple and non-intrusive, in the sense that it is > totally automated, so I can easily reapply it as Emacs changes. Same here. It can *look* very intrusive, even pervasive, when the uses are scattered around the source tree, but simple transforms like this aren't as scary as they might look to someone who doesn't recognize what's happening. > ... which brings me to my problem. I'd also like to apply a similar > treatment to buffer-local variables. However, those do not have > convenient accessor macros, and before starting the laborious task of > wrapping all buffer field accesses, I thought I'd ask for advice. Is > this a sane way to proceed? Should I do something different? Could I > get such a patch in before the rest of this work, just to make my > local > divergence smaller? Should I take this to mean you've already dealt with the buffer-local variables created by make-variable-buffer-local, which don't live in the buffer structure? If so, I wonder if you can make use of those changes, by replacing XBUFFER(b)->thing with SYMBOL_VALUE(Qthing) where Qthing holds a symbol that's marked as buffer-local; then all the changes for the interaction between thread-local and buffer-local bindings would be localized in indirect_variable and friends, which would then have to deal with both Lisp_Misc_Buffer_Objfwd and Lisp_Misc_Buffer_Local_Value. The Guile work I'm doing would also probably benefit from such changes, down the road. (One change I'm looking at in my Guile work is changing indirect_variable to accept and return Lisp_Objects instead of struct Lisp_Symbol pointers, for better GC safety. I doubt such a change would significantly affect your work, though it may touch on overlapping bits of code.) Ken [1] http://lists.gnu.org/archive/html/guile-devel/2009-08/ msg00163.html ; I also have a sort of "project page" I wrote up a while back, but it's not quite current.