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: Bytevector VM ops Date: Tue, 30 Jun 2009 09:15:48 +0200 Message-ID: References: <873a9ibrx1.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1246346342 9644 80.91.229.12 (30 Jun 2009 07:19:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 30 Jun 2009 07:19:02 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Jun 30 09:18:55 2009 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.50) id 1MLXcE-00021T-Id for guile-devel@m.gmane.org; Tue, 30 Jun 2009 09:18:54 +0200 Original-Received: from localhost ([127.0.0.1]:56202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MLXcD-00078j-QL for guile-devel@m.gmane.org; Tue, 30 Jun 2009 03:18:53 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MLXax-0006WD-Lw for guile-devel@gnu.org; Tue, 30 Jun 2009 03:17:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MLXas-0006U2-Ag for guile-devel@gnu.org; Tue, 30 Jun 2009 03:17:34 -0400 Original-Received: from [199.232.76.173] (port=49211 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MLXas-0006Tx-6U for guile-devel@gnu.org; Tue, 30 Jun 2009 03:17:30 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:5296) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MLXan-0004QB-5I; Tue, 30 Jun 2009 03:17:25 -0400 Original-Received: from a-sasl-quonix.sasl.smtp.pobox.com ([208.72.237.25] helo=sasl.smtp.pobox.com) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MLXam-0004d6-6k; Tue, 30 Jun 2009 03:17:24 -0400 Original-Received: from localhost.localdomain (unknown [127.0.0.1]) by a-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTP id C4DDE23FEC; Tue, 30 Jun 2009 03:17:07 -0400 (EDT) Original-Received: from unquote (unknown [88.17.129.121]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTPSA id D69FD23FEB; Tue, 30 Jun 2009 03:17:05 -0400 (EDT) In-Reply-To: <873a9ibrx1.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Tue, 30 Jun 2009 00:23:38 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) X-Pobox-Relay-ID: 0540F638-6546-11DE-9D88-DC021A496417-02397024!a-sasl-quonix.pobox.com X-Detected-Operating-System: by mx20.gnu.org: Solaris 10 (beta) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:8805 Archived-At: Hi, On Tue 30 Jun 2009 00:23, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > "Andy Wingo" writes: > >> +#define BV_FIXABLE_INT_REF(stem, fn_stem, type, size) = \ >> +{ = \ >> + long i; = \ >> + ARGS2 (bv, idx); = \ >> + VM_VALIDATE_BYTEVECTOR (bv); = \ >> + if (SCM_LIKELY (SCM_I_INUMP (idx) = \ >> + && ((i =3D SCM_I_INUM (idx)) >=3D 0) = \ >> + && (i < SCM_BYTEVECTOR_LENGTH (bv)) = \ >> + && (i % size =3D=3D 0))) = \ >> + RETURN (SCM_I_MAKINUM (*(scm_t_##type*) = \ >> + (SCM_BYTEVECTOR_CONTENTS (bv) + i))); = \ > > Did you test this on SPARC or some such? I'm 90% sure > `(bv-u32-ref bv 1)' would lead to SIGBUS there, due to the unaligned acce= ss. > This is why `INTEGER_REF ()' in `bytevectors.c' uses memcpy(3). Wouldn't the i % size =3D=3D 0 case catch that? (This is used in native-ref instructions)=20 >> + else = \ >> + RETURN (scm_bytevector_##fn_stem##_ref (bv, idx)); = \ > > In this case, we pay the overhead twice (type-checking et al.). It's probably an error -- idx is not an inum, is out of range, or is unaligned... > Given that there's some duplication with `bytevectors.c', maybe we could > share some of the accessor macros between both files? Perhaps! The one difference is that we can fast-path only the normal cases here, calling out to those functions to handle stranger things (like unaligned access). Andy --=20 http://wingolog.org/