From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: Re: scm_remember_upto_here asm volatile Date: Thu, 14 Aug 2003 07:09:16 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <878ypx2rk3.fsf@zip.com.au> References: <874r4186ty.fsf@zip.com.au> <87znll48wr.fsf@zagadka.ping.de> <87he7rwzox.fsf@zip.com.au> <87znl1ocrn.fsf@zagadka.ping.de> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1060722677 15679 80.91.224.253 (12 Aug 2003 21:11:17 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 12 Aug 2003 21:11:17 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Aug 12 23:11:15 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19mgQF-0003X3-00 for ; Tue, 12 Aug 2003 23:11:15 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19mgPJ-0002M5-8J for guile-devel@m.gmane.org; Tue, 12 Aug 2003 17:10:17 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19mgPC-0002H0-Ib for guile-devel@gnu.org; Tue, 12 Aug 2003 17:10:10 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19mgOg-000282-E2 for guile-devel@gnu.org; Tue, 12 Aug 2003 17:10:09 -0400 Original-Received: from [61.8.0.36] (helo=snoopy.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.20) id 19mgOf-00024V-HQ for guile-devel@gnu.org; Tue, 12 Aug 2003 17:09:37 -0400 Original-Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.2.228.40]) by snoopy.pacific.net.au (8.12.3/8.12.3/Debian-6.4) with ESMTP id h7CL9a0J029844 for ; Wed, 13 Aug 2003 07:09:36 +1000 Original-Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id h7CL9akv016393 for ; Wed, 13 Aug 2003 07:09:36 +1000 (EST) Original-Received: from localhost (ppp123.dyn228.pacific.net.au [203.143.228.123]) by wisma.pacific.net.au (8.12.9/8.12.9) with ESMTP id h7CL9Xos010393 for ; Wed, 13 Aug 2003 07:09:34 +1000 (EST) Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 19n2rt-0001NP-00; Thu, 14 Aug 2003 07:09:17 +1000 Original-To: guile-devel@gnu.org Mail-Copies-To: never User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2690 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2690 --=-=-= In absense of violent objections I made this change, I'm pretty sure it's right. A temporary "# %0" or similar can be put in the asm string to see in the .s output where the operand is actually located (just to prove that it really is live at the right point). * gc.h (scm_remember_upto_here_1, scm_remember_upto_here_2) [__GNUC__]: Use volatile asm macros rather than a function call. * gc.c (scm_remember_upto_here_1, scm_remember_upto_here_2): Undefine macros while defining functions. --=-=-= Content-Disposition: attachment; filename=gc.h.upto.diff --- gc.h.~1.110.~ 2003-07-29 09:27:59.000000000 +1000 +++ gc.h 2003-08-14 07:05:09.000000000 +1000 @@ -341,6 +341,26 @@ SCM_API void scm_remember_upto_here_1 (SCM obj); SCM_API void scm_remember_upto_here_2 (SCM obj1, SCM obj2); SCM_API void scm_remember_upto_here (SCM obj1, ...); + +/* In GCC we can force a reference to an SCM with a little do-nothing asm, + avoiding the code size and slowdown of an actual function call. + __volatile__ ensures nothing will be moved across the reference, and that + it won't be optimized away (or rather only if proved unreachable). + Unfortunately there doesn't seem to be any way to do the varargs + scm_remember_upto_here similarly. */ + +#ifdef __GNUC__ +#define scm_remember_upto_here_1(x) \ + do { \ + __asm__ __volatile__ ("" : : "g" (x)); \ + } while (0) +#define scm_remember_upto_here_2(x, y) \ + do { \ + scm_remember_upto_here_1 (x); \ + scm_remember_upto_here_1 (y); \ + } while (0) +#endif + SCM_API SCM scm_return_first (SCM elt, ...); SCM_API int scm_return_first_int (int x, ...); SCM_API SCM scm_permanent_object (SCM obj); --=-=-= Content-Disposition: attachment; filename=gc.c.upto.diff --- gc.c.~1.244.~ 2003-04-07 08:05:08.000000000 +1000 +++ gc.c 2003-08-14 07:06:36.000000000 +1000 @@ -656,6 +656,12 @@ * scm_remember_upto_here_1 (str); // str will be alive up to this point. */ +/* Remove any macro versions of these while defining the functions. + Functions are always included in the library, for upward binary + compatibility and in case combinations of GCC and non-GCC are used. */ +#undef scm_remember_upto_here_1 +#undef scm_remember_upto_here_2 + void scm_remember_upto_here_1 (SCM obj SCM_UNUSED) { --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel --=-=-=--