From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Matthew Mundell Newsgroups: gmane.emacs.devel Subject: Re: Compilation to native Date: 20 Mar 2004 21:52:51 +0000 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87n06bp4ng.fsf@sno.mundell.ukfsn.org> References: <87eks0654s.fsf@sno.mundell.ukfsn.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1079819720 18064 80.91.224.253 (20 Mar 2004 21:55:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 20 Mar 2004 21:55:20 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sat Mar 20 22:55:15 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1B4oR1-0005S4-00 for ; Sat, 20 Mar 2004 22:55:15 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1B4oR1-0008LQ-00 for ; Sat, 20 Mar 2004 22:55:15 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B4oPq-00047l-My for emacs-devel@quimby.gnus.org; Sat, 20 Mar 2004 16:54:02 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1B4oPO-00045x-1c for emacs-devel@gnu.org; Sat, 20 Mar 2004 16:53:34 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1B4oOp-0003mg-Ga for emacs-devel@gnu.org; Sat, 20 Mar 2004 16:53:30 -0500 Original-Received: from [217.158.120.143] (helo=mail.ukfsn.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B4oOo-0003l3-Ow for emacs-devel@gnu.org; Sat, 20 Mar 2004 16:52:58 -0500 Original-Received: from localhost (lucy.ukfsn.org [127.0.0.1]) by mail.ukfsn.org (Postfix) with ESMTP id 6A096E6D5B for ; Sat, 20 Mar 2004 21:52:44 +0000 (GMT) Original-Received: from mail.ukfsn.org ([127.0.0.1]) by localhost (lucy.ukfsn.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 03195-01 for ; Sat, 20 Mar 2004 21:52:44 +0000 (GMT) Original-Received: from sno.mundell.ukfsn.org (dsl213-218-238-16.as15444.net [213.218.238.16]) by mail.ukfsn.org (Postfix) with ESMTP id 0D950E6D4E for ; Sat, 20 Mar 2004 21:52:44 +0000 (GMT) Original-Received: from sno.mundell.ukfsn.org ([10.0.0.3]) by sno.mundell.ukfsn.org with esmtp (Exim 3.36 #1 (Debian)) id 1B4oOh-0000uZ-00 for ; Sat, 20 Mar 2004 21:52:52 +0000 Original-To: emacs-devel User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Original-Lines: 57 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:20653 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:20653 Matthew Mundell writes: > >From etc/TODO: > > * Investigate using GNU Lightning or similar system for incremental > compilation of selected bytecode functions to subrs. Converting CCL > programs to native code is probably the first thing to try, though. > > Is there any work towards this? Well, I have a start at generating native code from byte code at run time, and invoking the code produced. It uses the GNU Lightning macros. The generation is done in a modified copy of Fbyte_code, called Fnative_compile_byte_code, by generating the code for each byte code operation instead of performing the operation. Enough is implemented to run the example function from the "Speed of Byte-Code" node in the Elisp manual. The function is: (defun silly-loop (n) "Return time before and after N iterations of a loop." (let ((t1 (current-time-string))) (while (> (setq n (1- n)) 0)) (list t1 (current-time-string)))) Here is a set of results: (silly-loop 100000000) => ("Sat Feb 28 10:04:39 2004" "Sat Feb 28 10:05:30 2004") ; 51 secs (byte-compile 'silly-loop) (silly-loop 100000000) => ("Sat Feb 28 10:06:37 2004" "Sat Feb 28 10:06:53 2004") ; 16 secs (native-compile 'silly-loop) (silly-loop 100000000) => ("Sat Feb 28 10:17:13 2004" "Sat Feb 28 10:17:22 2004") ; 9 secs The changes come to more than 25000 characters, so they're here: http://www.mundell.ukfsn.org/native/bytecode.c.diff http://www.mundell.ukfsn.org/native/eval.c.diff http://www.mundell.ukfsn.org/native/lisp.h.diff Alternatively, the full files are available: http://www.mundell.ukfsn.org/native/bytecode.c http://www.mundell.ukfsn.org/native/eval.c http://www.mundell.ukfsn.org/native/lisp.h Either way, this file is also required: http://www.mundell.ukfsn.org/native/native.el The changes require NO_UNION_TYPE to be set, USE_LSB_TAG to be clear, and EMACS_INT to be an int. For now a fixed amount of memory is allocated for the generated code. Is this effort good enough to continue?