unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: scratch/bytecode-speedup 870806d4c4 04/11: Pin bytecode strings to avoid copy at call time
       [not found] ` <20220111165048.75C05C0DA31@vcs2.savannah.gnu.org>
@ 2022-01-11 17:09   ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2022-01-11 17:09 UTC (permalink / raw)
  To: emacs-devel; +Cc: Mattias Engdegård

> branch: scratch/bytecode-speedup
> commit 870806d4c453addca794aa0940298425241e13d9
> Author: Mattias Engdegård <mattiase@acm.org>
> Commit: Mattias Engdegård <mattiase@acm.org>
>
>     Pin bytecode strings to avoid copy at call time
> +  /* ... we plonk BYTESTR and VECTOR there to ensure that they survive
> +     GC (bug#33014), since these variables aren't used directly beyond
> +     the interpreter prologue and wouldn't be found in the stack frame
> +     otherwise.  */
> +  stack_base[0] = bytestr;
> +  stack_base[1] = vector;
> +  Lisp_Object *top = stack_base + 1;
> +  Lisp_Object *stack_lim = top + stack_items;
> +  unsigned char const *bytestr_data = SDATA (bytestr);

Why not keep a ref to the function object itself?
That would also allow providing a new bytecode to extract a `self`
reference to the function that's being executed.

Oh, I think I can see one reason: there's no such object when we're
called from `Fbyte_code`.  Maybe `Fbyte_code` should be reimplemented as
`(funcall (make-byte-code 0 bytecode csts depth))`?
(and change `bytecomp.el` not to use `byte-code` any more)
(and mark `byte-code` as obsolete)


        Stefan




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

* Re: scratch/bytecode-speedup 1dca615cf9 08/11: Move a runtime interpreter check to ENABLE_CHECKING
       [not found] ` <20220111165050.357D6C0DA35@vcs2.savannah.gnu.org>
@ 2022-01-11 17:22   ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2022-01-11 17:22 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: emacs-devel

> +  /* The byte code should have been properly pinned.  */
>    eassert (SDATA (bytestr) == bytestr_data);
> -
>    /* Binds and unbinds are supposed to be compiled balanced.  */
> -  if (SPECPDL_INDEX () != count)
> -    {
> -      if (SPECPDL_INDEX () > count)
> -	unbind_to (count, Qnil);
> -      error ("binding stack not balanced (serious byte compiler bug)");
> -    }
> +  eassert (SPECPDL_INDEX () == count);

This makes compiler debugging harder since it crashes Emacs instead of
signaling a clean error :-(

Maybe this actually should not be an error at all, and instead
`bytecomp.el` could skip emitting trailing `unbind`s and rely on
`exec_byte_code` doing the unbinds instead.

I think this would result in a speed up (and a more compact bytecode)
with dynbind code.  Not sure how it'd work out with lexbind code where
it's much more common for functions not to need any `unbind`.


        Stefan




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

end of thread, other threads:[~2022-01-11 17:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <164191984181.15147.4731922332585678354@vcs2.savannah.gnu.org>
     [not found] ` <20220111165048.75C05C0DA31@vcs2.savannah.gnu.org>
2022-01-11 17:09   ` scratch/bytecode-speedup 870806d4c4 04/11: Pin bytecode strings to avoid copy at call time Stefan Monnier
     [not found] ` <20220111165050.357D6C0DA35@vcs2.savannah.gnu.org>
2022-01-11 17:22   ` scratch/bytecode-speedup 1dca615cf9 08/11: Move a runtime interpreter check to ENABLE_CHECKING Stefan Monnier

Code repositories for project(s) associated with this inbox:

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).