From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "T.V Raman" Newsgroups: gmane.emacs.devel Subject: Re: Emacs Lisp JIT Compiler Date: Mon, 13 Aug 2018 06:50:03 -0700 Message-ID: References: <87va8ej4o1.fsf@tromey.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1534168106 7074 195.159.176.226 (13 Aug 2018 13:48:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 13 Aug 2018 13:48:26 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Tom Tromey Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 13 15:48:22 2018 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 1fpDCn-0001kh-MC for ged-emacs-devel@m.gmane.org; Mon, 13 Aug 2018 15:48:21 +0200 Original-Received: from localhost ([::1]:39720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpDEs-0002DN-7k for ged-emacs-devel@m.gmane.org; Mon, 13 Aug 2018 09:50:30 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpDEb-00025q-Ux for emacs-devel@gnu.org; Mon, 13 Aug 2018 09:50:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fpDEX-0004mE-0a for emacs-devel@gnu.org; Mon, 13 Aug 2018 09:50:14 -0400 Original-Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:33579) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fpDEW-0004lA-P9 for emacs-devel@gnu.org; Mon, 13 Aug 2018 09:50:08 -0400 Original-Received: by mail-pf1-x42e.google.com with SMTP id d4-v6so7698192pfn.0 for ; Mon, 13 Aug 2018 06:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=aVkrXim72sYxtXnLBGpDw7ndmTZIz2FzWg8mNLK1+ug=; b=DDNfx2iUfNrcCuBX7erboMrKEyrfo92Qf1Mqh33bSCeHXb1T/fQkeAaBD0p2K2J/Br YIdx3FjaEBHOhy7a9eSS66kcNm3hcRA5c6nbX0zdenuv5JDadx2moJpOHfHeVIzU9Cpf +Nz6CugJKL4rtG5rpJ5meolkizZzWZqsNJfCtbU9K5FmOvFOZxyubE18wY5EfmknZ2bz 00OJQQfZ0rTD7qgaykhjbUuWkHMa+e7w3f/34mzrj3chumFLtr/RwdU0x2HHir6xQhT9 HoZ2JNn21Jo9qTd9OB2J6WsO4KeriEBZmhjB9LhCLB/gqU8kljpTriWtCdEW5hpA8VD3 VZbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=aVkrXim72sYxtXnLBGpDw7ndmTZIz2FzWg8mNLK1+ug=; b=P3PNEb85lJx1Dsa2X7Le6AtoOvvXvrxYWngVtDdKD1/KGT02PZrQ/e1GurfvuvOgp4 QJEikXD2SluMJbUYtS3bNTRVBIElciPoOxUfIp197k/Z4tYXrXLDh8Lf7PzFfcTRiP+G Apd8boksljFPzWubNnkePyyO+bgJf+Hr3TxGwXS0OWoto5qa9ya7fSSyJTDx8jq2ftcJ Vy+UUodLwBiPA8fUsYyQXlwn5KZqDBpdbxEInNs07PiiX5FRc8m0Sneb5J0P7GizihQM ox2MlV4/JtKSG8yynIyEI18c6l0o06FD5HA1brF6iZ0ucuiXyGpD1nju/r//om2pYCxp QCeQ== X-Gm-Message-State: AOUpUlENyA5k7TDRuU/yqfzmHED2RRsj2wFtwOIedRUUV6E8zhloKWP4 0zQSPObm7tZ65J4pIuU40CDA0w== X-Google-Smtp-Source: AA+uWPzSDCQEmDr4JxYen62n2PqsonA3MnIiOSx0SZcchOiULND0KfMq3Vf8YYN5YDqVbS8auxJMdg== X-Received: by 2002:a62:9ed1:: with SMTP id f78-v6mr19198406pfk.35.1534168206763; Mon, 13 Aug 2018 06:50:06 -0700 (PDT) Original-Received: from raman-glaptop ([107.84.156.214]) by smtp.gmail.com with ESMTPSA id i192-v6sm25263630pfe.188.2018.08.13.06.50.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Aug 2018 06:50:04 -0700 (PDT) In-Reply-To: <87va8ej4o1.fsf@tromey.com> (Tom Tromey's message of "Sun, 12 Aug 2018 22:01:34 -0600") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::42e 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:228477 Archived-At: Tom Tromey writes: Will it work with adviced functions?> Hi. I've written a JIT compiler for Emacs Lisp, and I'd like to check > it in. > > This JIT is based on GNU libjit, like some other attempts that have come > before it. However, this one is somewhat faster than those, primarily > because it does all stack manipulations at compile time, not runtime. > > In some simple benchmarks, it is about 3x faster than the bytecode > interpreter. > > I have only tested this on x86-64. Whether or not the JIT works on a > given platform is primarily up to libjit. (I suspect the JIT won't work > on x86 with --with-wide-int; but that is something I could fix.) > > I currently have the JIT set up to always compile all eligible functions > (that is, just byte-compiled, lexically-bound functions). It's robust > enough that, as far as I can tell, everything works fine in this mode. > It would be possible to have it be a bit lazier, say only compile after > 100 invocations, or something like that. > > Aside from the possible --with-wide-int thing, there are two bugs I know > of. > > First, libjit never frees functions. So, if a function is JIT-compiled > and then redefined, the old JIT code will linger. It's possible to fix > this with a custom allocator and a libjit patch (that I sent but that > hasn't been checked in yet). > > Second, I haven't gotten around to emulating the "quitcounter" behavior > in the bytecode interpreter. This seems straightforward. > > > This version of the compiler is pretty basic. It just compiles each > bytecode to more or less the obvious thing. I have some plans to make > the calling convention a bit less expensive, and to allow for inlining. > > Note that this change does not involve any semantic changes to Emacs Lisp. > Also, if libjit is unavailable, the JIT is simply disabled. > > Tom > --