emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MPS symbols


From: Gerd Möllmann
Subject: Re: MPS symbols
Date: Fri, 28 Jun 2024 09:42:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]