From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: Native Code Again Date: Fri, 28 Jan 2011 12:01:52 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1296222396 27728 80.91.229.12 (28 Jan 2011 13:46:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 28 Jan 2011 13:46:36 +0000 (UTC) Cc: guile-devel@gnu.org To: Noah Lavine Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Jan 28 14:46:32 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pioel-0000cS-Kk for guile-devel@m.gmane.org; Fri, 28 Jan 2011 14:46:31 +0100 Original-Received: from localhost ([127.0.0.1]:47358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pioek-0005Bq-V4 for guile-devel@m.gmane.org; Fri, 28 Jan 2011 08:46:31 -0500 Original-Received: from [140.186.70.92] (port=43390 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pioeb-00057p-TE for guile-devel@gnu.org; Fri, 28 Jan 2011 08:46:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pioea-0002f1-Hl for guile-devel@gnu.org; Fri, 28 Jan 2011 08:46:21 -0500 Original-Received: from a-pb-sasl-sd.pobox.com ([64.74.157.62]:50064 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pioea-0002et-D2 for guile-devel@gnu.org; Fri, 28 Jan 2011 08:46:20 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 9DD0C3D2E; Fri, 28 Jan 2011 08:47:10 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=bBoOP9U1eVn6+XF8f/0+AOCUlac=; b=tjH9kc 4KYVG73JaXhyvbFE5JpQsRZOjoS/FfU27Oyyep7OSBXpjTDN4hGxUG4jOEyvQ+/o LWxBduNLc/KIqiLbXtgNBlc+1sxuJm6crdqfL3kGlcvMQ7ufHGU9X4SaQFiMKWJO aQx6q+5IVX4wKcTUhfrAmOo2KiVeDAfZqy9Vo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=lN3KK4tKlfKsBwMv0aLc/MzjLg0LqkDD xyIpMBf95T4pelNjd3FwRLaS0kbN7WuauLyI6GpPjibRPSEMDwHQK3ay4qNBk14a cb8BegcUmXN+dSOunPN/XkFvHDq58ap0tw+aehAqA+xEBvGt0K+RhgqalPeY2huc CzHmYli1jnU= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 8B0F23D2D; Fri, 28 Jan 2011 08:47:09 -0500 (EST) Original-Received: from unquote.localdomain (unknown [90.164.198.39]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id C349C3D2B; Fri, 28 Jan 2011 08:47:07 -0500 (EST) In-Reply-To: (Noah Lavine's message of "Sat, 8 Jan 2011 12:27:25 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Pobox-Relay-ID: 1A2047C8-2AE5-11E0-9C1A-BC4EF3E828EC-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 64.74.157.62 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11379 Archived-At: Heya Noah, Replying out-of-order here. On Sat 08 Jan 2011 18:27, Noah Lavine writes: > Therefore, I think the path to a native-code VM is to leave the VM as > it is (except maybe reserve an opcode for native-code calls). Then I > write first a C parser for Guile and then a converter program that > would take Guile's current VM and output a JIT VM like I've described. Hah, it seems we concluded on the same thing after all... > Specifically, you could construct the VM using the JITcode generator, > either on Guile startup or whenever the user decided to enable native > code generation. This is a very interesting possibility. It scares me, in its complexity, but it does seem to handle all of the objections that I had. > The ideal method of calling natively-generated code would be for the > VM to tail call the JITed code, which would then tail call the VM when > it was done. The only two ways of doing this are asking GCC to add a > tail call intrinsic (unportable) or building a library of tail-call > ASM for different platforms (more generally useful, but also basically > unportable). I actually don't think that either of these are bad ideas. And also... why not rely on gcc's tail-call optimization, in the case where it works? You can check for it at configure-time. I just ran some small tests for tail-calls between functions in separate compilation units and it shows that indeed, gcc does the right thing. I guess that given this circumstance, things are a lot easier. The JIT library still needs to know how to tail-call a C function, but that is more tractable. If you don't have tail-calls, perhaps the JIT compiler uses trampolines as you and Ludovic proposed; and that becomes a case that only gets exercised with -O0, and possibly not even then if we add -foptimize-sibling-calls when available. My apologies again for going back and forth on this issue! It's important, and there are a few options, so I guess more discussion is better here. Let us know your thoughts :) Regards, Andy -- http://wingolog.org/