From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.bugs Subject: bug#14916: Fixnum procedures can be made to return non-fixnums Date: Tue, 21 Jun 2016 09:20:56 +0200 Message-ID: <87shw73t47.fsf@pobox.com> References: <8738r9ai62.fsf@industria.weinholt.se> <87ioz5gffz.fsf@tines.lan> <87y580vjj1.fsf@industria.weinholt.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1466493751 2916 80.91.229.3 (21 Jun 2016 07:22:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 21 Jun 2016 07:22:31 +0000 (UTC) Cc: =?UTF-8?Q?G=C3=B6ran?= Weinholt , 14916@debbugs.gnu.org To: Mark H Weaver Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Jun 21 09:22:21 2016 Return-path: Envelope-to: guile-bugs@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 1bFG0l-0003IO-OL for guile-bugs@m.gmane.org; Tue, 21 Jun 2016 09:22:15 +0200 Original-Received: from localhost ([::1]:49354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFG0k-0000dx-VZ for guile-bugs@m.gmane.org; Tue, 21 Jun 2016 03:22:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFG0d-0000dj-DW for bug-guile@gnu.org; Tue, 21 Jun 2016 03:22:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFG0Y-00063Z-DC for bug-guile@gnu.org; Tue, 21 Jun 2016 03:22:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36125) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFG0Y-00063U-8r for bug-guile@gnu.org; Tue, 21 Jun 2016 03:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bFG0Y-0000wo-2Y for bug-guile@gnu.org; Tue, 21 Jun 2016 03:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andy Wingo Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 21 Jun 2016 07:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14916 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 14916-submit@debbugs.gnu.org id=B14916.14664936673575 (code B ref 14916); Tue, 21 Jun 2016 07:22:02 +0000 Original-Received: (at 14916) by debbugs.gnu.org; 21 Jun 2016 07:21:07 +0000 Original-Received: from localhost ([127.0.0.1]:48462 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFFzf-0000vb-Be for submit@debbugs.gnu.org; Tue, 21 Jun 2016 03:21:07 -0400 Original-Received: from pb-sasl2.pobox.com ([64.147.108.67]:56968 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFFzd-0000vT-Bu for 14916@debbugs.gnu.org; Tue, 21 Jun 2016 03:21:05 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id 132CD20958; Tue, 21 Jun 2016 03:21:04 -0400 (EDT) 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:content-transfer-encoding; s=sasl; bh=E8jcQ0TVTmqM udkq4zlIz3RP8vQ=; b=xA+C1mdI7IGPiNnMg8AxH7yjKsiplrm4Gpv8xidd77vG NsNICigbF+ENGtqMO+BfMgs7CKDIXPewHmZeB5pN4BKNNHlDbMUjykFOPAZWqXi8 O9mQM5A7CqoMmmeBsG/LE4YFLpV2NHBe1N6ZvppxfVLUjqMtomw5GxYDcBI2EN8= 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:content-transfer-encoding; q=dns; s=sasl; b=IVUIo3 X+0qqBUQ7lUehjKU4F0MA9XwQJDQBhBSVrYW4SEKUuUr0+p6ZMiPO8Jh4QMOLEGw ulQ5nxpgAWzmXFeE+oAXqivdSJmYRD/JNdTzXMoaQsGsPfP8VYq7Aw0VTR/hl3fG 7ey2UVgiPfABd0GJPlbFZbymzP/i7wZyToQL8= Original-Received: from pb-sasl2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id 0B18620957; Tue, 21 Jun 2016 03:21:04 -0400 (EDT) Original-Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl2.pobox.com (Postfix) with ESMTPSA id 55F8F20956; Tue, 21 Jun 2016 03:21:03 -0400 (EDT) In-Reply-To: <87y580vjj1.fsf@industria.weinholt.se> ("=?UTF-8?Q?G=C3=B6ran?= Weinholt"'s message of "Sat, 17 Aug 2013 09:55:14 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Pobox-Relay-ID: B645A9D8-3780-11E6-BA2C-28A6F1301B6D-02397024!pb-sasl2.pobox.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:8058 Archived-At: Hi Mark, I know you like mathy things and so this might be a project you would like. I think the right thing to do here is to redefine fixnum? as (=3D x (logand x #x2fffffff)) on 32-bit targets and 8 more f's for 64-bit targets. Make sure to get that inline. In that way we'll end up unboxing X and doing unboxed arithmetic on it. Likewise we can insert a similar check at the end. Andy On Sat 17 Aug 2013 09:55, G=C3=B6ran Weinholt writes: > Mark H Weaver writes: > >> G=C3=B6ran Weinholt writes: >> >>> the fxdiv procedure from (rnrs) fails to check that its result is >>> representable as a fixnum: > >> Hmm. Currently, our fixnum and flonum operations are implemented in >> terms of the generic operations, with added checks. Whereas the most >> important generic arithmetic operations compile to VM instructions, the >> fixnum and flonum operations compile into procedure calls to scheme code >> that performs the checks and then uses the generic ops. >> >> Needless to say, this is terribly slow. I'm reluctant to make that code >> any slower by adding more checks. > > I agree with this sentiment. The fixnum operations are supposed to be > fast, so making them slower doesn't make sense. There is a delicious > irony in the fact that the generic operations have all these extra > checks that would have to be undone by adding more checks afterwards. > >> However, in the coming months I intend to reimplement the fixnum and >> flonum operations, using dedicated instructions in the new RTL VM which >> will be the basis of Guile 2.2. >> >> It would be possible to backport some of this to Guile 2.0 as well, but >> I'm not sure it's worth the effort. >> >> What do you think? > > It's better to look toward the future. If Guile 2.2 will be much faster > then you get more leverage when optimizing the fixnum/flonum operations > than compared with Guile 2.0. > > Regards,