From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.devel Subject: Re: MPS: Please check if scratch/igc builds with native compilation Date: Thu, 23 May 2024 16:46:10 +0200 Message-ID: <87y18060y5.fsf@gmail.com> References: <87r0du5rly.fsf@gmail.com> <87le425p8i.fsf@gmail.com> <87ed9u5lbi.fsf@gmail.com> <87ikz56j66.fsf@gmail.com> <87cypc7v8y.fsf@gmail.com> <878r007tpf.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23806"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Andrea Corallo , Emacs Devel , Eli Zaretskii To: Gerd =?utf-8?Q?M=C3=B6llmann?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu May 23 16:47:13 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 1sA9iq-0005ym-Ii for ged-emacs-devel@m.gmane-mx.org; Thu, 23 May 2024 16:47:12 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sA9i3-0003fV-FH; Thu, 23 May 2024 10:46:23 -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 1sA9hy-0003eH-8k for emacs-devel@gnu.org; Thu, 23 May 2024 10:46:18 -0400 Original-Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sA9hv-0001xQ-HW; Thu, 23 May 2024 10:46:17 -0400 Original-Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5755fafa5a7so6905000a12.1; Thu, 23 May 2024 07:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716475573; x=1717080373; 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=5Q0jf3yycy3OlJUbDthDNa9obzSkcLLp7GPW8GCEJYU=; b=B1Xdo5Gwm/mHhIt/HtttXJmiHuMBAHSulpXiX3T3rMXfLwFklyWdbbEo480dTFtr2e 7KQFLtwtNNaz0aynJajL5TGuYIh0WUOZHSWgwU0U0ruVRgynHZrf0ENR28CaBPsJTJvE pL8Jy46lcEm/unhUlJSAClGEzuHe1fXLsnfLImfuONAIwNPCQaZNvbUrE0k0yOxSyiqE gwOpE+zGqeeWvqumPYCafpzXCaG3PUOLZqz7gh9Ic/h6JEvk5T7LZ3E7eXHxHuXRJ4S1 SBqqFnn2WZnQG4TgQpZHD+LAJ2EbN1FENdzLbrUtOwoRomCOOc4ClMMSj1B1wzSeB+zm 7zgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716475573; x=1717080373; 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=5Q0jf3yycy3OlJUbDthDNa9obzSkcLLp7GPW8GCEJYU=; b=UW46WSV6Nhv5+1exkhmwYSFtq7Bjw0IEWLfIdauO3QEnS23YabKTgRMU7cAhkBNejl JPsOmDE+0KTiQ9zAOe54CpKsct0PimO5QUizuA5VMsTF2sTwfd7I1r1hDZsYvPLUkZyW 2ONQEUCrGwXRu6Bznevhq/Ka83sMZ8SHxvFnBxVtuwaeU1W+wsN7qEVUcJ2u+SU8MzXe roIIYk86px7iut+8hK1c4m6MeJaUc8nAOCCWwRXvefa55ZJEDnAM1ZBYwgTcRiH6Va5s C0yUB+cP/hVLLvxI1xBDfYGTL5S+EJUnVGdXUq5TsSqsru2Jbn+DRnfP/PMaBZav6H3k pu4Q== X-Forwarded-Encrypted: i=1; AJvYcCUjHyR4yrw0B7Ke6h5JXw/fJzqp/8iPZ4ecRb3dMmynFFbefjxzvnEowvkXPjK7fLy939uNW2pDK3dqHGZcqaIFWHsXOhuuA0fxv4W+mqAKS60= X-Gm-Message-State: AOJu0YyNUTuzpJ5zLaTiJpDRGhQ76lCi5S5M2O0O9tbMgtn2DV0zBQ+K x3GpLlgRbgadpeJPhJikceHdDMbS3Z0tch7y921hMURlHYFPx9ZQTOnRvw== X-Google-Smtp-Source: AGHT+IHzALw51PdgR4UtKdX1ixlJPbme8vVOUZOw8yPGKUKAMab7jNBtZGIwso8yTkfGWmTABHXeKw== X-Received: by 2002:a17:906:7d3:b0:a5d:edb:6d59 with SMTP id a640c23a62f3a-a62281c8137mr316408066b.73.1716475572801; Thu, 23 May 2024 07:46:12 -0700 (PDT) Original-Received: from caladan (dial-188233.pool.broadband44.net. [212.46.188.233]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a17b01647sm1941017166b.160.2024.05.23.07.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 07:46:12 -0700 (PDT) In-Reply-To: ("Gerd =?utf-8?Q?M=C3=B6llman?= =?utf-8?Q?n=22's?= message of "Thu, 23 May 2024 12:19:56 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=eller.helmut@gmail.com; helo=mail-ed1-x532.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:319525 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Thu, May 23 2024, Gerd M=C3=B6llmann wrote: > I'll let it rest a bit now. When you have some time to spare, could you try the patch below? I think that load_static_obj can trigger GC and we should be prepared for that. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Register-roots-for-comp-units-earlier.patch >From 000702e21a347d3bdd2b74d025ed9f358a2b6702 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Thu, 23 May 2024 16:42:06 +0200 Subject: [PATCH] Register roots for comp units earlier --- src/comp.c | 23 +++++++++++------------ src/comp.h | 5 ++++- src/igc.c | 46 +++++++++++++++++++++++----------------------- src/igc.h | 3 +++ 4 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/comp.c b/src/comp.c index fdf99d51c78..a3756857205 100644 --- a/src/comp.c +++ b/src/comp.c @@ -5369,6 +5369,7 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump, #ifdef HAVE_MPS comp_u->data_relocs = dynlib_sym (handle, DATA_RELOC_SYM); comp_u->comp_unit = dynlib_sym (handle, COMP_UNIT_SYM); + comp_u->comp_unit_root = igc_root_create_n (saved_cu, 1); #endif if (!comp_u->loaded_once) @@ -5418,6 +5419,8 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump, EMACS_INT d_vec_len = XFIXNUM (Flength (comp_u->data_vec)); #ifdef HAVE_MPS comp_u->n_data_relocs = d_vec_len; + if (d_vec_len > 0) + comp_u->data_relocs_root = igc_root_create_n (data_relocs, d_vec_len); #endif for (EMACS_INT i = 0; i < d_vec_len; i++) data_relocs[i] = AREF (comp_u->data_vec, i); @@ -5425,6 +5428,9 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump, d_vec_len = XFIXNUM (Flength (comp_u->data_impure_vec)); #ifdef HAVE_MPS comp_u->n_data_imp_relocs = d_vec_len; + if (d_vec_len > 0) + comp_u->data_imp_relocs_root + = igc_root_create_n (data_imp_relocs, d_vec_len); #endif for (EMACS_INT i = 0; i < d_vec_len; i++) data_imp_relocs[i] = AREF (comp_u->data_impure_vec, i); @@ -5452,22 +5458,19 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump, load_static_obj (comp_u, TEXT_DATA_RELOC_EPHEMERAL_SYM); EMACS_INT d_vec_len = XFIXNUM (Flength (data_ephemeral_vec)); - for (EMACS_INT i = 0; i < d_vec_len; i++) - data_eph_relocs[i] = AREF (data_ephemeral_vec, i); # ifdef HAVE_MPS /* FIXME: If we want to get rid of these objects, stop tracing these references at some point. */ comp_u->data_eph_relocs = data_eph_relocs; comp_u->n_data_eph_relocs = d_vec_len; + if (d_vec_len > 0) + comp_u->data_eph_relocs_root + = igc_root_create_n (data_eph_relocs, d_vec_len); # endif + for (EMACS_INT i = 0; i < d_vec_len; i++) + data_eph_relocs[i] = AREF (data_ephemeral_vec, i); } - /* FIXME: Remvoe eph root once it is no longer needed. */ -# ifdef HAVE_MPS - if (comp_u->igc_info == NULL) - igc_root_create_comp_unit (comp_u); -# endif - /* Executing this will perform all the expected environment modifications. */ res = top_level_run (comp_u_lisp_obj); @@ -5477,10 +5480,6 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump, eassert (check_comp_unit_relocs (comp_u)); } -# ifdef HAVE_MPS - if (comp_u->igc_info == NULL) - igc_root_create_comp_unit (comp_u); -# endif if (!recursive_load) /* Clean-up the load ongoing flag in case. */ diff --git a/src/comp.h b/src/comp.h index e2ff7296722..c48e93a0242 100644 --- a/src/comp.h +++ b/src/comp.h @@ -54,7 +54,10 @@ #define COMP_H Lisp_Object *data_eph_relocs; size_t n_data_eph_relocs; Lisp_Object *comp_unit; - void *igc_info; + struct igc_root *data_relocs_root; + struct igc_root *data_imp_relocs_root; + struct igc_root *data_eph_relocs_root; + struct igc_root *comp_unit_root; # endif bool loaded_once; bool load_ongoing; diff --git a/src/igc.c b/src/igc.c index 7cb42722a85..dc4512713f7 100644 --- a/src/igc.c +++ b/src/igc.c @@ -1724,7 +1724,9 @@ fix_terminal (mps_ss_t ss, struct terminal *t) { IGC_FIX_CALL_FN (ss, struct Lisp_Vector, t, fix_vectorlike); IGC_FIX12_RAW (ss, &t->next_terminal); +#ifdef HAVE_WINDOW_SYSTEM IGC_FIX12_RAW (ss, &t->image_cache); +#endif // These are malloc'd, so they can be accessed. IGC_FIX_CALL_FN (ss, struct coding_system, t->keyboard_coding, fix_coding); IGC_FIX_CALL_FN (ss, struct coding_system, t->terminal_coding, fix_coding); @@ -2190,37 +2192,33 @@ root_create_exact_n (Lisp_Object *start, size_t n) return root_create_exact (global_igc, start, start + n, scan_exact); } +struct igc_root * +igc_root_create_n (Lisp_Object start[], size_t n) +{ + return (struct igc_root *)root_create_exact_n (start, n); +} + +void +igc_root_destroy (struct igc_root **root) +{ + destroy_root ((struct igc_root_list **)root); +} + void igc_root_create_comp_unit (struct Lisp_Native_Comp_Unit *u) { - struct igc_cu_roots *r = xzalloc (sizeof *r); - if (u->n_data_relocs) - r->data_relocs = root_create_exact_n (u->data_relocs, u->n_data_relocs); - if (u->n_data_imp_relocs) - r->data_imp_relocs - = root_create_exact_n (u->data_imp_relocs, u->n_data_imp_relocs); - if (u->n_data_eph_relocs) - r->data_eph_relocs - = root_create_exact_n (u->data_eph_relocs, u->n_data_eph_relocs); - r->comp_unit = root_create_exact_n (u->comp_unit, 1); - igc_assert (u->igc_info == NULL); - u->igc_info = r; } void igc_root_destroy_comp_unit (struct Lisp_Native_Comp_Unit *u) { - igc_assert (u->igc_info != NULL); - struct igc_cu_roots *r = u->igc_info; - if (r->data_relocs) - destroy_root (&r->data_relocs); - if (r->data_imp_relocs) - destroy_root (&r->data_imp_relocs); - if (r->data_eph_relocs) - destroy_root (&r->data_eph_relocs); - destroy_root (&r->comp_unit); - xfree (r); - u->igc_info = NULL; + if (u->data_relocs_root) + igc_root_destroy (&u->data_relocs_root); + if (u->data_imp_relocs_root) + igc_root_destroy (&u->data_imp_relocs_root); + if (u->data_eph_relocs_root) + igc_root_destroy (&u->data_eph_relocs_root); + igc_root_destroy (&u->comp_unit_root); } static mps_res_t @@ -3211,12 +3209,14 @@ igc_grow_ptr_vec (ptrdiff_t *n, ptrdiff_t n_incr_min, ptrdiff_t n_max) return new_vec; } +#ifdef HAVE_WINDOW_SYSTEM struct image_cache * igc_make_image_cache (void) { struct image_cache *c = alloc (sizeof *c, IGC_OBJ_IMAGE_CACHE); return c; } +#endif DEFUN ("igc-make-weak-ref", Figc_make_weak_ref, Sigc_make_weak_ref, 1, 1, 0, doc diff --git a/src/igc.h b/src/igc.h index 25b37a8ac41..fb37ce22e22 100644 --- a/src/igc.h +++ b/src/igc.h @@ -131,6 +131,9 @@ #define EMACS_IGC_H void igc_root_create_exact_ptr (void *var_addr); void igc_root_create_comp_unit (struct Lisp_Native_Comp_Unit *u); void igc_root_destroy_comp_unit (struct Lisp_Native_Comp_Unit *u); +struct igc_root; +struct igc_root *igc_root_create_n (Lisp_Object start[], size_t n); +void igc_root_destroy (struct igc_root **); struct Lisp_Weak_Ref; Lisp_Object igc_weak_ref_deref (struct Lisp_Weak_Ref *); -- 2.39.2 --=-=-=--