From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Gerd_M=C3=B6llmann?= Newsgroups: gmane.emacs.devel Subject: Re: MPS symbols Date: Fri, 28 Jun 2024 09:42:25 +0200 Message-ID: References: <87r0chwnzx.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10035"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Helmut Eller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 28 09:43:21 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sN6GP-0002QW-2n for ged-emacs-devel@m.gmane-mx.org; Fri, 28 Jun 2024 09:43:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN6Fc-0006RA-KA; Fri, 28 Jun 2024 03:42:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN6Fb-0006QH-DS for emacs-devel@gnu.org; Fri, 28 Jun 2024 03:42:31 -0400 Original-Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN6FZ-0003v0-Rr for emacs-devel@gnu.org; Fri, 28 Jun 2024 03:42:31 -0400 Original-Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-57cbc2a2496so386238a12.0 for ; Fri, 28 Jun 2024 00:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719560547; x=1720165347; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZxPAV9EKmsjywFC2fBgH1SqDZFONoqt2QNNS/N9v5zQ=; b=Md8LvlpkrsSYNp0rLQjpoN43jxMKgrLbZK/qDIMlCYm4P0iVf7k4XipyrPF/xXMT4Q o0ef3QIUPivHJYJ/CDgYujLN/RzZzGLncHb3n6DM+GO0CKOZxS6gKI48NejLWcex3DwH eI476nADRecenoCjuQ96SZcsW4UucmrShcLL8ixL0E9VN7ayISN3l5gurRelENR1Mnus AZWKrZL+84WXOuLgY7bUjHJJIYUoI1MrZdLiGgaA7O7Pu5JvuquqDIdhIAkdXYPXQRMZ 7XHasl3fjbG93d3TqXNbcn3eht6C9q3cDQgXCRIkL13s/RaFypu+kv5XpKd0f1+DZZpN CiNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719560547; x=1720165347; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZxPAV9EKmsjywFC2fBgH1SqDZFONoqt2QNNS/N9v5zQ=; b=smOsgj/LQNVDzb9WFkfwuQb4kKYeOM+KKNGImFbQNbrj6E5d22fG3UsJa2olz4hivV oGJ+dzSsOKNqu4aBil7uWA8aFnHdfC26CGTOQDalRaG+1kxMWhnYroxJe1whuF+UlJru zGVveaRHO5h5e6e/Z5Y+E4+rdgROqyzk6k7ly58YKzhNC6X+0s3Di+4hOdG18WxUY25d GtWQR/O8RMiRH0QPHeYEtITT4CBwuAFldNS8KorkpgygMqaLPYiwd7KogChxMXXDGZZO nxqJg81PUF5Wpc9LsSyk5yQAL/qCKRd24InuLjbeJ8hFOIT1zvKYRMj2xB4kkWwy9XUI NYSQ== X-Gm-Message-State: AOJu0Yw3GGEpUlSz4ekkgnvFG9rkHE3hLYU1+Y+1Df9ZCgbH/bbdwUcU k1hfKPK+IVO+jhe3uMCKVyUUrvnZ+dgVvMEvxc6hc2uPn/PpFQRMPnrUgg== X-Google-Smtp-Source: AGHT+IHByze98GNEsUcXPVokT9jEOPHOr/UlLD5mOOio5n6k+8actqpWkhagBfEiOSSxVUcLc+kdyA== X-Received: by 2002:a17:907:174b:b0:a6f:e3cf:2b8e with SMTP id a640c23a62f3a-a7245cc096emr1327373666b.76.1719560547113; Fri, 28 Jun 2024 00:42:27 -0700 (PDT) Original-Received: from pro2.fritz.box (pd9e360da.dip0.t-ipconnect.de. [217.227.96.218]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf1bc08sm50257966b.28.2024.06.28.00.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jun 2024 00:42:26 -0700 (PDT) In-Reply-To: <87r0chwnzx.fsf@gmail.com> (Helmut Eller's message of "Fri, 28 Jun 2024 09:00:18 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=gerd.moellmann@gmail.com; helo=mail-ed1-x529.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:320802 Archived-At: Helmut Eller 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; }