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: Question about DEFVAR_LISP_NOPRO Date: Fri, 05 Apr 2024 18:37:56 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25406"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Kenichi Handa , emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 05 18:38:43 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 1rsmaR-0006MP-33 for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Apr 2024 18:38:43 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rsmZn-0007mm-S6; Fri, 05 Apr 2024 12:38:03 -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 1rsmZn-0007me-64 for emacs-devel@gnu.org; Fri, 05 Apr 2024 12:38:03 -0400 Original-Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsmZk-0003MN-DC; Fri, 05 Apr 2024 12:38:02 -0400 Original-Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-33ddd1624beso1365086f8f.1; Fri, 05 Apr 2024 09:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712335078; x=1712939878; 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=uK0B+eL0bWDhRxI0T/eKHsmMFZp8z55NzE70g7ZZ6z0=; b=fb+KD6sjzKTqmxMoDHkYwV3CKv7dMqnh7woGLZGO1gG1S2TpTeNjCpQWwEDLQ6mkz+ qubXwdfgIgNEZgonay5YdvxJ03+52ToNJbhvlN5MHYM69UV076zsv92AZUY5cKAUJp8w RP9OuVoblXcAi3T6eJAbZK4r5BfVKx6g21EoYwTLPyw0Xzj10R+AHa0cFjUC6k/3n7Rt njl8k0P00q0vV08tdX7rGrKQRR2EaM1NS5wm2rU6eaOrl3i+DlX0NxfOkn+ZY6Y+kvqT VJqobo5C1/JCuthf9VMUdRDy8lhO1YunZT88WT7nNKdd9Of0iko7KGMaXC0bhH2tHKay 4yYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712335078; x=1712939878; 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=uK0B+eL0bWDhRxI0T/eKHsmMFZp8z55NzE70g7ZZ6z0=; b=Vo723W1i0iF8eLvZhaz3QbpulSM6LBjFgxVoN2UHWL7Z5omjyWm+aECQ+BaUTf7IeR 1rnHpUWu9rYC1T15/jOnIQlZ5VZ6/9abIELEv2D7ffqwjcvQnR04yql0vIUrHPVmyTCS H6do5DlMvLJ9tPuAnkBhnVxQY0vS5yge7QFJGe5gsaUlC/PNwB0jjY7WZSBESz1Gq8Ce GC8P5aUq+lMYZ7oJ6rqBvt24dWZEQG16JIGaW64RQytczX5ZI1fqt4RUe2LyHYsbirrP rBJ8Y3tIW3AWPc5NrMckrX3SnspDH3GclH6qog+1WI1LY18sVqxgHE2E7ORMQpGqii8c BJMQ== X-Forwarded-Encrypted: i=1; AJvYcCX3mRYGUxWMtK/BzG83BtHsqTTmc0ioLbwwGhLcoSiDatM8tndDRBNB1xG20FzjXvk/yK60+jeE1J6IVY/Q7KbvKjh8 X-Gm-Message-State: AOJu0YwKqAj87/bXj8zR4GvIzyAnm6hzCzpqkKSDlCYhRoOP14CAFmM2 5u9UPwdTjnuaYMpskDyAhQzeT+mbKus6HfS/yvRuy9i7Vm8Tx9RK/yFwE0YJ X-Google-Smtp-Source: AGHT+IHFgu5EfIuRcch8b9v230XFgXQPP5Egp0XvFdtqJuCdxWlojCfPB6qU5YjrqJoS9j5Zhs5pgA== X-Received: by 2002:adf:cc90:0:b0:33e:9f3d:6910 with SMTP id p16-20020adfcc90000000b0033e9f3d6910mr2278595wrj.31.1712335077868; Fri, 05 Apr 2024 09:37:57 -0700 (PDT) Original-Received: from Pro.fritz.box (p4fe3a1a0.dip0.t-ipconnect.de. [79.227.161.160]) by smtp.gmail.com with ESMTPSA id e38-20020a5d5966000000b003437ad152f9sm2369524wri.105.2024.04.05.09.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 09:37:57 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Fri, 05 Apr 2024 12:24:43 -0400") Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=gerd.moellmann@gmail.com; helo=mail-wr1-x42b.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:317556 Archived-At: Stefan Monnier writes: >> I came across another esoteric question in the context of a moving GC. >> >> Emacs contains has a few uses of DEFVAR_LISP_NOPRO, which is like >> DEFVAR_LISP, except that it does not staticpro the variable. >> >> #define DEFVAR_LISP_NOPRO(lname, vname, doc) \ >> do { \ >> static struct Lisp_Objfwd const o_fwd \ >> = {Lisp_Fwd_Obj, &globals.f_##vname}; \ >> defvar_lisp_nopro (&o_fwd, lname); \ >> } while (false) >> >> Example: >> >> DEFVAR_LISP_NOPRO ("font-weight-table", Vfont_weight_table, >> doc: /* Vector of valid font weight values. ... */); >> Vfont_weight_table = BUILD_STYLE_TABLE (weight_table); >> make_symbol_constant (intern_c_string ("font-weight-table")); >> >> Here a symbol is defined which has a value that is forwarded to the >> static globals.f_Vfont_weight_table, but that static is not staticpro'd. >> >> My question is simply: What the heck? > > I think only Kenichi knows the real answer (commit d0ab1ebe49f7), but my > guess is that it was just an optimization because those vars always > refer to each of the three elements of the `font_style_table` which *is* > gcpro'd and is not exposed to ELisp so we know that a non-moving GC doesn't > need to know about those vars. > > IOW, it seems perfectly safe to change those to plain `DEFVAR_LISP` > (and get rid of `DEFVAR_LISP_NOPRO`). Thanks, Stefan. BTW, this comment in process_mark_stack isn't true because of DEFVAR_LISP_NOPRO: case SYMBOL_FORWARDED: /* If the value is forwarded to a buffer or keyboard field, these are marked when we see the corresponding object. And if it's forwarded to a C variable, either it's not a Lisp_Object var, or it's staticpro'd already. */ break;