From: Han-Wen <hanwen@cs.uu.nl>
Cc: cmm@kakpryg.net
Subject: scm_mark_dependencies & guardians
Date: Fri, 19 Jul 2002 00:14:30 +0200 [thread overview]
Message-ID: <15671.15814.215112.357262@blauw.xs4all.nl> (raw)
hi all,
Strolling through gc.c, I found a construct worthy of
Spaghetti-coding 101, namely
#define MARK scm_gc_mark
#define FNAME "scm_gc_mark"
#endif /*!MARK_DEPENDENCIES*/
/* Mark an object precisely.
*/
void
MARK (SCM p)
#define FUNC_NAME FNAME
{
:
#ifndef MARK_DEPENDENCIES
:
/* And here we define `scm_gc_mark_dependencies', by including this
* same file in itself.
*/
#define MARK scm_gc_mark_dependencies
#define FNAME "scm_gc_mark_dependencies"
#define MARK_DEPENDENCIES
#include "gc-mark.c"
#undef MARK_DEPENDENCIES
#undef MARK
#undef FNAME
The scm_gc_mark_dependencies function is used once, to detect if a
guardian object points to itself in any way. I would like to change
this code to be like
inline
scm_mark (SCM p)
{
if (marked_p(p))
return
mark_cell (p)
scm_mark_dependencies (p)
}
/* mark all objects pointed to by P */
inline scm_mark_dependencies (SCM p)
{
..
}
however, the current code is so obtuse (goto considered harmful) that
it is difficult to make out what the exact semantics of
scm_mark_dependencies () should be. For example, a self-reference to
the argument of scm_mark_dependencies() is not followed or marked, but
only in when such a mark happens in scm_mark_dependencies(), not if it
happens in subsequent recursive invocation of scm_gc_mark().
Any comments? Any objections if I change the code as I proposed? I
am a little worried that the above code may be less efficient due to
less use of goto, but that is something that can be measured.
(Some minutes later: I implemented the change, and measured a 0.4 %
speed decrease in one particular GC benchmark. I'd say that 0.4% is
not worth the spaghetti, if it were statistically significant. There
are no errors from the test suite.)
--
Han-Wen Nienhuys | hanwen@cs.uu.nl | http://www.cs.uu.nl/~hanwen
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next reply other threads:[~2002-07-18 22:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-18 22:14 Han-Wen [this message]
2002-07-19 18:48 ` scm_mark_dependencies & guardians Marius Vollmer
2002-07-19 21:03 ` Han-Wen Nienhuys
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=15671.15814.215112.357262@blauw.xs4all.nl \
--to=hanwen@cs.uu.nl \
--cc=cmm@kakpryg.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).