From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.devel Subject: Re: Emacs Lisp JIT Compiler Date: Mon, 5 Dec 2016 11:32:19 -0800 Message-ID: <3ca57bfc-72db-65ee-b7c4-4bf75a64c495@dancol.org> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1480966363 13102 195.159.176.226 (5 Dec 2016 19:32:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 5 Dec 2016 19:32:43 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 To: Burton Samograd , Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 05 20:32:38 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cDz09-0002UF-Ft for ged-emacs-devel@m.gmane.org; Mon, 05 Dec 2016 20:32:37 +0100 Original-Received: from localhost ([::1]:44025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDz0D-0003QL-CC for ged-emacs-devel@m.gmane.org; Mon, 05 Dec 2016 14:32:41 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDz06-0003Q4-IQ for emacs-devel@gnu.org; Mon, 05 Dec 2016 14:32:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cDz03-00037H-BZ for emacs-devel@gnu.org; Mon, 05 Dec 2016 14:32:34 -0500 Original-Received: from dancol.org ([2600:3c01::f03c:91ff:fedf:adf3]:49152) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cDz02-000377-Uc for emacs-devel@gnu.org; Mon, 05 Dec 2016 14:32:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:To:Subject; bh=5oOoHULSGXOnEzPzQHXBGtam2csz8ufhYGwFFnWgA4Y=; b=LDoDLhs4qV4udMmIxjvbfhD9bZTkybbCu526e71QkxdrBqtI1t+cCrnAgVqY2vQySiv4cSqTLg/aAc0N7ovAA8fCvP5pbpxZ2m3lF5kKEAoTW0UeXb7fPJ4CKFbkoLI4mjVRL0VWeDhb4XBbvGZ05lgo63jEi7/PKLt1p4URv38hTBF1Yb5SqZBUuCIuU3j4lSGD0Ek8ydhzjxrZI1m90b8oblP2UpqYVnjmKFp5K+hqKGHltGRAdD+tlvto7mlRWMmLVxizXVvECXw/HjM+Ngcwi7Wli+FnWfFQT/oU94+v3+HilY6spOdRqHUclQe47NQVeQRiArsJD3NhZlVyWQ==; Original-Received: from [104.132.51.109] (helo=[192.168.152.77]) by dancol.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1cDz00-0007UV-Ah; Mon, 05 Dec 2016 11:32:28 -0800 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2600:3c01::f03c:91ff:fedf:adf3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:210083 Archived-At: Thanks for doing this work. On 12/05/2016 10:16 AM, Burton Samograd wrote: > Hello, > > I’ve published my Emacs Lisp JIT compiler for comments and review: > > https://github.com/burtonsamograd/emacs-jit > > The JIT compiler implements a strategy of turning the byte code > execution loop into a series of function calls, moving the overhead of > the loop into the CPU execution unit. I call this ‘compiling down the > spine’ of the byte code vector. No other changes have been done to the > byte code instructions other than to map them to the new execution strategy. > > This is work in progress and about ~90% complete and was done about 4 > years ago, so it’s quite a bit off of HEAD right now. It ‘works’ to the > point of being able to JIT compile and run my included ray-tracer with a > 25% speed improvement. Enabling full JIT during compilation shows bugs > and will fail; I haven’t been able to track down the cause of these > failures yet. Let's benchmark it after making sure it's correct. > By default, this build will provide the Lisp function 'jit-compile’ > which takes a lambda expression or a symbol. > > A new byte code instruction has been added Bjitcall. When a function is > JIT compiled, it’s code vector is replaced by the single Bjitcall > instruction followed by the JIT compiled code block. I'm hesitant to call this work a "JIT compiler", since it's not doing any "compilation" --- CFG construction, register allocation, machine-code generation. we're still executing the same bits of the interpreter code ---- just reaching them more efficiency. (It's a step in that direction though.) Since each function pointer (four or eight bytes) is much larger than the corresponding bytecode instruction, for cache efficiency reasons, I'd apply this optimization only to hot functions. Four years ago, GCC's JIT API was unavailable. I suggest taking a close look at it. It will deliver far greater speedups to computation than the techniques in this work can, and it's much lower-maintenance to boot. BTW: we don't use C99 dynamic arrays in Emacs.