From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Using the GNU GMP Library for Bignums in Emacs Date: Sun, 15 Jul 2018 11:02:49 -0400 Message-ID: References: <29f933ac-a6bf-8742-66a7-0a9d6d3e5a88@disroot.org> <83bmecy6fx.fsf@gnu.org> <0d3175d8-d996-651e-b221-71978bde3a65@cs.ucla.edu> <87tvpdnzgy.fsf@tromey.com> <4c2a814f-c254-29e5-39cf-11b5f2e5c9c8@cs.ucla.edu> <49d8ba62-c9a5-9203-d882-8e900b441ff3@cs.ucla.edu> <8e0320d9-e0d0-2b57-57cc-2df4399f133c@cs.ucla.edu> <87lgaio7xd.fsf@tromey.com> <877em1cb0i.fsf@tromey.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1531666916 24067 195.159.176.226 (15 Jul 2018 15:01:56 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 15 Jul 2018 15:01:56 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Tom Tromey , emacs-devel@gnu.org, eggert@cs.ucla.edu To: Richard Stallman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 15 17:01:52 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1feiX1-0006BN-Lt for ged-emacs-devel@m.gmane.org; Sun, 15 Jul 2018 17:01:51 +0200 Original-Received: from localhost ([::1]:45853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feiZ8-0000pt-Ql for ged-emacs-devel@m.gmane.org; Sun, 15 Jul 2018 11:04:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feiYG-0000oR-V5 for emacs-devel@gnu.org; Sun, 15 Jul 2018 11:03:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feiYF-000811-JT for emacs-devel@gnu.org; Sun, 15 Jul 2018 11:03:09 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:40064) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feiYB-0007yG-RU; Sun, 15 Jul 2018 11:03:03 -0400 Original-Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id w6FF3Vga022564; Sun, 15 Jul 2018 11:03:32 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id C2021661B8; Sun, 15 Jul 2018 11:02:49 -0400 (EDT) In-Reply-To: (Richard Stallman's message of "Thu, 12 Jul 2018 19:35:33 -0400") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6329=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6329> : inlines <6748> : streams <1792625> : uri <2673979> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.20 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:227431 Archived-At: > I don't know HOW bad this will be. (It would be nice to find out by > experiment.) That's why I said there _may_ be important advantages on > the other side. I don't know how important they are. I recently posted a patch which makes EQ behave like `eql` attached. I just tried to see its impact on the ELisp compilation time (i.e. I did `rm **/*.elc; make`). The original time on my benchmark machine was in the bracket 58.77s..59.13s, and with the patch, the time increased to a bracket of 61.03s..61.68s. So basically a 4% slow down. Stefan diff --git a/src/fns.c b/src/fns.c index 27c16c6072..4c23bb2488 100644 --- a/src/fns.c +++ b/src/fns.c @@ -2173,10 +2173,7 @@ DEFUN ("eql", Feql, Seql, 2, 2, 0, Floating-point numbers of equal value are `eql', but they may not be `eq'. */) (Lisp_Object obj1, Lisp_Object obj2) { - if (FLOATP (obj1)) - return equal_no_quit (obj1, obj2) ? Qt : Qnil; - else - return EQ (obj1, obj2) ? Qt : Qnil; + return EQL (obj1, obj2) ? Qt : Qnil; } DEFUN ("equal", Fequal, Sequal, 2, 2, 0, @@ -2272,7 +2269,7 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind, } } - if (EQ (o1, o2)) + if (lisp_h_EQ (o1, o2)) return true; if (XTYPE (o1) != XTYPE (o2)) return false; @@ -3766,7 +3763,7 @@ cmpfn_user_defined (struct hash_table_test *ht, in a Lisp integer. */ static EMACS_UINT -hashfn_eq (struct hash_table_test *ht, Lisp_Object key) +hashfn__eq (struct hash_table_test *ht, Lisp_Object key) { return XHASH (key) ^ XTYPE (key); } @@ -3788,7 +3785,13 @@ hashfn_equal (struct hash_table_test *ht, Lisp_Object key) static EMACS_UINT hashfn_eql (struct hash_table_test *ht, Lisp_Object key) { - return FLOATP (key) ? hashfn_equal (ht, key) : hashfn_eq (ht, key); + return FLOATP (key) ? hashfn_equal (ht, key) : hashfn__eq (ht, key); +} + +static EMACS_UINT +hashfn_eq (struct hash_table_test *ht, Lisp_Object key) +{ + return hashfn_eql (ht, key); } /* Value is a hash code for KEY for use in hash table H which uses as diff --git a/src/lisp.h b/src/lisp.h index 0bb7c488f2..26fa477ce4 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -361,7 +361,7 @@ typedef EMACS_INT Lisp_Word; #define lisp_h_INTEGERP(x) ((XTYPE (x) & (Lisp_Int0 | ~Lisp_Int1)) == Lisp_Int0) #define lisp_h_MARKERP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Marker) #define lisp_h_MISCP(x) (XTYPE (x) == Lisp_Misc) -#define lisp_h_NILP(x) EQ (x, Qnil) +#define lisp_h_NILP(x) lisp_h_EQ (x, Qnil) #define lisp_h_SET_SYMBOL_VAL(sym, v) \ (eassert ((sym)->u.s.redirect == SYMBOL_PLAINVAL), \ (sym)->u.s.val.value = (v)) @@ -421,7 +421,7 @@ typedef EMACS_INT Lisp_Word; # define CHECK_SYMBOL(x) lisp_h_CHECK_SYMBOL (x) # define CHECK_TYPE(ok, predicate, x) lisp_h_CHECK_TYPE (ok, predicate, x) # define CONSP(x) lisp_h_CONSP (x) -# define EQ(x, y) lisp_h_EQ (x, y) +# define EQ(x, y) EQL (x, y) # define FLOATP(x) lisp_h_FLOATP (x) # define INTEGERP(x) lisp_h_INTEGERP (x) # define MARKERP(x) lisp_h_MARKERP (x) @@ -1141,10 +1141,21 @@ make_natnum (EMACS_INT n) /* Return true if X and Y are the same object. */ +extern bool equal_no_quit (Lisp_Object o1, Lisp_Object o2); + +INLINE bool +EQL (Lisp_Object x, Lisp_Object y) +{ + if (lisp_h_FLOATP (x)) + return equal_no_quit (x, y); + else + return lisp_h_EQ (x, y); +} + INLINE bool (EQ) (Lisp_Object x, Lisp_Object y) { - return lisp_h_EQ (x, y); + return EQL (x, y); } /* True if the possibly-unsigned integer I doesn't fit in a Lisp fixnum. */ @@ -3626,7 +3637,6 @@ extern Lisp_Object merge (Lisp_Object, Lisp_Object, Lisp_Object); extern Lisp_Object do_yes_or_no_p (Lisp_Object); extern Lisp_Object concat2 (Lisp_Object, Lisp_Object); extern Lisp_Object concat3 (Lisp_Object, Lisp_Object, Lisp_Object); -extern bool equal_no_quit (Lisp_Object, Lisp_Object); extern Lisp_Object nconc2 (Lisp_Object, Lisp_Object); extern Lisp_Object assq_no_quit (Lisp_Object, Lisp_Object); extern Lisp_Object assoc_no_quit (Lisp_Object, Lisp_Object);