From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: [BDW-GC] Static allocation of subrs Date: Tue, 03 Feb 2009 00:38:07 +0100 Message-ID: <87iqnsbeao.fsf@gnu.org> References: <87vdrv179q.fsf@gnu.org> <87wsc8jys1.fsf@arudy.ossau.uklinux.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1233617968 11844 80.91.229.12 (2 Feb 2009 23:39:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 2 Feb 2009 23:39:28 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Feb 03 00:40:42 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 1LU8Oq-0005hK-QE for guile-devel@m.gmane.org; Tue, 03 Feb 2009 00:40:21 +0100 Original-Received: from localhost ([127.0.0.1]:41933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LU8NY-0006tG-4U for guile-devel@m.gmane.org; Mon, 02 Feb 2009 18:39:00 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LU8NS-0006sz-IM for guile-devel@gnu.org; Mon, 02 Feb 2009 18:38:54 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LU8NR-0006sn-TP for guile-devel@gnu.org; Mon, 02 Feb 2009 18:38:54 -0500 Original-Received: from [199.232.76.173] (port=50921 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LU8NR-0006sk-O9 for guile-devel@gnu.org; Mon, 02 Feb 2009 18:38:53 -0500 Original-Received: from main.gmane.org ([80.91.229.2]:44119 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LU8NR-0005ms-2R for guile-devel@gnu.org; Mon, 02 Feb 2009 18:38:53 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LU8NL-0005Yl-41 for guile-devel@gnu.org; Mon, 02 Feb 2009 23:38:47 +0000 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 02 Feb 2009 23:38:47 +0000 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 02 Feb 2009 23:38:47 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 116 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 15 =?iso-8859-1?Q?Pluvi=F4se?= an 217 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 821D 815D 902A 7EAB 5CEE D120 7FBA 3D4F EB1F 5364 X-OS: i686-pc-linux-gnu User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) Cancel-Lock: sha1:AO2uX7ptP7fTp36/iJ9hJjwjPJM= 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:8121 Archived-At: Hi Neil, Note: I reply to messages in order of least difficulty. ;-) Neil Jerram writes: > ludo@gnu.org (Ludovic Courtès) writes: >> For these reasons, we may want to merge this patch in `master' as >> well. > > Yes, I think so. Noted, will do. >> 2. The second step does the actual work [1]. Currently, it only >> deals with subrs, i.e., primitive procedures with "relatively few" >> arguments (see `create_gsubr ()'). > > Presumably that is in practice almost all of the primitives, though? That's 200 gsubrs, vs. 873 "simple" subrs. >> To distinguish subrs (few arguments) from gsubrs (unrestricted >> arity, see `default:' in `create_gsubr ()'), a Dirty Hack(tm) was >> needed. The hack is that `SCM_DEFINE' is an alias for a new macro >> `SCM_DEFINE_SUBR_reqX_optY_rstZ', where X, Y and Z are the number >> of required, optional and rest arguments. If X, Y and Z are such >> that a raw subr can be used, then the macro is an alias for >> `SCM_DEFINE_SUBR', which does the actual static allocation; >> otherwise, it's an alias for `SCM_DEFINE_GSUBR', which is the same >> as `SCM_DEFINE' in `master'. > > Not so bad, IMO. It breaks cases like primitive procedures with more than 16 arguments (because I arbitrarily decided that `snarf-gsubr.h' would contain definitions up to 16 req/opt args), and situations like: SCM_DEFINE (scm_foo, "foo", 0001, 0002, 0003, ...) This is probably acceptable in practice. >> The dirtiest part of the hack is the generation of "snarf-gsubr.h" >> which contains definitions of `SCM_DEFINE_SUBR_reqX_optY_rstZ' for >> a "reasonable" number of combinations of X, Y and Z (C++ template >> specialization would solve this problem much more elegantly...). > > This part is quite dirty, as you say. I'm not sure what's the > advantage of the generation at make time. Wouldn't it be simpler, and > have the same function, just to hardcode all these definitions > directly in snarf.h? Given the size of `snarf-gsubr.h' (there are 16 * 16 * 2 = 512 combinations), I'd rather keep it separated. The makefile rule is an efficient way to compress it. ;-) >> [0] http://git.savannah.gnu.org/gitweb/?p=guile.git;a=commitdiff;h=2ee5aa25dbd679b175707762f5961585027e1397 > > Should probably remove the comments about how many subrs there are, > since it's no longer relevant. Right. > I see there's no NEWS in the commit; is that because there's no impact > on the API? Even if so, I imagine it might merit a line in the 2.0 > release notes. If you agree, I'd encourage you to write the NEWS now, > rather than adding it later. Right. It's just that I have not maintained any NEWS file for BDW-GC-related changes, initially. > + meta_info = scm_gc_malloc (2 * sizeof (* meta_info), > + "subr meta-info"); > > I found the space between "*" and "meta_info" confusing for a few > seconds, so would have a preference for "*meta_info". Yes, I feel the same today (I probably felt differently that day). :-) >> [1] http://git.savannah.gnu.org/gitweb/?p=guile.git;a=commitdiff;h=46f9baf49a8ea4461e8494c75a88b87d0f5c5195 > > Why does the macro code sometimes use scm_i_paste, and sometimes ## > directly? The `scm_i_paste ()' macro is needed so that macro-expansion of definitions like those of `srfi-4.i.c' work as expected. There are a few cases where it isn't used (e.g., in `SCM_IMMUTABLE_DOUBLE_CELL ()'), but I guess it didn't cause any problem because `scm_i_paste ()' was properly used by callers. We could unify that but `scm_i_paste ()' has the drawback of having a long name. > Finally SCM_SUBR_ARITY_TO_TYPE... The implementation feels a bit > messy, but I don't have any alternative to suggest, so I guess that's > OK. The problem is that this information is shared among 3 places: `SCM_SUBR_ARITY_TO_TYPE ()', `create_gsubr ()', and `SCM_DEFINE_SUBR_reqX_optY_rstZ ()'. Ideally, all 3 would be generated from a single source. Besides, I think we need to review the use of subr/gsubr tag in detail to see whether we can make better use of them. > But what about the fact that it's added to the libguile API? I > realize that this is necessary to some extent so that snarf.h can be > used by application code - but can we somehow restrict > SCM_SUBR_ARITY_TO_TYPE to being used in that context, so that it > doesn't become on ongoing constraint for us? I share your concern, but I have no idea of how to avoid it. We could add `_I_' in its name, perhaps. Hopefully, it's too low-level for anyone to try it. Thanks, Ludo'.