all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Optimize assume(...) away? (agaiin)
@ 2013-10-09 16:43 Dmitry Antipov
  2013-10-09 17:21 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Antipov @ 2013-10-09 16:43 UTC (permalink / raw)
  To: Emacs development discussions; +Cc: Eli Zaretskii, Paul Eggert, Stefan Monnier

1) http://lists.gnu.org/archive/html/emacs-devel/2013-10/msg00238.html
2) http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15565

3) Consider non-trivial eassert like:

eassert ((BUFFERP (it->object)
           && IT_CHARPOS (*it) == it->bidi_it.charpos
           && IT_BYTEPOS (*it) == it->bidi_it.bytepos)
          || (STRINGP (it->object)
              && IT_STRING_CHARPOS (*it) == it->bidi_it.charpos
              && IT_STRING_BYTEPOS (*it) == it->bidi_it.bytepos)
          || (CONSP (it->object) && it->method == GET_FROM_STRETCH))

   a) It takes some time to check whether there are side effects here;
   b) If someone change 'struct it' so IT_STRING_CHARPOS (*it)
      becomes a non-trivial function with side effects, it would be
      too annoying (and error-prone) to review all easserts.

Due to 1), 2) and 3) I strongly suggests to redesign eassert
to avoid any assumptions about its argument expression.

Dmitry



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Optimize assume(...) away? (agaiin)
  2013-10-09 16:43 Optimize assume(...) away? (agaiin) Dmitry Antipov
@ 2013-10-09 17:21 ` Eli Zaretskii
  2013-10-09 17:55   ` Paul Eggert
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2013-10-09 17:21 UTC (permalink / raw)
  To: Dmitry Antipov; +Cc: eggert, monnier, emacs-devel

> Date: Wed, 09 Oct 2013 20:43:17 +0400
> From: Dmitry Antipov <dmantipov@yandex.ru>
> CC: Stefan Monnier <monnier@IRO.UMontreal.CA>, 
>  Eli Zaretskii <eliz@gnu.org>,
>  Paul Eggert <eggert@cs.ucla.edu>
> 
> 1) http://lists.gnu.org/archive/html/emacs-devel/2013-10/msg00238.html
> 2) http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15565
> 
> 3) Consider non-trivial eassert like:
> 
> eassert ((BUFFERP (it->object)
>            && IT_CHARPOS (*it) == it->bidi_it.charpos
>            && IT_BYTEPOS (*it) == it->bidi_it.bytepos)
>           || (STRINGP (it->object)
>               && IT_STRING_CHARPOS (*it) == it->bidi_it.charpos
>               && IT_STRING_BYTEPOS (*it) == it->bidi_it.bytepos)
>           || (CONSP (it->object) && it->method == GET_FROM_STRETCH))
> 
>    a) It takes some time to check whether there are side effects here;
>    b) If someone change 'struct it' so IT_STRING_CHARPOS (*it)
>       becomes a non-trivial function with side effects, it would be
>       too annoying (and error-prone) to review all easserts.
> 
> Due to 1), 2) and 3) I strongly suggests to redesign eassert
> to avoid any assumptions about its argument expression.

How about simply removing 'assume' from eassert?  

'assume' is primarily an optimization device, and thus important in
production builds of Emacs where optimizations are enabled.  By
contrast, eassert will be defined to nothing in such builds.  So it
sounds like we are at best optimizing a rare, or even non-existing use
case, a.k.a. "premature optimization".



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Optimize assume(...) away? (agaiin)
  2013-10-09 17:21 ` Eli Zaretskii
@ 2013-10-09 17:55   ` Paul Eggert
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Eggert @ 2013-10-09 17:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Dmitry Antipov, monnier, emacs-devel

On 10/09/13 10:21, Eli Zaretskii wrote:
> How about simply removing 'assume' from eassert?  

Yes, that sounds better.  I installed a fix along these lines,
in trunk bzr 114593.  The 'assume' helps performance
in some cases, but not others.  We could have a different
flavor of 'eassert' for when we know 'assume' helps performance
(this was briefly in the trunk as 'eassert_and_assume')
but it's not clear that it's worth the maintenance confusion
to have two flavors of 'assert'.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-09 17:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-09 16:43 Optimize assume(...) away? (agaiin) Dmitry Antipov
2013-10-09 17:21 ` Eli Zaretskii
2013-10-09 17:55   ` Paul Eggert

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.