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: Forwording symbols Date: Thu, 20 Jun 2024 16:18:59 +0200 Message-ID: <87le2z4rzg.fsf@gmail.com> References: <87jziod6yc.fsf@gmail.com> <874j9rcuf6.fsf@gmail.com> <87y173bda9.fsf@gmail.com> <87plsfbcd5.fsf@gmail.com> <87iky6boz7.fsf@gmail.com> <878qz2bh3u.fsf@gmail.com> <87le3282mh.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="12551"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 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 Jun 20 16:19:34 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 1sKIdR-00038c-Rj for ged-emacs-devel@m.gmane-mx.org; Thu, 20 Jun 2024 16:19:34 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKId2-0000ch-QN; Thu, 20 Jun 2024 10:19:08 -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 1sKId0-0000cD-C8 for emacs-devel@gnu.org; Thu, 20 Jun 2024 10:19:06 -0400 Original-Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKIcx-0004Lq-7C; Thu, 20 Jun 2024 10:19:05 -0400 Original-Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-57ccd1111aeso1093588a12.0; Thu, 20 Jun 2024 07:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718893141; x=1719497941; 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=eMkg4cGGyD1EqTDNLCQIhXcKVnhy4JTOh1BHNTcIRjs=; b=Wc8pDeVrxUAlMXGOltRRWEtvBFsvbA64rSm65tppLfOBr6U4Lq63I9LoUKYJTcwUhA w1M86YSD1k3uGOly8E9Vz5SnBYcTB2yMloNZ/9vnB3zowWZFVmPYNRaLeCll+IKroTkR AwSrZ84MgzCK6xvNtnpVWEAiykXwKBRq58WLNe2/ir/vdWlRZ0IxUPEZCOzsAiceyC7n lpZ5ffkWDe1ERHc8Ly3j/9PBRFKiscXhenE/haZNZ7TeqxqHbuqReThEsCRms1odpHzT AfbcBq2MoDT+nUpXp0RO5o7mlnpRcqdx8vJ+FHSHfU1uviwGztM4FdXwtsgN81LRLsmi c7ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718893141; x=1719497941; 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=eMkg4cGGyD1EqTDNLCQIhXcKVnhy4JTOh1BHNTcIRjs=; b=nZY+PS4ea99HWPDpShFCF/5lZ5frwI25t/VdXH18F32tXfQ1XwR/oqVEBY0xmMgV7W yeLWebAL4AWGddhsi10jbQNoIhPoinlwjvSCTt0kWMgc+tbrMZ/Ir34AeYwu0NEGtInF 7qUsfgKkJ3rDqZJUiABbw95XuB3v42xXprnlpkf/1okgFOkxx8u99m+/WUCTlHAehUw7 GRTiNdkGp10Bm2ogv+4DACIoOZ4Ay7a+kQy9jRp+gna5cJaWr2xKmOAJZV3O3DJN9O/8 v2O3Fum/JUuvSvZkOz44Mh8uiG9N+0wl/n7PgHxgN0Xoy2LB9nv/YukbwMZeNqy/HVQ0 ILLA== X-Forwarded-Encrypted: i=1; AJvYcCUncCA53T/Usk/OrLH59woPQYX5Maeq5bmhNinVpm3AE55SUkhUgvFwPP4+B8aOwt2NXQlcaAFkXTAQ6wg= X-Gm-Message-State: AOJu0Yz0p5jSu5Dr1F5ROocwogR5lyLVM3kSsj/gqn8F5DGcYqaR5uSy czTD3fsx/YjgiLND4FFd/mPPnqZsIDN4JA09t2gWkEgo9+GTO/n4rQYIqQ== X-Google-Smtp-Source: AGHT+IGqbg58dA7XXHREeuoIoNpCZbm/5PG/hYQyui30QQpqbrXvHu6im2v0iqJYN7su+tF5w2Tuag== X-Received: by 2002:a50:8d5a:0:b0:57c:6740:f47c with SMTP id 4fb4d7f45d1cf-57d07eabd35mr3503360a12.27.1718893140758; Thu, 20 Jun 2024 07:19:00 -0700 (PDT) Original-Received: from caladan ([31.177.116.19]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57cb7439070sm9825388a12.85.2024.06.20.07.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 07:19:00 -0700 (PDT) In-Reply-To: ("Gerd =?utf-8?Q?M=C3=B6llman?= =?utf-8?Q?n=22's?= message of "Tue, 18 Jun 2024 21:55:56 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=eller.helmut@gmail.com; helo=mail-ed1-x533.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, T_SCC_BODY_TEXT_LINE=-0.01 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:320323 Archived-At: --=-=-= Content-Type: text/plain I added labels to some roots so that the telemetry data is easier to interpret. When recording telemetry with MPS_TELEMETRY_CONTROL="all" MPS_TELEMETRY_FILENAME=/tmp/mpsio.log ../src/emacs -Q --batch -l lisp/emacs-lisp/ert-tests.el --eval '(ert-run-tests-batch-and-exit "ert-test-\\(parse\\|plist\\|record\\|run-tests-batch-exp\\)")' and displaying it with this SQL statement: select root,label,avg(delta),min(delta),max(delta),count(*) as count from (select root, (select I.string from EVENT_Intern AS I, EVENT_Label AS L where I.stringId = L.stringId and R.root=L.address) as label,time, time - lag(time) over (order by time) as delta from (select root,time from EVENT_RootScan union select 'flip',time from EVENT_TraceFlipBegin) R) group by root order by avg(delta) ; I get this: label avg(delta) min(delta) max(delta) count -------------- ---------------- ---------- ---------- ----- "exact-ptr 675.666666666667 462 914 3 "rdstack 987.0 903 1113 3 "xpalloc-exact 1130.33333333333 1029 1186 3 "dump-pins 1680.0 1554 1890 3 "xzalloc-ambig 2723.0 2667 2761 3 "main-thread 3940.66666666667 2656 4798 3 "pure 15088.6666666667 12800 17010 3 "exact 16992.6666666667 16527 17346 3 "terminal-list 28983.6666666667 3076 78950 3 "specpdl 41100.3333333333 11046 76744 3 "buffer 44033.3333333333 21934 87843 3 "bc-stack 139762.0 124866 155557 3 "create-thread 158259.333333333 150224 172525 3 "charset-table 179802.0 85963 320555 3 "buffer 468265.0 219009 628425 3 "staticvec 539668.333333333 69006 798409 3 "kdb-buffer 612549.0 373380 925365 3 "lispsym 1778728.33333333 230528 2853050 3 The numbers are the duration for scanning the root, in cycles; multiply with 400 picoseconds (or whatever you think is appropriate for one cycle) to get the time. E.g. for lispsym, the maximum was 2853050 * 400e-12 =~ 1.1 millisecond. That's down from 10 milliseconds it used to take to scan the dump. I expected that staticvec to be at the top, but I guess lispsym actually makes sense. It's strange though, that the maximum and minimum for lispsym vary so much. I general, ert-tests.el is quite strange. To run all tests in there with: make lisp/emacs-lisp/ert-tests requires almost 4GB peak, but when running ert-test-run-tests-batch-expensive alone, it requires much less than that. Here are the patches for this: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Introduce-RELOC_BUFFER.patch >From b4e3eb5f8a72657cbe39dab8709fd4bf90d77129 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Wed, 19 Jun 2024 10:20:26 +0200 Subject: [PATCH 1/6] Introduce RELOC_BUFFER Use the dump_relocs mechanism instead of relying on Vbuffer_alist to find all existing buffers. * src/pdumper.c (dump_buffer, dump_do_dump_relocation): Create a RELOC_BUFFER. * src/igc.c (igc_on_pdump_loaded): Remove the buffer related code. --- src/igc.c | 9 --------- src/pdumper.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/igc.c b/src/igc.c index 4c688aa5ddb..9b909310e92 100644 --- a/src/igc.c +++ b/src/igc.c @@ -3952,15 +3952,6 @@ igc_on_pdump_loaded (void *dump_base, void *hot_start, void *hot_end, igc_root_create_ambig (pinned_objects_in_dump, (uint8_t *)pinned_objects_in_dump + sizeof pinned_objects_in_dump); - - /* Copy to buffer text to out of pdump */ - for (Lisp_Object l = Vbuffer_alist; !NILP (l); l = XCDR (l)) - { - struct buffer *buf = XBUFFER (XCDR (XCAR (l))); - eassert (pdumper_object_p (buf->text->beg)); - enlarge_buffer_text (buf, 0); - eassert (!pdumper_object_p (buf->text->beg)); - } } void * diff --git a/src/pdumper.c b/src/pdumper.c index e0ff395fd94..27717eea9c8 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -181,6 +181,9 @@ #define dump_offsetof(type, member) \ RELOC_NATIVE_COMP_UNIT, RELOC_NATIVE_SUBR, RELOC_BIGNUM, +#ifdef HAVE_MPS + RELOC_BUFFER, +#endif /* dump_lv = make_lisp_ptr (dump_lv + dump_base, type - RELOC_DUMP_TO_DUMP_LV) (Special case for symbols: make_lisp_symbol) @@ -2870,6 +2873,11 @@ dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer) dump_remember_cold_op (ctx, COLD_OP_BUFFER, make_lisp_ptr ((void *) in_buffer, Lisp_Vectorlike)); +#ifdef HAVE_MPS + dump_push (&ctx->dump_relocs[LATE_RELOCS], + list2 (make_fixnum (RELOC_BUFFER), + dump_off_to_lisp (ctx->obj_offset))); +#endif } else eassert (buffer->own_text.beg == NULL); @@ -5759,6 +5767,18 @@ dump_do_dump_relocation (const uintptr_t dump_base, mpz_roinit_n (bignum->value, limbs, reload_info.nlimbs); break; } +#ifdef HAVE_MPS + case RELOC_BUFFER: + { + /* When resurrecting, copy the text out of the dump so that we + can collect the dumped text. */ + struct buffer *b = dump_ptr (dump_base, reloc_offset); + eassert (pdumper_object_p (b->text->beg)); + enlarge_buffer_text (b, 0); + eassert (!pdumper_object_p (b->text->beg)); + } + break; +#endif default: /* Lisp_Object in the dump; precise type in reloc.type */ { Lisp_Object lv = dump_make_lv_from_reloc (dump_base, reloc); -- 2.39.2 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Shrink-dump_public-after-the-dump-is-initialized.patch >From 492d9698b411045c757b1e1d5cac59a0e3262957 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Wed, 19 Jun 2024 10:29:46 +0200 Subject: [PATCH 2/6] Shrink dump_public after the dump is initialized * src/pdumper.c (pdumper_load): Set dump_public to the pinned region from cold_user_data_start to heap_end. This should reduce the probability that pdumper_object_p is misused. --- src/pdumper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pdumper.c b/src/pdumper.c index 27717eea9c8..27b84707fcc 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -6086,6 +6086,11 @@ pdumper_load (const char *dump_filename, char *argv0) for (int i = 0; i < nr_dump_late_hooks; ++i) dump_late_hooks[i] (); +#ifdef HAVE_MPS + dump_public.start = (uintptr_t)cold_user_data_start; + dump_public.end = (uintptr_t)heap_end; +#endif + initialized = true; struct timespec load_timespec = -- 2.39.2 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-Minor-changes.patch >From d7c51a03896a01bcac9d846139f8529d3ac6fdc2 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Wed, 19 Jun 2024 10:53:50 +0200 Subject: [PATCH 3/6] Minor changes * src/igc.c (igc_alloc_dump): Let nbytes be the size without header. (dump_mmap_contiguous_mps): Update accordingly. (dump_field_fwd): Use &in_field->fwdptr instead of in_field. --- src/igc.c | 7 ++++--- src/pdumper.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/igc.c b/src/igc.c index 9b909310e92..9eb55e06000 100644 --- a/src/igc.c +++ b/src/igc.c @@ -3959,15 +3959,16 @@ igc_alloc_dump (size_t nbytes) { igc_assert (global_igc->park_count > 0); mps_ap_t ap = thread_ap (IGC_OBJ_CONS); + size_t block_size = igc_header_size () + nbytes; mps_addr_t block; do { - mps_res_t res = mps_reserve (&block, ap, nbytes); + mps_res_t res = mps_reserve (&block, ap, block_size); if (res != MPS_RES_OK) memory_full (0); + set_header (block, IGC_OBJ_INVALID, block_size, 0); } - while (!mps_commit (ap, block, nbytes)); - set_header (block, IGC_OBJ_INVALID, nbytes, 0); + while (!mps_commit (ap, block, block_size)); return base_to_client (block); } diff --git a/src/pdumper.c b/src/pdumper.c index 27b84707fcc..6f0ca3233bb 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -2362,7 +2362,7 @@ dump_float (struct dump_context *ctx, const struct Lisp_Float *lfloat) dump_field_fwd (struct dump_context *ctx, void *out, const void *in_start, const lispfwd *in_field) { - dump_field_emacs_ptr (ctx, out, in_start, in_field); + dump_field_emacs_ptr (ctx, out, in_start, &in_field->fwdptr); switch (XFWDTYPE (*in_field)) { case Lisp_Fwd_Int: @@ -5101,7 +5101,7 @@ dump_mmap_release_mps (struct dump_memory_map *map) dump_mmap_contiguous_mps (struct dump_memory_map *maps, int nr_maps, size_t total_size) { - uint8_t *p = igc_alloc_dump (igc_header_size () + total_size); + uint8_t *p = igc_alloc_dump (total_size); for (size_t i = 0; i < nr_maps; ++i) { struct dump_memory_map *map = &maps[i]; -- 2.39.2 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0004-When-resurrecting-buffers-copy-markers-to-a-weak-vec.patch >From a1bbbc0c1328e1adda65ee7e5f074796069a2b1e Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Thu, 20 Jun 2024 08:47:56 +0200 Subject: [PATCH 4/6] When resurrecting buffers, copy markers to a weak vector * src/igc.h (igc_resurrect_markers): New. * src/igc.c (igc_resurrect_markers): Implementation. (weak_vector_p): New helper. * src/pdumper.c (dump_do_dump_relocation): Use igc_resurrect_markers. --- src/igc.c | 29 +++++++++++++++++++++++++++++ src/igc.h | 1 + src/pdumper.c | 1 + 3 files changed, 31 insertions(+) diff --git a/src/igc.c b/src/igc.c index 9eb55e06000..a464aee07c2 100644 --- a/src/igc.c +++ b/src/igc.c @@ -3522,6 +3522,35 @@ igc_remove_all_markers (struct buffer *b) } } +static bool +weak_vector_p (Lisp_Object x) +{ + if (VECTORP (x)) + { + struct igc *igc = global_igc; + mps_pool_t pool = NULL; + mps_addr_pool (&pool, igc->arena, XVECTOR (x)); + return pool == igc->weak_pool; + } + else + return false; +} + +void +igc_resurrect_markers (struct buffer *b) +{ + Lisp_Object old = BUF_MARKERS (b); + if (NILP (old)) + return; + igc_assert (!weak_vector_p (old)); + size_t len = ASIZE (old); + Lisp_Object new = alloc_vector_weak (len, Qnil); + memcpy (XVECTOR (new)->contents, XVECTOR (old)->contents, + len * sizeof (Lisp_Object)); + BUF_MARKERS (b) = new; + igc_assert (weak_vector_p (BUF_MARKERS (b))); +} + DEFUN ("igc-make-weak-vector", Figc_make_weak_vector, Sigc_make_weak_vector, 2, 2, 0, doc: /* Return a new weak vector of length LENGTH, with each element being INIT. See also the function `vector'. */) diff --git a/src/igc.h b/src/igc.h index 55ef7d4d56c..cd782fca0ca 100644 --- a/src/igc.h +++ b/src/igc.h @@ -79,6 +79,7 @@ #define EMACS_IGC_H void igc_add_marker (struct buffer *b, struct Lisp_Marker *m); void igc_remove_marker (struct buffer *b, struct Lisp_Marker *m); void igc_remove_all_markers (struct buffer *b); +void igc_resurrect_markers (struct buffer *b); Lisp_Object igc_alloc_symbol (void); void *igc_alloc_global_ref (void); diff --git a/src/pdumper.c b/src/pdumper.c index 6f0ca3233bb..e69a2b56f0b 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -5776,6 +5776,7 @@ dump_do_dump_relocation (const uintptr_t dump_base, eassert (pdumper_object_p (b->text->beg)); enlarge_buffer_text (b, 0); eassert (!pdumper_object_p (b->text->beg)); + igc_resurrect_markers (b); } break; #endif -- 2.39.2 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0005-When-creating-roots-allow-to-record-a-debug-name.patch >From be160fc73f081824cea5f6ffd51d8702e0e93a72 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Thu, 20 Jun 2024 14:04:59 +0200 Subject: [PATCH 5/6] When creating roots, allow to record a debug-name * src/igc.c (register_root): Create a telemetry label for the debug_name. (root_create, root_create_ambig, root_create_exact) (igc_root_create_ambig): New debug_name argument. (root_create_staticvec, root_create_lispsym, root_create_buffer) (root_create_terminal_list, root_create_main_thread) (igc_root_create_exact, igc_root_create_exact_ptr, root_create_specpdl) (root_create_bc, root_create_charset_table, root_create_pure) (root_create_thread, igc_grow_rdstack, root_create_exact_n) (igc_xalloc_lisp_objs_exact, igc_xzalloc_ambig, igc_realloc_ambig) (igc_xpalloc_ambig, igc_xpalloc_exact, igc_xnrealloc_ambig) (igc_on_pdump_loaded): Set debug_name. * src/igc.c (igc_root_create_ambig): New debug_name argument. * src/keyboard.c (init_keyboard): Set debug_name. --- src/igc.c | 82 ++++++++++++++++++++++++++++++-------------------- src/igc.h | 2 +- src/keyboard.c | 3 +- 3 files changed, 53 insertions(+), 34 deletions(-) diff --git a/src/igc.c b/src/igc.c index a464aee07c2..627f88acf4d 100644 --- a/src/igc.c +++ b/src/igc.c @@ -581,10 +581,16 @@ arena_release (struct igc *gc) static struct igc_root_list * register_root (struct igc *gc, mps_root_t root, void *start, void *end, - bool ambig) + bool ambig, const char *debug_name) { - struct igc_root r - = { .gc = gc, .root = root, .start = start, .end = end, .ambig = ambig }; + if (debug_name && (mps_telemetry_get () & (1 << 6))) + { + mps_label_t label = mps_telemetry_intern (debug_name); + mps_telemetry_label (root, label); + } + struct igc_root r = { + .gc = gc, .root = root, .start = start, .end = end, .ambig = ambig + }; return igc_root_list_push (&gc->roots, &r); } @@ -2101,48 +2107,52 @@ scan_cell_callback (struct igc_opaque *op, Lisp_Object *addr) static igc_root_list * root_create (struct igc *gc, void *start, void *end, mps_rank_t rank, - mps_area_scan_t scan, void *closure, bool ambig) + mps_area_scan_t scan, void *closure, bool ambig, + const char *debug_name) { mps_root_t root; mps_res_t res = mps_root_create_area (&root, gc->arena, rank, 0, start, end, scan, closure); IGC_CHECK_RES (res); - return register_root (gc, root, start, end, ambig); + return register_root (gc, root, start, end, ambig, debug_name); } static igc_root_list * -root_create_ambig (struct igc *gc, void *start, void *end) +root_create_ambig (struct igc *gc, void *start, void *end, + const char *debug_name) { return root_create (gc, start, end, mps_rank_ambig (), scan_ambig, NULL, - true); + true, debug_name ? debug_name : "ambig"); } static igc_root_list * root_create_exact (struct igc *gc, void *start, void *end, - mps_area_scan_t scan) + mps_area_scan_t scan, const char *debug_name) { - return root_create (gc, start, end, mps_rank_exact (), scan, NULL, false); + return root_create (gc, start, end, mps_rank_exact (), scan, NULL, false, + debug_name); } static void root_create_staticvec (struct igc *gc) { root_create_exact (gc, staticvec, staticvec + ARRAYELTS (staticvec), - scan_staticvec); + scan_staticvec, "staticvec"); } static void root_create_lispsym (struct igc *gc) { - root_create_exact (gc, lispsym, lispsym + ARRAYELTS (lispsym), scan_lispsym); + root_create_exact (gc, lispsym, lispsym + ARRAYELTS (lispsym), + scan_lispsym, "lispsym"); } static void root_create_buffer (struct igc *gc, struct buffer *b) { void *start = &b->name_, *end = &b->own_text; - root_create_ambig (gc, start, end); + root_create_ambig (gc, start, end, "buffer"); } static void @@ -2150,7 +2160,7 @@ root_create_terminal_list (struct igc *gc) { void *start = &terminal_list; void *end = (char *) start + sizeof (terminal_list); - root_create_ambig (gc, start, end); + root_create_ambig (gc, start, end, "terminal-list"); } static void @@ -2158,19 +2168,19 @@ root_create_main_thread (struct igc *gc) { void *start = &main_thread; void *end = (char *) &main_thread + sizeof (main_thread); - root_create_exact (gc, start, end, scan_main_thread); + root_create_exact (gc, start, end, scan_main_thread, "main-thread"); } void -igc_root_create_ambig (void *start, void *end) +igc_root_create_ambig (void *start, void *end, const char* debug_name) { - root_create_ambig (global_igc, start, end); + root_create_ambig (global_igc, start, end, debug_name); } void igc_root_create_exact (Lisp_Object *start, Lisp_Object *end) { - root_create_exact (global_igc, start, end, scan_exact); + root_create_exact (global_igc, start, end, scan_exact, "exact"); } void @@ -2178,7 +2188,7 @@ igc_root_create_exact_ptr (void *var_addr) { void *start = var_addr; void *end = (char *) start + sizeof (void *); - root_create_exact (global_igc, start, end, scan_ptr_exact); + root_create_exact (global_igc, start, end, scan_ptr_exact, "exact-ptr"); } static void @@ -2194,7 +2204,8 @@ root_create_specpdl (struct igc_thread_list *t) ts->m_specpdl, ts->m_specpdl_end, scan_specpdl, t); IGC_CHECK_RES (res); t->d.specpdl_root - = register_root (gc, root, ts->m_specpdl, ts->m_specpdl_end, false); + = register_root (gc, root, ts->m_specpdl, ts->m_specpdl_end, false, + "specpdl"); } static void @@ -2208,14 +2219,16 @@ root_create_bc (struct igc_thread_list *t) bc->stack, bc->stack_end, scan_bc, t); IGC_CHECK_RES (res); igc_assert (t->d.bc_root == NULL); - t->d.bc_root = register_root (gc, root, bc->stack, bc->stack_end, true); + t->d.bc_root = register_root (gc, root, bc->stack, bc->stack_end, true, + "bc-stack"); } static void root_create_charset_table (struct igc *gc) { root_create_ambig (gc, charset_table_init, - charset_table_init + ARRAYELTS (charset_table_init)); + charset_table_init + ARRAYELTS (charset_table_init), + "charset-table"); } #ifndef IN_MY_FORK @@ -2224,7 +2237,8 @@ root_create_pure (struct igc *gc) { void *start = &pure[0]; void *end = &pure[PURESIZE]; - root_create (gc, start, end, mps_rank_ambig (), scan_pure, NULL, true); + root_create (gc, start, end, mps_rank_ambig (), scan_pure, NULL, true, + "pure"); } #endif @@ -2238,7 +2252,7 @@ root_create_thread (struct igc_thread_list *t) = mps_root_create_thread_scanned (&root, gc->arena, mps_rank_ambig (), 0, t->d.thr, scan_ambig, 0, cold); IGC_CHECK_RES (res); - register_root (gc, root, cold, NULL, true); + register_root (gc, root, cold, NULL, true, "create-thread"); } void @@ -2269,7 +2283,8 @@ igc_grow_rdstack (struct read_stack *rs) for (ptrdiff_t i = old_nitems; i < rs->size; ++i) rs->stack[i].type = RE_free; gc->rdstack_root - = root_create_exact (gc, rs->stack, rs->stack + rs->size, scan_rdstack); + = root_create_exact (gc, rs->stack, rs->stack + rs->size, scan_rdstack, + "rdstack"); } } @@ -2278,7 +2293,8 @@ root_create_exact_n (Lisp_Object *start, size_t n) { igc_assert (start != NULL); igc_assert (n > 0); - return root_create_exact (global_igc, start, start + n, scan_exact); + return root_create_exact (global_igc, start, start + n, scan_exact, + "exact-n"); } void * @@ -2424,7 +2440,8 @@ igc_xalloc_lisp_objs_exact (size_t n) { size_t size = n * sizeof (Lisp_Object); void *p = xzalloc (size); - root_create_exact (global_igc, p, (char *) p + size, scan_exact); + root_create_exact (global_igc, p, (char *) p + size, scan_exact, + "xalloc-exact"); return p; } @@ -2443,7 +2460,7 @@ igc_xzalloc_ambig (size_t size) void *end = (char *) p + size; if (end == p) end = (char *) p + IGC_ALIGN_DFLT; - root_create_ambig (global_igc, p, end); + root_create_ambig (global_igc, p, end, "xzalloc-ambig"); return p; } @@ -2459,7 +2476,7 @@ igc_realloc_ambig (void *block, size_t size) size_t new_size = (size == 0 ? IGC_ALIGN_DFLT : size); void *p = xrealloc (block, new_size); void *end = (char *)p + new_size; - root_create_ambig (global_igc, p, end); + root_create_ambig (global_igc, p, end, "realloc-ambig"); return p; } @@ -2492,7 +2509,7 @@ igc_xpalloc_ambig (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min, } pa = xpalloc (pa, nitems, nitems_incr_min, nitems_max, item_size); char *end = (char *) pa + *nitems * item_size; - root_create_ambig (global_igc, pa, end); + root_create_ambig (global_igc, pa, end, "xpalloc-ambig"); } return pa; } @@ -2522,7 +2539,7 @@ igc_xpalloc_exact (void **pa_cell, ptrdiff_t *nitems, pa = xpalloc (pa, nitems, nitems_incr_min, nitems_max, item_size); char *end = (char *)pa + *nitems * item_size; root_create (global_igc, pa, end, mps_rank_exact (), - scan_xpalloced, scan_area, false); + scan_xpalloced, scan_area, false, "xpalloc-exact"); *pa_cell = pa; } } @@ -2540,7 +2557,7 @@ igc_xnrealloc_ambig (void *pa, ptrdiff_t nitems, ptrdiff_t item_size) } pa = xnrealloc (pa, nitems, item_size); char *end = (char *) pa + nitems * item_size; - root_create_ambig (global_igc, pa, end); + root_create_ambig (global_igc, pa, end, "xnrealloc-ambig"); } return pa; } @@ -3980,7 +3997,8 @@ igc_on_pdump_loaded (void *dump_base, void *hot_start, void *hot_end, memcpy (pinned_objects_in_dump, pinned_roots, sizeof pinned_roots); igc_root_create_ambig (pinned_objects_in_dump, (uint8_t *)pinned_objects_in_dump - + sizeof pinned_objects_in_dump); + + sizeof pinned_objects_in_dump, + "dump-pins"); } void * diff --git a/src/igc.h b/src/igc.h index cd782fca0ca..485f23090c2 100644 --- a/src/igc.h +++ b/src/igc.h @@ -145,7 +145,7 @@ #define EMACS_IGC_H void igc_on_alloc_main_thread_bc (void); void igc_begin_collecting (void); void igc_collect (void); -void igc_root_create_ambig (void *start, void *end); +void igc_root_create_ambig (void *start, void *end, const char *debug_name); void igc_root_create_exact (Lisp_Object *start, Lisp_Object *end); void igc_root_create_exact_ptr (void *var_addr); void igc_root_destroy_comp_unit (struct Lisp_Native_Comp_Unit *u); diff --git a/src/keyboard.c b/src/keyboard.c index 21c4bbd7b2f..e40447d4b39 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -12670,7 +12670,8 @@ delete_kboard (KBOARD *kb) init_keyboard (void) { #ifdef HAVE_MPS - igc_root_create_ambig (kbd_buffer, kbd_buffer + ARRAYELTS (kbd_buffer)); + igc_root_create_ambig (kbd_buffer, kbd_buffer + ARRAYELTS (kbd_buffer), + "kdb-buffer"); #endif /* This is correct before outermost invocation of the editor loop. */ command_loop_level = -1; -- 2.39.2 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0006-Use-igc_assert-instead-of-eassert.patch >From d810517b678e920a45992f02138d688a7cb37df8 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Thu, 20 Jun 2024 15:08:55 +0200 Subject: [PATCH 6/6] Use igc_assert instead of eassert * src/igc.c. (igc_on_pdump_loaded): --- src/igc.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/igc.c b/src/igc.c index 627f88acf4d..b8f0c020847 100644 --- a/src/igc.c +++ b/src/igc.c @@ -3962,24 +3962,24 @@ igc_on_pdump_loaded (void *dump_base, void *hot_start, void *hot_end, void *cold_user_data_start, void *heap_end) { igc_assert (global_igc->park_count > 0); - eassert (base_to_client (hot_start) == charset_table); - eassert (((struct igc_header *)cold_start)->obj_type - == IGC_OBJ_DUMPED_CODE_SPACE_MASKS); - eassert (((struct igc_header *)cold_user_data_start)->obj_type - == IGC_OBJ_DUMPED_BYTES); - eassert (((struct igc_header *)heap_end)->obj_type == IGC_OBJ_DUMPED_BYTES); - + igc_assert (base_to_client (hot_start) == charset_table); + igc_assert (((struct igc_header *)hot_start)->obj_type + == IGC_OBJ_DUMPED_CHARSET_TABLE); + igc_assert (((struct igc_header *)cold_start)->obj_type + == IGC_OBJ_DUMPED_CODE_SPACE_MASKS); + igc_assert (((struct igc_header *)cold_user_data_start)->obj_type + == IGC_OBJ_DUMPED_BYTES); + igc_assert (((struct igc_header *)heap_end)->obj_type + == IGC_OBJ_DUMPED_BYTES); size_t discardable_size = (uint8_t *)cold_start - (uint8_t *)hot_end; // size_t cold_size = (uint8_t *)cold_end - (uint8_t *)cold_start; size_t dump_header_size = (uint8_t *)hot_start - (uint8_t *)dump_base; size_t relocs_size = (uint8_t *)cold_end - (uint8_t *)heap_end; struct igc_header *h = client_to_base (dump_base); igc_assert (h->obj_type == IGC_OBJ_INVALID); -#ifdef IGC_DEBUG - size_t dump_size = (uint8_t *)cold_end - (uint8_t *)dump_base; - igc_assert (obj_size (h) == sizeof *h + dump_size); + igc_assert (obj_size (h) + == sizeof *h + (uint8_t *)cold_end - (uint8_t *)dump_base); igc_assert (discardable_size > 2 * sizeof *h); -#endif /* Ignore dump_header */ set_header (h, IGC_OBJ_PAD, sizeof *h + dump_header_size, 0); /* Ignore discardable section */ -- 2.39.2 --=-=-=--