From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nala Ginrut Newsgroups: gmane.lisp.guile.devel Subject: Re: A vm for native code in guile Date: Mon, 14 Jan 2013 10:51:46 +0800 Organization: HFG Message-ID: <1358131906.23443.129.camel@Renee-desktop.suse> References: <87obnxreq5.fsf@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1358131925 25302 80.91.229.3 (14 Jan 2013 02:52:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 14 Jan 2013 02:52:05 +0000 (UTC) Cc: Andy Wingo , guile-devel To: Stefan Israelsson Tampe Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Jan 14 03:52:22 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tua9s-0004nk-QR for guile-devel@m.gmane.org; Mon, 14 Jan 2013 03:52:21 +0100 Original-Received: from localhost ([::1]:60202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tua9c-0006RC-Nt for guile-devel@m.gmane.org; Sun, 13 Jan 2013 21:52:04 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:59491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tua9X-0006R6-Co for guile-devel@gnu.org; Sun, 13 Jan 2013 21:52:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tua9R-0001Th-F4 for guile-devel@gnu.org; Sun, 13 Jan 2013 21:51:59 -0500 Original-Received: from mail-da0-f47.google.com ([209.85.210.47]:48090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tua9R-0001Tc-85 for guile-devel@gnu.org; Sun, 13 Jan 2013 21:51:53 -0500 Original-Received: by mail-da0-f47.google.com with SMTP id s35so1592228dak.6 for ; Sun, 13 Jan 2013 18:51:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:subject:from:to:cc:date:in-reply-to :references:organization:content-type:x-mailer:mime-version :content-transfer-encoding; bh=FbGCjw+YKB0bwvpa2RWtSJX1E4C7nNUVjskzvXslMrY=; b=iENGYV9+XlhbIh+YgHHcGibxTl4aPc2T8T4EMcWoFNiIr5u0S9awa5pFMaWJOIGvnd nFB+jeZTbblcp/azqxeM3Hj0b8g90/8Bkt0IpF/6PLXDk1Rf0JE+6uu8rTOxba0Uil1Z 0RMV/da7qzqts37ytSV8bUo76K+BRmgpom3Xwe2oGhxy4RkFrFjLhv5TTMnlu98v88Co LSBqrn1o/yZirpy67bHwxYsRFqw8vrQxeuZ9qmWtnLG/bvdEm4Fi3pE7cYZpPHPVf9ct 7ThAFF1tmbdlllz5NanV7jpN3WqArI/Em9qHP/PXHNd1ACcukRHjskJ44RbwCeYbD0xL 700g== X-Received: by 10.68.231.40 with SMTP id td8mr56160781pbc.48.1358131912348; Sun, 13 Jan 2013 18:51:52 -0800 (PST) Original-Received: from [147.2.147.112] ([61.14.130.226]) by mx.google.com with ESMTPS id s5sm7802491pay.31.2013.01.13.18.51.48 (version=SSLv3 cipher=RC4-SHA bits=128/128); Sun, 13 Jan 2013 18:51:50 -0800 (PST) In-Reply-To: X-Mailer: Evolution 3.4.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.210.47 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:15417 Archived-At: On Wed, 2012-08-01 at 22:59 +0200, Stefan Israelsson Tampe wrote: > Hi, > > The byte-code -> native-code compiler is does serve my needs pretty well > now. It should really > soon be possible to add code that will auto compile bytecode versions to > native versions. The compiler is not perfect and some instructions is > missing. But it can go from VM->NATIVE->VM and so on so whenever there is > missing instruction the compiler can bail out to vm code. What's left is > to be able to go from VM to Native returning multiple values and in all > call positions. > > To note > > * the code is for x86-64, linux. > > * Windows have another calling convention => the assembler has to be recoded > => we need compilers for all interesting combinations of operating > systems and native targets > > * Using the C-stack is nice because the native push and pop instructions > can be used as well as > brk-ings makes for automatic stack growth? also calling out c functions > can be fast. On the > other hand stack traces is defunct with this code and I'm uncertain how > the prompting will > cope with this feature. It's probably better to use a separate stack for > the native code and model > it like the wip-rtl stack. On the other hand it has been convenient to > use it as a stack to save > variables before calling out to helper c-functions, but these helper > functions usually is on the slow > path and the savings can be done using helper registers that is local to > the vm a little bit slower > but doable. Not sure what path to take here. > > * Writing assembler is really tough. Because debugging is really difficult. > IMO, we don't have to write assembler again, since GNU Binutils does. The only necessary work is to map bytecode->asm, and add a AOT option with a script into 'guild' for calling Binutils. We may borrow some work from GCC. I don't know if it's easy, but GCC uses Lisp-like thing to handle machine-description. Though it could be interesting, it's a lot of work todo. Then it could support many platforms rather than x86. > * To ease things I compiled C code and examined the assembler => fragile > and difficult to port the > code. The final version needs to put more effort into probing for > constants used in the generated > assembler. > > * x86 code is pretty different because of the low number of registers and > invariant registers over c-call's > > * prompt and aborts are tricky instructions! > > Example: > as an example reducing a list of 1000 elements with a function that is > basically + a 4x increase in performance when compiling to native code > could be seen. This are typical figures for what one can expect to improve > in speed. A smarter usage of registers and less poping and pushing (RTL) > could mean that we can increase the speedup from stable-2.0 even further. > > > I will next week start working on the RTL branch porting the current setup > but use the rtl stack in stead of the native C stack. > > Regards > /Stefan