From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Guile 3 update, August edition Date: Mon, 20 Aug 2018 16:27:26 +0200 Message-ID: <87k1olazap.fsf@pobox.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1534775231 16330 195.159.176.226 (20 Aug 2018 14:27:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 20 Aug 2018 14:27:11 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Aug 20 16:27:07 2018 Return-path: Envelope-to: guile-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 1frl97-00044h-Pn for guile-devel@m.gmane.org; Mon, 20 Aug 2018 16:27:07 +0200 Original-Received: from localhost ([::1]:47406 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frlBE-0002ev-AH for guile-devel@m.gmane.org; Mon, 20 Aug 2018 10:29:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frl9v-0001gq-25 for guile-devel@gnu.org; Mon, 20 Aug 2018 10:27:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frl9r-0002Ry-Qk for guile-devel@gnu.org; Mon, 20 Aug 2018 10:27:55 -0400 Original-Received: from fanzine.igalia.com ([91.117.99.155]:54668) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frl9r-0002Q3-F6 for guile-devel@gnu.org; Mon, 20 Aug 2018 10:27:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From; bh=v6PjFKdV/Fo/rdjAyckPKop+i/P0YwHAw0rhhB9uRBU=; b=KBI3PPHs9JNBs2ch6tbMVpU+4Nl/mBp8ugBu8gsEmQMkzKrojfJSznDJi3Mj1FBPRJlw9L9/FYGwnHLqa2jA1dG6nZlKAmeEdH8h/xdN9iUxFew7lyt3v5Tt4KdD3jadJdpn5urtUae5sUgRFKN4k1kxeTKQ2olP+qT+G4kCpIVHFeyoiDnpcyKifBlECH4MkEc+9JxtAUHIwjV5qS1kaFa1m5opedCBtHJpkUqy5hWd8zsFVO8RyU45z24MwwDYgzQSIcxt6fFy3OmN9nXo1G6WTCumpX1ogCREXCAd5m3Z9jEe7v5XCfE4FZ7FnaF9JONAOW6vX0iFIAhQHSnm+w==; Original-Received: from cha74-2-88-160-190-192.fbx.proxad.net ([88.160.190.192] helo=sparrow) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim) id 1frl9o-0001T8-8T for ; Mon, 20 Aug 2018 16:27:49 +0200 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19623 Archived-At: Hi! Last dispatch was here: https://lists.gnu.org/archive/html/guile-devel/2018-07/msg00037.html To recap, I merged in GNU lightning and added an extra machine-code return address to frames, but hadn't actually written the JIT yet. Since July, I made it so that all Guile bytecode function entry points start with an "instrument-entry" bytecode that holds a counter. The intention is that when the counter increments beyond a certain value, the function should be automatically JIT-compiled. Associated with the counter is a native-code pointer corresponding to the function. I also added "instrument-loop" bytecodes to all loops, to be able to tier up from within hot loops. With all of this done and some other bytecode tweaks, I was able to move on to the JIT compiler itself. I'm happy to say that I now have a first version. It's about 3500 lines of C, so a bit gnarly. It's architecture-independent, as it uses lightning, and there are lightning backends for about every architecture. Lightning seems OK. Not optimal, but OK, and an OK thing to use for now anyway. I did have to write special cases for 32-bit machines, as Guile's VM supports 64-bit arithmetic, and some-endian-specific code. I probably got some of that wrong; review is very welcome: https://git.savannah.gnu.org/cgit/guile.git/tree/libguile/jit.c?h=lightning If you have fixes and are a committer, please feel free to just commit them directly. If you aren't a committer yet and you spot some fixes, mail the list; you should definitely be a committer if you can do that :) I just got the JIT working today. For the time being, the interface is a public function, %jit-compile. Eventually I will remove this when I have more confidence, relying only on the automatic compilation triggered by function entry and loop iterations. As an example: $ cat foo.scm (use-modules (rnrs bytevectors)) (define (f32v-sum bv) (let lp ((n 0) (sum 0.0)) (if (< n (bytevector-length bv)) (lp (+ n 4) (+ sum (bytevector-ieee-single-native-ref bv n))) sum))) (define ones (make-f32vector #e1e7 1.0)) # The JIT currently doesn't emit hook code. $ meta/guile --no-debug scheme@(guile-user)> (load "foo.scm") scheme@(guile-user)> ,time (f32v-sum ones) $2 = 1.0e7 ;; 0.143017s real time, 0.142986s run time. 0.000000s spent in GC. scheme@(guile-user)> (%jit-compile f32v-sum) scheme@(guile-user)> ,time (f32v-sum ones) $3 = 1.0e7 ;; 0.048514s real time, 0.048499s run time. 0.000000s spent in GC. In this particular example, the JITted code runs about 3x faster than the interpreted code. The JIT doesn't do register allocation; not sure precisely how to do that. A future topic. For the moment I want to consolidate what we have and once it's all just magically working and everybody's programs are faster, we release Guile 3. Cheers, Andy