unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#69952: [PATCH] Support pdumping compiled queries by dumping their source
@ 2024-03-23  3:27 Sergey Vinokurov
  2024-03-23  7:08 ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Sergey Vinokurov @ 2024-03-23  3:27 UTC (permalink / raw)
  To: 69952

[-- 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


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2024-05-18  8:38 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-23  3:27 bug#69952: [PATCH] Support pdumping compiled queries by dumping their source Sergey Vinokurov
2024-03-23  7:08 ` 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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).