all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Sergey Vinokurov <serg.foo@gmail.com>
To: 69952@debbugs.gnu.org
Subject: bug#69952: [PATCH] Support pdumping compiled queries by dumping their source
Date: Sat, 23 Mar 2024 03:27:18 +0000	[thread overview]
Message-ID: <c47199ce-1b89-44b2-b714-57d44027f895@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 540 bytes --]

Hello,

This patch aims to allow more things to be dumped. In particular, 
compiled treesitter queries can be easily dumped by storing their source 
so that they will be recompiled on load.

I noticed that in my config compiled quires are created somewhere which 
prevents me dumping with standard Emacs build. But with this patch I can 
dump successfully and not bother finding out who produced the queries.

It seems like there should be no drawbacks in allowing more things to be 
dumped, please correct me if I'm wrong.

Regards,
Sergey

[-- Attachment #2: pdump.patch --]
[-- Type: text/x-patch, Size: 2016 bytes --]

From 8b7263181ed358fe88a358355c2269b93379703c Mon Sep 17 00:00:00 2001
From: Sergey Vinokurov <serg.foo@gmail.com>
Date: Sun, 6 Aug 2023 16:24:29 +0100
Subject: [PATCH] Support compiled queries in pdump by dumping source

* src/pdumper.c (dump_vectorlike): Dump compiled queries
* src/pdumper.c (dump_treesit_compiled_query): New function
---
 src/pdumper.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/pdumper.c b/src/pdumper.c
index c7ebb38dea5..f2dd24c56a6 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -44,6 +44,7 @@
 #include "systime.h"
 #include "thread.h"
 #include "bignum.h"
+#include "treesit.h"
 
 #ifdef CHECK_STRUCTS
 # include "dmpstruct.h"
@@ -2215,6 +2216,21 @@ dump_finalizer (struct dump_context *ctx,
   return finish_dump_pvec (ctx, &out->header);
 }
 
+#ifdef HAVE_TREE_SITTER
+static dump_off
+dump_treesit_compiled_query (struct dump_context *ctx,
+			     struct Lisp_TS_Query *query)
+{
+  START_DUMP_PVEC (ctx, &query->header, struct Lisp_TS_Query, out);
+  dump_field_lv (ctx, &out->language, query, &query->language, WEIGHT_STRONG);
+  dump_field_lv (ctx, &out->source, query, &query->source, WEIGHT_STRONG);
+  /* Recompile these after load */
+  out->query = NULL;
+  out->cursor = NULL;
+  return finish_dump_pvec (ctx, &out->header);
+}
+#endif
+
 struct bignum_reload_info
 {
   dump_off data_location;
@@ -3108,6 +3124,12 @@ dump_vectorlike (struct dump_context *ctx,
           return DUMP_OBJECT_IS_RUNTIME_MAGIC;
         }
       break;
+#ifdef HAVE_TREE_SITTER
+    case PVEC_TS_COMPILED_QUERY:
+      return dump_treesit_compiled_query (ctx, XTS_COMPILED_QUERY (lv));
+#else
+    case PVEC_TS_COMPILED_QUERY:
+#endif
     case PVEC_WINDOW_CONFIGURATION:
     case PVEC_OTHER:
     case PVEC_XWIDGET:
@@ -3122,7 +3144,6 @@ dump_vectorlike (struct dump_context *ctx,
     case PVEC_FREE:
     case PVEC_TS_PARSER:
     case PVEC_TS_NODE:
-    case PVEC_TS_COMPILED_QUERY:
       break;
     }
   char msg[60];
-- 
2.43.1


             reply	other threads:[~2024-03-23  3:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-23  3:27 Sergey Vinokurov [this message]
2024-03-23  7:08 ` bug#69952: [PATCH] Support pdumping compiled queries by dumping their source Eli Zaretskii
2024-03-23 12:53   ` Sergey Vinokurov
2024-03-23 13:09     ` Eli Zaretskii
2024-04-13  7:41   ` Eli Zaretskii
2024-04-20  8:08     ` Yuan Fu
2024-04-20  9:32       ` Eli Zaretskii
2024-04-20 22:50         ` Yuan Fu
2024-04-21  4:53           ` Eli Zaretskii
2024-04-21 23:41             ` Yuan Fu
2024-04-22  5:47               ` Eli Zaretskii
2024-04-22  6:04                 ` Yuan Fu
2024-04-22  6:18                   ` Eli Zaretskii
2024-04-22  6:25                     ` Yuan Fu
2024-05-04  9:39                       ` Eli Zaretskii
2024-05-04 21:29                         ` Yuan Fu
2024-05-18  8:38                           ` Eli Zaretskii
2024-05-22  6:36                             ` Yuan Fu
2024-05-22 12:55                               ` Eli Zaretskii
2024-05-29 16:35                                 ` Andrea Corallo
2024-06-01 17:07                                   ` Yuan Fu
2024-06-15  7:59                                     ` Eli Zaretskii
2024-06-19  6:25                                       ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c47199ce-1b89-44b2-b714-57d44027f895@gmail.com \
    --to=serg.foo@gmail.com \
    --cc=69952@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.