Subject: Re: bug#69952: [PATCH] Support pdumping compiled queries by dumping their source

From: Yuan Fu <[email-masked]>
Date: Sat, 1 Jun 2024 10:07:38 -0700

> On May 29, 2024, at 9:35 AM, Andrea Corallo <[email-masked]> wrote:
> 
> Eli Zaretskii <[email-masked]> writes:
> 
>>> From: Yuan Fu <[email-masked]>
>>> Date: Tue, 21 May 2024 23:36:47 -0700
>>> Cc: [email-masked],
>>> [email-masked],
>>> [email-masked]
>>> 
>>>>>>> Yes, most likely a function-undefined signal, since all the
>>>>>> treesit.c functions like treesit-query-capture or
>>>>>> treesit-query-compile will be nonexistent. And usually the Lisp
>>>>>> program trying to use the query would check for tree-sitter
>>>>>> availability with treesit-available-p before trying to use any
>>>>>> tree-sitter functions; so that signal will be usually avoided as
>>>>>> well.
>>>>>> 
>>>>>> Can you suggest such an addition to the patch?
>>>>> 
>>>>> Let me take a look.
>>>>> 
>>>>> Yuan
>>> 
>>> Am I missing something? It seems the patch doesn’t include anything about loading a dumped query?
>> 
>> Looks like that, yes.
>> 
>>> I guess that’s the addition you’re talking about? If I want to add a special loader, where should I start?
>> 
>> I guess in dump_do_emacs_relocation and/or dump_do_dump_relocation?
> 
> Yes that's correct.
> 
>> Alternatively, perhaps it's better to define a hook via
>> pdumper_do_now_and_after_load_impl or
>> pdumper_do_now_and_after_late_load_impl, in which case the hook will
>> be run after loading the dump file.  This sounds easier if you can
>> access all the loaded queries one by one, instead of catching them
>> as they are being loaded.
> 
> Note also that if one decides to execute code at LATE_RELOCS or
> VERY_LATE_RELOCS time he has the lisp machinery at disposal (including
> allocation), but native code becomes functional only after
> VERY_LATE_RELOCS relocs are done (not sure this can impact you here).
> 
> On this might be necessary if Yuan goes for the hook and needs native
> Lisp code to be working, to add
> 'pdumper_do_now_and_after_very_late_load_impl' (which I think I didn't
> bothered at the time).
> 
>  Andrea

Thanks to you both! I’ll see what I can come up with.

Yuan