Subject: Re: bug#39944: 27.0.90; JIT Stealth timer errors

From: Eli Zaretskii <[email-masked]>
Date: Sun, 08 Mar 2020 17:10:01 +0200

> From: Paul Eggert <[email-masked]>
> Cc: [email-masked]
> Date: Sun, 8 Mar 2020 00:41:05 -0800
> 
> >> Although comments in that area no doubt could use improvement, I'd rather not 
> >> see comments like this:
> >> 
> >>        /* Add TM_YEAR_BASE to mpz[0].  */
> >>        mpz_add_ui (mpz[0], mpz[0], TM_YEAR_BASE);
> > 
> > There are quite a few of similar comments there,
> 
> I don't see any similar comments for simple calls from Emacs to mpz_add_ui.

You interpret what I said too literally.  I meant these examples:

      /* The plan is to compute (na * (db/g) + nb * (da/g)) / lcm (da, db)
	 where g = gcd (da, db).  Start by computing g.  */
      mpz_t *g = &mpz[3];
      mpz_gcd (*g, *da, *db);

      /* fa = da/g, fb = db/g.  */
      mpz_t *fa = &mpz[4], *fb = &mpz[3];
      mpz_divexact (*fa, *da, *g);
      mpz_divexact (*fb, *db, *g);

      /* ihz = fa * db.  This is equal to lcm (da, db).  */
      mpz_t *ihz = &mpz[0];
      mpz_mul (*ihz, *fa, *db);

      /* iticks = (fb * na) OP (fa * nb), where OP is + or -.  */
      mpz_t const *na = bignum_integer (iticks, ta.ticks);
      mpz_mul (*iticks, *fb, *na);
      mpz_t const *nb = bignum_integer (&mpz[3], tb.ticks);
      (subtract ? mpz_submul : mpz_addmul) (*iticks, *fa, *nb);

Quite helpful, I'd say.

> Similarly for nearly every library function Emacs calls. GMP should be no 
> different from other libraries in this respect.

I think it's different, because using it essentially converts infix
expressions to a long series of function calls, and thus significantly
slows down code reading and makes its comprehension harder.  Most
other libraries don't force us to issue so many library calls with
such high density, in order to do relatively simple calculations.

> I added a few comments here and there. But I didn't go down to the level of 
> commenting every call.

Thanks.