From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet via "Emacs development discussions." Newsgroups: gmane.emacs.devel Subject: Re: Merging scratch/no-purespace to remove unexec and purespace Date: Fri, 20 Dec 2024 08:42:43 +0000 Message-ID: <87ldwa7nld.fsf@protonmail.com> References: <87frml9cy4.fsf@protonmail.com> <875xng9g48.fsf@protonmail.com> <87ttaz98q1.fsf@protonmail.com> Reply-To: Pip Cet Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37935"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Andrea Corallo , =?utf-8?Q?Gerd_M=C3=B6llmann?= , Eli Zaretskii , emacs-devel@gnu.org, monnier@iro.umontreal.ca To: Stefan Kangas Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 20 13:11:46 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 1tObr6-0009aD-H0 for ged-emacs-devel@m.gmane-mx.org; Fri, 20 Dec 2024 13:11:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tObpx-0007kB-9T; Fri, 20 Dec 2024 07:10:35 -0500 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 1tOYaz-00040i-LY for emacs-devel@gnu.org; Fri, 20 Dec 2024 03:42:53 -0500 Original-Received: from mail-10631.protonmail.ch ([79.135.106.31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOYax-0000IV-0l; Fri, 20 Dec 2024 03:42:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1734684166; x=1734943366; bh=vpEngvbOfi/ezX8BZyk7xgTjP698WZwWxktdezIXiwg=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=szjJrNjcTOGJcLgWPgr+f/zpFFkWNzWjX66DmKt4oPNRRqoBzWEsGytQJZVPwcOiA +UbZy55KEtBAkXjyRaswqdoEpYH7rp+Dvd9YgHEYXIRMICJujw71Wu+EYbGO+RxH+T 3TsWqxZq1SU32p1ERljDQPOeLldTVtoGpSeU2ZqPQNrf5/6q87S9jwqp6/3Tpi8qSP jydo+JVYr5l440It5OVDtoo9qAJF3WwBF4hJuOBJrdX0BAK8twSiMPcCunIFAsywHW CXBHv+xgzEaX3bVBgjpn8Kp/N9NI/ZFfOWZXqNPn9Cb6COQJkaCjhgSBjXKpga7qv+ DrBq2CB3GiUog== In-Reply-To: Feedback-ID: 112775352:user:proton X-Pm-Message-ID: 9177c4fc8466513dcf1ddc015e77dbd436285a51 Received-SPF: pass client-ip=79.135.106.31; envelope-from=pipcet@protonmail.com; helo=mail-10631.protonmail.ch 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 20 Dec 2024 07:10:26 -0500 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:326796 Archived-At: Pip Cet writes: > But I'll try to come up with a patch doing the simple #1# thing first. Easy enough to do, but it doesn't solve the read-circle problem (which appears to affect autoloaded .elc files as well as .eln files, so it's probably best to discuss that in a separate bug report once this is merged). >From 6f4133b54edc890993d6198940800cc9a19df85c Mon Sep 17 00:00:00 2001 From: Pip Cet Date: Fri, 20 Dec 2024 07:53:38 +0000 Subject: [PATCH] Use circular references as placeholders in nativecomp relo= cs * lisp/emacs-lisp/comp.el (comp--finalize-container): Use temporary placeholder rather than `--lambda-fixup'. * src/comp.c (declare_imported_data_relocs): Replace temporary placeholders by permanent placeholders. (check_comp_unit_relocs): Check for circular reference instead of `--lambda-fixup'. (syms_of_comp): Remove `--lambda-fixup'. * src/pdumper.c (dump_do_dump_relocation): Check for circular reference instead of `--lambda-fixup'. --- lisp/emacs-lisp/comp.el | 8 ++++---- src/comp.c | 14 ++++++++++---- src/pdumper.c | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index ab6fd77f11a..d5351fe440d 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -3254,10 +3254,10 @@ comp--finalize-container ;; from the corresponding m-var. collect (if (gethash obj (comp-ctxt-byte-func-to-func-h comp-= ctxt)) - ;; Hack not to have `--lambda-fixup' in - ;; data relocations as it would trigger the - ;; check in 'check_comp_unit_relocs'. - (intern (concat (make-string 1 ?-) "-lambda-f= ixup")) + ;; Temporary placeholder, to be replaced by + ;; a circular reference to the vector + ;; containing the element + (comp-data-container-idx cont) obj)))) =20 (defun comp--finalize-relocs () diff --git a/src/comp.c b/src/comp.c index 8b38adec252..3b3dfa58602 100644 --- a/src/comp.c +++ b/src/comp.c @@ -2854,13 +2854,20 @@ emit_static_object (const char *name, Lisp_Object o= bj) declare_imported_data_relocs (Lisp_Object container, const char *code_symb= ol, =09=09=09 const char *text_symbol) { + Lisp_Object index_table =3D + CALL1I (comp-data-container-idx, container); /* Imported objects. */ reloc_array_t res; res.len =3D - XFIXNUM (CALL1I (hash-table-count, -=09=09 CALL1I (comp-data-container-idx, container))); + XFIXNUM (CALL1I (hash-table-count, index_table)); Lisp_Object d_reloc =3D CALL1I (comp-data-container-l, container); d_reloc =3D Fvconcat (1, &d_reloc); + /* Replace temporary placeholders, turning them into circular + * references to the vector itself. */ + EMACS_INT n =3D XFIXNUM (Flength (d_reloc)); + for (EMACS_INT i =3D 0; i < n; i++) + if (EQ (AREF (d_reloc, i), index_table)) + ASET (d_reloc, i, d_reloc); =20 res.r_val =3D gcc_jit_lvalue_as_rvalue ( @@ -5173,7 +5180,7 @@ check_comp_unit_relocs (struct Lisp_Native_Comp_Unit = *comp_u) for (ptrdiff_t i =3D 0; i < d_vec_len; i++) { Lisp_Object x =3D data_relocs[i]; - if (EQ (x, Q__lambda_fixup)) + if (EQ (x, comp_u->data_vec)) =09return false; else if (NATIVE_COMP_FUNCTIONP (x)) =09{ @@ -5622,7 +5629,6 @@ syms_of_comp (void) DEFSYM (Qfixnum, "fixnum"); DEFSYM (Qscratch, "scratch"); DEFSYM (Qlate, "late"); - DEFSYM (Q__lambda_fixup, "--lambda-fixup"); DEFSYM (Qgccjit, "gccjit"); DEFSYM (Qcomp_subr_trampoline_install, "comp-subr-trampoline-install"); DEFSYM (Qnative_comp_warning_on_missing_source, diff --git a/src/pdumper.c b/src/pdumper.c index d45bbc84bba..956da4d8c72 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -5504,7 +5504,7 @@ dump_do_dump_relocation (const uintptr_t dump_base, =09 XSETSUBR (tem, subr); =09 Lisp_Object *fixup =3D =09 &(comp_u->data_relocs[XFIXNUM (lambda_data_idx)]); -=09 eassert (EQ (*fixup, Q__lambda_fixup)); +=09 eassert (EQ (*fixup, comp_u->data_vec)); =09 *fixup =3D tem; =09 Fputhash (tem, Qt, comp_u->lambda_gc_guard_h); =09 } --=20 2.47.0