all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Gerd Möllmann" <gerd.moellmann@gmail.com>
To: Helmut Eller <eller.helmut@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: MPS symbols
Date: Fri, 28 Jun 2024 09:42:25 +0200	[thread overview]
Message-ID: <m2msn5cy3i.fsf@pro2.fritz.box> (raw)
In-Reply-To: <87r0chwnzx.fsf@gmail.com> (Helmut Eller's message of "Fri, 28 Jun 2024 09:00:18 +0200")

Helmut Eller <eller.helmut@gmail.com> writes:

> I have trouble to understand how symbols work with MPS.
>
> A Lisp_Object that references a symbol has tag Lisp_Symbol (0) and the
> other bits are an offset (in bytes) from lispsym.
>
> How can MPS recognize ambiguous references to symbols?

I hope I got that right (I think I have). Let me cite the scanner
function for simpliciry:

  scan_ambig (mps_ss_t ss, void *start, void *end, void *closure)
  {
    MPS_SCAN_BEGIN (ss)
    {
      for (mps_word_t *p = start; p < (mps_word_t *) end; ++p)
        {
          mps_word_t word = *p;
          mps_word_t tag = word & IGC_TAG_MASK;

          /* If the references in the object being scanned are
             ambiguous then MPS_FIX2() does not update the
             reference (because it can't know if it's a
             genuine reference). The MPS handles an ambiguous
             reference by pinning the block pointed to so that
             it cannot move. */
          mps_addr_t ref = (mps_addr_t) word;
          mps_res_t res = MPS_FIX12 (ss, &ref);
          if (res != MPS_RES_OK)
            return res;

Ambiguous referencess can be either pointers or Lisp_Objects. The above
lines handle the pointer case, and below is the Lisp_Object case, that
is when it looks kuje a Lisp_Object.

          switch (tag)
            {
            case Lisp_Int0:
            case Lisp_Int1:
            case Lisp_Type_Unused0:
              break;

            case Lisp_Symbol:
              {
                ptrdiff_t off = word ^ tag;
                ref = (mps_addr_t) ((char *) lispsym + off);
                res = MPS_FIX12 (ss, &ref);
                if (res != MPS_RES_OK)
                  return res;
              }
              break;

And anove is the symbol case. I.e. the word looks like Lisp_Object of a
symbol, we do the offset thing and rely on MPS_FIX12 to to the right ting.

            default:
              ref = (mps_addr_t) (word ^ tag);
              res = MPS_FIX12 (ss, &ref);
              if (res != MPS_RES_OK)
                return res;
              break;

And the above is basically fhe same as for symbols, only that we don't have
to do the offset dance.
            }
        }
    }
    MPS_SCAN_END (ss);
    return MPS_RES_OK;
  }



  reply	other threads:[~2024-06-28  7:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-28  7:00 MPS symbols Helmut Eller
2024-06-28  7:42 ` Gerd Möllmann [this message]
2024-06-28  7:53   ` Helmut Eller
2024-06-28  8:37     ` Gerd Möllmann
2024-06-28  8:46       ` Gerd Möllmann
2024-06-28  9:19         ` Gerd Möllmann
2024-06-28 11:54           ` Helmut Eller
2024-06-28 12:13             ` Gerd Möllmann
2024-06-28 12:36               ` Gerd Möllmann
2024-06-28 11:16       ` Eli Zaretskii
2024-06-28 11:50         ` Gerd Möllmann
2024-06-28 13:47           ` Helmut Eller
2024-06-28 14:13             ` Gerd Möllmann
2024-06-28 14:46               ` Gerd Möllmann
2024-06-28 15:41                 ` Helmut Eller
2024-06-28 16:06                   ` Eli Zaretskii
2024-06-28 16:19                     ` Helmut Eller
2024-06-28 17:40                       ` Eli Zaretskii
2024-06-28 16:20                     ` Gerd Möllmann
2024-06-28 17:59                       ` Eli Zaretskii
2024-06-29  3:56                         ` Gerd Möllmann

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2msn5cy3i.fsf@pro2.fritz.box \
    --to=gerd.moellmann@gmail.com \
    --cc=eller.helmut@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.