GNU bug report logs - #14916
Fixnum procedures can be made to return non-fixnums

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guile; Reported by: Göran Weinholt <goran@HIDDEN>; dated Sat, 20 Jul 2013 06:00:03 UTC; Maintainer for guile is bug-guile@HIDDEN.

Message received at 14916 <at> debbugs.gnu.org:


Received: (at 14916) by debbugs.gnu.org; 22 Jun 2016 15:32:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 22 11:32:34 2016
Received: from localhost ([127.0.0.1]:51328 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bFk8o-0005iq-24
	for submit <at> debbugs.gnu.org; Wed, 22 Jun 2016 11:32:34 -0400
Received: from world.peace.net ([50.252.239.5]:48073)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mhw@HIDDEN>) id 1bFk8m-0005ie-TF
 for 14916 <at> debbugs.gnu.org; Wed, 22 Jun 2016 11:32:33 -0400
Received: from c-73-253-48-168.hsd1.ma.comcast.net ([73.253.48.168] helo=jojen)
 by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <mhw@HIDDEN>)
 id 1bFk8g-0005IX-SY; Wed, 22 Jun 2016 11:32:26 -0400
From: Mark H Weaver <mhw@HIDDEN>
To: Andy Wingo <wingo@HIDDEN>
Subject: Re: bug#14916: Fixnum procedures can be made to return non-fixnums
References: <8738r9ai62.fsf@HIDDEN> <87ioz5gffz.fsf@HIDDEN>
 <87y580vjj1.fsf@HIDDEN> <87shw73t47.fsf@HIDDEN>
Date: Wed, 22 Jun 2016 11:32:14 -0400
In-Reply-To: <87shw73t47.fsf@HIDDEN> (Andy Wingo's message of "Tue, 21 Jun
 2016 09:20:56 +0200")
Message-ID: <87por9s0ht.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 14916
Cc: =?utf-8?Q?G=C3=B6ran?= Weinholt <goran@HIDDEN>, 14916 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

Andy Wingo <wingo@HIDDEN> writes:

> 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
>
>  (= x (logand x #x2fffffff))

This doesn't work for negative fixnums, because you are effectively
masking out the sign of 'x' above.  Unfortunately, this problem cannot
be fixed by changing the mask.  For purposes of the bitwise operations,
negative integers are treated as though they have an infinite number of
ones in the high bits, e.g. -1 is all ones, and is thus an identity for
'logand'.  So, there's no single sign bit, but rather an infinite number
of them, and all of those bits can also be used as value bits as well,
so there's no way to avoid masking out the sign without also masking out
high-order value bits.

One possibility would be to subtract 'most-negative-fixnum' from x
before masking, but I don't know what the compiler would do with that.

     Mark




Information forwarded to bug-guile@HIDDEN:
bug#14916; Package guile. Full text available.

Message received at 14916 <at> debbugs.gnu.org:


Received: (at 14916) by debbugs.gnu.org; 21 Jun 2016 07:21:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 21 03:21:07 2016
Received: from localhost ([127.0.0.1]:48462 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bFFzf-0000vb-Be
	for submit <at> debbugs.gnu.org; Tue, 21 Jun 2016 03:21:07 -0400
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 <wingo@HIDDEN>) id 1bFFzd-0000vT-Bu
 for 14916 <at> debbugs.gnu.org; Tue, 21 Jun 2016 03:21:05 -0400
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=
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)
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)
From: Andy Wingo <wingo@HIDDEN>
To: Mark H Weaver <mhw@HIDDEN>
Subject: Re: bug#14916: Fixnum procedures can be made to return non-fixnums
References: <8738r9ai62.fsf@HIDDEN> <87ioz5gffz.fsf@HIDDEN>
 <87y580vjj1.fsf@HIDDEN>
Date: Tue, 21 Jun 2016 09:20:56 +0200
In-Reply-To: <87y580vjj1.fsf@HIDDEN> (=?utf-8?Q?=22G=C3=B6r?=
 =?utf-8?Q?an?= Weinholt"'s
 message of "Sat, 17 Aug 2013 09:55:14 +0200")
Message-ID: <87shw73t47.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Pobox-Relay-ID: B645A9D8-3780-11E6-BA2C-28A6F1301B6D-02397024!pb-sasl2.pobox.com
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: 14916
Cc: =?utf-8?Q?G=C3=B6ran?= Weinholt <goran@HIDDEN>, 14916 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.4 (-)

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 <goran@HIDDEN> writes:

> Mark H Weaver <mhw@HIDDEN> writes:
>
>> G=C3=B6ran Weinholt <goran@HIDDEN> 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,




Information forwarded to bug-guile@HIDDEN:
bug#14916; Package guile. Full text available.

Message received at 14916 <at> debbugs.gnu.org:


Received: (at 14916) by debbugs.gnu.org; 17 Aug 2013 07:57:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Aug 17 03:57:53 2013
Received: from localhost ([127.0.0.1]:35977 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1VAbOR-000760-IN
	for submit <at> debbugs.gnu.org; Sat, 17 Aug 2013 03:57:52 -0400
Received: from iustitia.weinholt.se ([46.16.232.230]:36910)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <goran@HIDDEN>) id 1VAbON-00075k-Cs
 for 14916 <at> debbugs.gnu.org; Sat, 17 Aug 2013 03:57:48 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=weinholt.se;
 s=iustitia2012; 
 h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References:Subject:Cc:To:From;
 bh=t5YrV8NzEjeWmVe3k6clWzMvTRRvbXiUBzOphX5fDoc=; 
 b=Ag1R6IG1XSfiGYx8v0xxVL2Vh9++j/k9cRYFigWQ1BpJWFzrBUTCaJ8x5rc5bzyy+TlpYvbGT3S726XDkv/xZimFMNO9WoVC7jw2vTK5icm2cY1yP+oN6KZJkNh2/0OT8sVyAdvZLbb1BS0rwfNBP57YwJiPqCH++Jx1AzK3xbKIkt9sD1Rm3XKR0/HyRlamQw8Yj0tSQ0220RPSBTbUHLK5MIJ+xnzc1sdZEBbd1ZpMftDk8rXRXqO/meNtcQ2mzp0KVKTI25V8QMnv5UQ/pxIf1cU2flcL6TzC06wfqAzK5RtpioS13hnN5KEAiv9PiDHGvFJnL6BxKDt2VQTaoA==;
Received: from uucp by iustitia.weinholt.se with local-bsmtp (Exim 4.72)
 (envelope-from <goran@HIDDEN>)
 id 1VAbOL-0008PX-CN; Sat, 17 Aug 2013 09:57:45 +0200
Received: from weinholt by industria with local (Exim 4.80)
 (envelope-from <goran@HIDDEN>)
 id 1VAbM4-0001W6-DI; Sat, 17 Aug 2013 09:55:24 +0200
From: =?utf-8?Q?G=C3=B6ran?= Weinholt <goran@HIDDEN>
To: Mark H Weaver <mhw@HIDDEN>
Subject: Re: bug#14916: Fixnum procedures can be made to return non-fixnums
References: <8738r9ai62.fsf@HIDDEN> <87ioz5gffz.fsf@HIDDEN>
X-Hashcash: 1:20:130817:14916 <at> debbugs.gnu.org::tSWqhH3CUgCweKkD:00000000000000000000000000000000000000000SiX
X-Hashcash: 1:20:130817:mhw@HIDDEN::asADUF11NMkFvmKR:0001OVx
Date: Sat, 17 Aug 2013 09:55:14 +0200
In-Reply-To: <87ioz5gffz.fsf@HIDDEN> (Mark H. Weaver's message of "Fri, 16
 Aug 2013 23:32:32 -0400")
Message-ID: <87y580vjj1.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
X-Spam-Score: -2.7 (--)
X-Debbugs-Envelope-To: 14916
Cc: 14916 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.7 (--)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Mark H Weaver <mhw@HIDDEN> writes:

> G=C3=B6ran Weinholt <goran@HIDDEN> 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,

=2D-=20
G=C3=B6ran Weinholt <goran@HIDDEN>
"I knew it! He's stepping up his game! We must match
his game with... MUCH MORE GAME!" -- The Monarch

--=-=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQIcBAEBCgAGBQJSDyxjAAoJEOM+YaLpuMOil0QP/01hvbmAMCyljPthKaKL7Lz0
SpxTkzyOW63guvkLkLCtixH1/aS8kGot62Bc7RDWinddgUF3Qf773ohO9Ded6Lvh
EaaL4RuUkBUm9TtdgRjI8VfaQHEhcrmDyHZh1CeWp/BAuNFrb19jRz+J7mJfG/QQ
wOAlul+d82bva5ToPK7+yZQTReKJi3QxB42v2KjBcxpwgeBD5aHMNMWDbC3szasa
c/6xf/hfZVHE2KR8JHJ0D9Zr3E7/AZa7RzXYjTHgjc3ZEsP+APA/jbqwbNHrYkvH
s1xEQDLoKJ8JPqqHsf8TWat01wnRkEhe9RExrEBqEGd8Jl2fv4EK14vben+XMFua
yH8Sjwe4aVn2NsQlBkB/G3T7MJrGaw2p5aPaySW6yFC2pMZ4SEjOriWUd0Cvva1b
KsHn8Eht0FCG64tJLKODB5P/7bYtgedB59lQZYpNDhZypKaDdVQ8IrixwRbqOM7l
KtDsOseQt6rT+piESgo4K9pcxOZUMbJPjRQcXlwQl5TWedrFdjkEzAV7bSIhQU4X
dOY/eg3yMkT/quY7Bmi9pozzZhf8GRvwWxMDSJUMM5wAUF9VlnJLksnbZXiBPmHU
T9ZLbTHYUr83DfV3IJHCu7st8M04gsJoTw5g1s/vi7LioVYEIQDcw5aqRrgjNlb+
YA1q3La55V2IG6jl67uZ
=cHlS
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to bug-guile@HIDDEN:
bug#14916; Package guile. Full text available.

Message received at 14916 <at> debbugs.gnu.org:


Received: (at 14916) by debbugs.gnu.org; 17 Aug 2013 03:32:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Aug 16 23:32:49 2013
Received: from localhost ([127.0.0.1]:35725 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1VAXFw-0000C9-8E
	for submit <at> debbugs.gnu.org; Fri, 16 Aug 2013 23:32:49 -0400
Received: from world.peace.net ([96.39.62.75]:60020 ident=hope3)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <mhw@HIDDEN>) id 1VAXFt-0000By-Rx
 for 14916 <at> debbugs.gnu.org; Fri, 16 Aug 2013 23:32:46 -0400
Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com
 ([209.6.91.212] helo=tines.lan)
 by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
 (Exim 4.72) (envelope-from <mhw@HIDDEN>)
 id 1VAXFn-00011q-IZ; Fri, 16 Aug 2013 23:32:39 -0400
From: Mark H Weaver <mhw@HIDDEN>
To: =?utf-8?Q?G=C3=B6ran?= Weinholt <goran@HIDDEN>
Subject: Re: bug#14916: Fixnum procedures can be made to return non-fixnums
References: <8738r9ai62.fsf@HIDDEN>
Date: Fri, 16 Aug 2013 23:32:32 -0400
In-Reply-To: <8738r9ai62.fsf@HIDDEN> (=?utf-8?Q?=22G=C3=B6r?=
 =?utf-8?Q?an?= Weinholt"'s
 message of "Sat, 20 Jul 2013 07:56:21 +0200")
Message-ID: <87ioz5gffz.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 14916
Cc: 14916 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

G=C3=B6ran Weinholt <goran@HIDDEN> writes:

> the fxdiv procedure from (rnrs) fails to check that its result is
> representable as a fixnum:
>
> scheme@(guile-user)> (import (rnrs))
> scheme@(guile-user)> (fxdiv (least-fixnum) -1)
> $1 =3D 2305843009213693952
>
> It should raise an &implementation-restriction.

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.

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?

      Mark




Information forwarded to bug-guile@HIDDEN:
bug#14916; Package guile. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 20 Jul 2013 05:59:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 20 01:59:54 2013
Received: from localhost ([127.0.0.1]:38843 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1V0QCw-0007qp-C9
	for submit <at> debbugs.gnu.org; Sat, 20 Jul 2013 01:59:54 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48103)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <goran@HIDDEN>) id 1V0QCt-0007qQ-Rj
 for submit <at> debbugs.gnu.org; Sat, 20 Jul 2013 01:59:52 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <goran@HIDDEN>) id 1V0QCn-0001PL-3b
 for submit <at> debbugs.gnu.org; Sat, 20 Jul 2013 01:59:46 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-99.2 required=5.0 tests=BAYES_50,LOTS_OF_MONEY,
 T_DKIM_INVALID,USER_IN_WHITELIST autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:48182)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <goran@HIDDEN>) id 1V0QCm-0001PH-TZ
 for submit <at> debbugs.gnu.org; Sat, 20 Jul 2013 01:59:44 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:49820)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <goran@HIDDEN>) id 1V0QCl-0002ND-HA
 for bug-guile@HIDDEN; Sat, 20 Jul 2013 01:59:44 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <goran@HIDDEN>) id 1V0QCj-0001Ot-C9
 for bug-guile@HIDDEN; Sat, 20 Jul 2013 01:59:43 -0400
Received: from iustitia.weinholt.se ([2a02:28f0:0:a::7dce:e5a8]:52534)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <goran@HIDDEN>) id 1V0QCi-0001OZ-Un
 for bug-guile@HIDDEN; Sat, 20 Jul 2013 01:59:41 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=weinholt.se;
 s=iustitia2012; 
 h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From;
 bh=H2tJ6TbFO0hnShmnzVgnnxbIdvnzR+NnkazIkQFbXAM=; 
 b=gDlR8T/HQkFYGGEllMGS9aUA264ONoV7ZjFQ/kp3wTsqnuFCSlkfZ6D8L5e0mLOawzBBVUYXMNExm9M6OWkiZ79zS59O/cl3AW/hdsvg5sHCVi4S37H8Pds/IoJiCT85bTjDPimE8Etad4H4LIRx9M4mQGJ/4VhdRr4Wpe7BYLx8f/XUmM9wNUPl16sy1ZmclM/dIjiR1NRE+MfAYgT+9aQpqCDvbnWFw79fKChlXywVig1HzOiyx2Lu+0LCPmaQIoAowdqiZFxvo1oFSiyd/PcmAu1Ooq1ClNRPAk9orq5idYOv7TDF+qqN04aHe3WhbG9EP4IbhkxQDzz9iHhP2Q==;
Received: from uucp by iustitia.weinholt.se with local-bsmtp (Exim 4.72)
 (envelope-from <goran@HIDDEN>)
 id 1V0QCh-0003f4-Cb; Sat, 20 Jul 2013 07:59:39 +0200
Received: from weinholt by industria with local (Exim 4.80)
 (envelope-from <goran@HIDDEN>)
 id 1V0Q9b-0001Ss-Vv; Sat, 20 Jul 2013 07:56:27 +0200
X-Hashcash: 1:20:130720:bug-guile@HIDDEN::S8gXevaA1SnMnU6F:000000000000000000000000000000000000000000002Wxb
From: =?utf-8?Q?G=C3=B6ran?= Weinholt <goran@HIDDEN>
To: bug-guile@HIDDEN
Subject: Fixnum procedures can be made to return non-fixnums
Date: Sat, 20 Jul 2013 07:56:21 +0200
Message-ID: <8738r9ai62.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -3.3 (---)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hello schemers,

the fxdiv procedure from (rnrs) fails to check that its result is
representable as a fixnum:

scheme@(guile-user)> (import (rnrs))
scheme@(guile-user)> (fxdiv (least-fixnum) -1)
$1 =3D 2305843009213693952

It should raise an &implementation-restriction. Here are a few other
examples of the same problem:

scheme@(guile-user)> (fxdiv-and-mod (least-fixnum) -1)
$2 =3D 2305843009213693952
$3 =3D 0
scheme@(guile-user)> (fxdiv0 (least-fixnum) -1)
$4 =3D 2305843009213693952
scheme@(guile-user)> (fxdiv0-and-mod0 (least-fixnum) -1)
$5 =3D 2305843009213693952
$6 =3D 0
scheme@(guile-user)> (fxarithmetic-shift-left (greatest-fixnum) 1)
$7 =3D 4611686018427387902
scheme@(guile-user)> (fxarithmetic-shift (greatest-fixnum) 1)
$8 =3D 4611686018427387902

Tested with Guile 2.0.9.40-824b-dirty on an amd64 system.

Regards,

=2D-=20
G=C3=B6ran Weinholt <goran@HIDDEN>
"Detta skall jag visa dig medelst ett stort papper som jag har fyllt
med faktiska upplysningar!" -- August Strindberg

--=-=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQIcBAEBCgAGBQJR6iaFAAoJEOM+YaLpuMOiZowP/RlkvJ5+Isq/F2A4djgG9Dpm
sRSbNgA/BkBNcEJg0+VjtMa0HWK+3er963rBkoMYXsKH5J47tZBC8gEHQuHYw7a7
o3320qkqEsznixShD98Fno2wfPeQpVXdGBp5p7O/0YaTvq1LxQgo7khWdCwb/7v+
xbYVtsm25b9/Ag/XNh2L0uMpJCwNT1nvlFDtYhZ8Z9xsUv+u3JNWG66J3PRBuOGQ
oYspe1IYTfmYVK1sfbL16ct8UgHxaQmSMEtPfuV0XL1vl2cGiTyLXZxp7qv7+5BS
/evwo0eQ2aemirN/WQbfTCPrFYF6g/z8s6EBK8I2eh3qTvAQcbMQ5d8k2E3o7TAK
LFfj+z8FBYx+lAiPfO6RYkbP+i7++9EFqSOc/n/+mpeKzuz9ab/LpIVyNinLIXJ+
5DYhCmN+Cp2BXOu0rc0ZFbZLcZotq1yFcZhHFzFi7eXqGQsDxs3Tig4GmlxWGGBQ
ciHSPSmai1DmxxhsMNkKoZvOI3uRnTGc5Jfu+q2SIvJ/YFv9L3PU9QvXA4tPD8UC
OZQ1hxS94EW1D03ZC7P+Xh+vyl5P6+fWAFME2d/+ONmmxNoKS4xAGmiT0h9JpJSo
4YUuE1xmQksWgFpILbCdAYlRctOROUX3MgdkJJhrgHmYLo7kXXNeUQnBi4bRQ+Ex
oDh976X5QoyTVnN5PeKH
=3XZI
-----END PGP SIGNATURE-----
--=-=-=--




Acknowledgement sent to Göran Weinholt <goran@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guile@HIDDEN. Full text available.
Report forwarded to bug-guile@HIDDEN:
bug#14916; Package guile. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.