From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: Re: Compiling Elisp to a native code with a GCC plugin Date: Tue, 14 Sep 2010 15:59:50 -0600 Message-ID: References: <87bp805ecr.fsf@gmail.com> <874ods5ctf.fsf@gmail.com> <877hio3urh.fsf@gmail.com> <87wrqo2ev4.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1284501605 22526 80.91.229.12 (14 Sep 2010 22:00:05 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 14 Sep 2010 22:00:05 +0000 (UTC) Cc: emacs-devel@gnu.org To: Wojciech Meyer Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 15 00:00:03 2010 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.69) (envelope-from ) id 1OvdXm-0001pt-ET for ged-emacs-devel@m.gmane.org; Wed, 15 Sep 2010 00:00:02 +0200 Original-Received: from localhost ([127.0.0.1]:35646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvdXl-0008Rd-Us for ged-emacs-devel@m.gmane.org; Tue, 14 Sep 2010 18:00:01 -0400 Original-Received: from [140.186.70.92] (port=32957 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvdXf-0008RY-Sq for emacs-devel@gnu.org; Tue, 14 Sep 2010 17:59:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OvdXe-00032S-O5 for emacs-devel@gnu.org; Tue, 14 Sep 2010 17:59:55 -0400 Original-Received: from mx1.redhat.com ([209.132.183.28]:45054) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvdXe-00032G-Fa for emacs-devel@gnu.org; Tue, 14 Sep 2010 17:59:54 -0400 Original-Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8ELxqY2012417 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 14 Sep 2010 17:59:53 -0400 Original-Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8ELxqZL017678; Tue, 14 Sep 2010 17:59:52 -0400 Original-Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o8ELxppI022226; Tue, 14 Sep 2010 17:59:51 -0400 Original-Received: by opsy.redhat.com (Postfix, from userid 500) id 25F853784BE; Tue, 14 Sep 2010 15:59:51 -0600 (MDT) X-Attribution: Tom In-Reply-To: <87wrqo2ev4.fsf@gmail.com> (Wojciech Meyer's message of "Tue, 14 Sep 2010 22:29:35 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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:130156 Archived-At: >>>>> "Wojciech" == Wojciech Meyer writes: Tom> So, lots of grunge work, just to get the point where you could start Tom> actually working on the GC. I would look at automated rewriting to Tom> make this work -- that worked out great on the concurrent branch. Wojciech> Maybe that work should be actually done even without thinking Wojciech> currently about GC. AFAIR MT Emacs rewriting was in Elisp, Wojciech> ideally maybe using GCC would be better at some point. You would have to hack GCC a little bit, because most of the code locations you want to change arise from macro expansion, and GCC does not keep all that information. (Though there's a WIP patch for this.) Maybe it could be done more simply using a simple parser in elisp that recognizes just the needed forms. Or maybe something based on clang. This would get you most of the way there, though there are still some bad things you have to fix up by hand. For the concurrency stuff, we did two kinds of automated rewriting. One was just pure elisp that searched the .c for DEFVAR_LISP and then made various changes. The other one modified the source (in a compile-breaking way), then ran the compiler, then visited each error to perform a rewrite. This approach might also work for the GC problem, I am not certain. These scripts are both in src/ on the concurrency branch. One problem with any compiler-based approach is that it only works on the sources it sees. That is, the not-taken #if branches won't get rewritten. This argues for trying some kind of custom parser. Another problem we ran into is that this approach doesn't work if the problem code itself appears in a macro. There were a few spots that we had to fix by hand -- no big deal, the automation is still worthwhile even if it only does 85% of the work. My advice is to try to do this bulk rewriting work on head, so that it doesn't rot. I think that's been a problem for the concurrency work :-( Tom