unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Re: fyi, a reading of guile source
@ 2002-05-16  2:43 Lynn Winebarger
  2002-05-16  7:49 ` Martin Grabmueller
       [not found] ` <E178G1E-0000E2-00@mgrabmue.home.cs.tu-berlin.de>
  0 siblings, 2 replies; 4+ messages in thread
From: Lynn Winebarger @ 2002-05-16  2:43 UTC (permalink / raw)



On Wednesday 15 May 2002 19:01, Thien-Thi Nguyen wrote:
> this has been checked into $workbook/journal/owinebar.notes, btw.
> i learned a lot reading it.
> 
   Thanks.  With no response, I had thought everyone else thought
it was too basic and obvious to mention - or that prospective guile
modifiers _should_ have to explore these things themselves.  Or 
both.

    Between glancing at papers on macros and modules and my real
job I haven't had much time to read more, but I did figure out one thing
that had puzzled me.
    The least significant bit of a SCM value is not exactly for
tagging.  The garbage collector needs one bit per cell, so it was
given the lsb of the 2nd word of a cell.  That means you can't
look at an arbitrary scheme value (that may have been stored in
the cdr of a cell) and tell anything by its lsb.  But that means
the lsb of the first word of a cell is now unused.  So what we
can do is tag the cell itself as being a cons cell (by making the
lsb 0) or a non-cons cell (structs).
     Also, integers are given 2 tags, but they are the two ending
in 10,  so it's really just one 2-bit tag.   On first reading I had thought
they might have been two different types (one for fixnums and one
for bignums or something) as there's no glaringly obvious indication 
otherwise.
     Now I'm recalling, some of the case label #defines are pretty
misleading (also in tags.h).  A couple of them are named
scm_tcs_cons_{n,}imcar and commented as being for 
{non-,}immediate values in the cars of cons cells.  From what I
wrote above, this is misleading (because "non-immediate" means
the lsb is one, and this only happens in first word of a _non_-cons 
cell).  In particular, scm_tcs_cons_nimcar actually identifies only
pointers to cells (which is when the 3 lsb's are 0) regardless of whether
they're in the car of a cons cell, and it is used in the eval function 
just for the purpose of identifying un-memoized s-expressions (i.e.
the raw lists of symbols and constants).  [ Note this is the last clause
in the main switch statement of eval(): all the preceding ones are for
"tree-coded" SCM values - where the operators have been resolved
into the base scheme operators identified by tags instead of symbols.
Presumably it's the last clause because you want the tree-coded expressions
to be the common case (they only require comparing the number in the
car with constants rather than symbol lookups), and the switch might
be implemented by a bunch of if/then statements, rather than, say, a quick
hash table lookup of jump destinations or other table implementation.
Unfortunately,  it makes the evaluation sequence harder to figure out 
if you don't know what you're looking for already.]   And scm_tcs_cons_imcar
actually identifies all the other immediates (integers, various constants, 
characters, ilocs, and "immediate instructions").
     I should redo some of this when I've looked more closely at the source 
again. I can't remember why "tree code" instructions are cells with a 1 in 
the lsb of the car, and immediate instructions end in "100".  I was thinking
the instructions were stored in the first word of the cell (after 
memoization),  but that can't be right.

Lynn


-------------------------------------------------------

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-05-19  4:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-16  2:43 fyi, a reading of guile source Lynn Winebarger
2002-05-16  7:49 ` Martin Grabmueller
     [not found] ` <E178G1E-0000E2-00@mgrabmue.home.cs.tu-berlin.de>
2002-05-18 13:47   ` Neil Jerram
2002-05-19  4:00     ` Thien-Thi Nguyen

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).