emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to add pseudo vector types


From: Eli Zaretskii
Subject: Re: How to add pseudo vector types
Date: Fri, 23 Jul 2021 22:10:28 +0300

> From: Yuan Fu <casouri@gmail.com>
> Date: Fri, 23 Jul 2021 09:25:17 -0400
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
>  Clément Pit-Claudel <cpitclaudel@gmail.com>,
>  emacs-devel@gnu.org
> 
> > So what does TS do if it attempts to allocate more memory and that
> > fails?  Regardless, we'd need some fallback strategy, because AFAIU
> > many people run with VM overcommit enabled, so the OOM killer will
> > just kill the Emacs process when it asks for too much memory.
> 
> Abort, it seems:
> 
> static inline void *ts_malloc_default(size_t size) {
>   void *result = malloc(size);
>   if (size > 0 && !result) {
>     fprintf(stderr, "tree-sitter failed to allocate %zu bytes", size);
>     exit(1);
>   }
>   return result;
> }

We must replace this function, if only because the MS-Windows build of
Emacs uses a custom malloc implementation.  Does TS allow the client
to use its own malloc?

> >> Also, we don’t call change hooks in replace_range_2, why?
> > 
> > Because it is called in a loop, one character at a time.  The caller
> > of replace_range_2 calls these hooks for the entire region, once.
> > 
> >> Should I update tree-sitter trees in that function, or should I not?
> > 
> > The only caller is casify_region, so you could update there.
> 
> casify_region doesn’t have access to byte positions.

You can compute them using CHAR_TO_BYTE.

> I’ll leave it as-is, recording change in replace_range_2, if you don’t object 
> to it.

That'd be wasteful, I think.  replace_range_2 is called one character
at a time.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]