Subject: Re: bug#40052: CC Mode 5.34 (C++//l); cc-mode hangs fontifying src/hotspot/share/runtime/globals.hpp in OpenJDK
From: Alan Mackenzie <[email-masked]>
To: Nick Gasson <[email-masked]>
Cc: [email-masked]
Date: Fri, 15 May 2020 19:44:50 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello, Nick.

On Wed, Apr 22, 2020 at 12:11:18 +0800, Nick Gasson wrote:

> > OK, thanks.  I've had another look into CC Mode, and found a bug in the
> > handling of its macro cache.  It isn't saving the position of the end of
> > the macro, hence is doing too much scanning.

> > I've fixed this in the following patch, which gives another factor of ~5
> > speedup in the scrolling.  Please remove the previous patch before
> > applying this new one.

> > However, the scrolling still gets sluggish towards the end of
> > globals.hpp.  This is because CC Mode's function which goes back to the
> > beginning of a statement is scanning back over the entire macro.  It
> > basically looks for semicolons or closing braces (at top level) and
> > there are none in the huge macro.  I tried creating a variant of
> > globals.hpp, where each "function call" was terminated by a semicolon.
> > The sluggishness was entirely fixed.  This is largely theoretical, as I
> > assume you have no control over the contents of globals.hpp.

> > Anyhow, here is the patch.  Please let me know if there are still
> > problems with it.  Thanks!

> Hi Alan,

> I tried the second patch and it's working well. Thanks again.

Thanks for the testing.  I've finally got around to committing it into
Emacs, but sadly the cut-off for Emacs 27 has long past, so the fix
won't be seeing the light of day until Emacs 28 (or the next stand-alone
CC Mode, of course).

> There was some discussion of getting rid of the giant macro on the
> OpenJDK mailing list. That's when I realised several other people had
> the same problem opening that file in Emacs.

> https://mail.openjdk.java.net/pipermail/hotspot-dev/2020-March/041088.html

Well, without that macro, a bug might have remained unfixed for a
long(er) time, but if it were up to me, I'd want to reduce the size of
that macro, too.  ;-)

> Nick

-- 
Alan Mackenzie (Nuremberg, Germany).