unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: master 3ed79cd: Separate bytecode stack
Date: Mon, 14 Mar 2022 16:56:20 +0100	[thread overview]
Message-ID: <1EB42282-A67C-4C20-8E5D-BA8DA9A21E9C@acm.org> (raw)
In-Reply-To: <83h781lma9.fsf@gnu.org>

13 mars 2022 kl. 19.50 skrev Eli Zaretskii <eliz@gnu.org>:

> The warning is gone

Excellent, thank you for testing!

>  What kind of pointers do you need to store in the
> fp array, why, and for what purpose?  And if you do need to do that,
> why not use a union?

Let's look at what we are doing. We switch to an explicit representation of the bytecode interpreter stack. Each stack frame is composed of two parts: a fixed-sized metadata record containing information such as where to continue execution after the function has terminated, and a variable-sized private data stack for the function. The size of that data stack is specified in the bytecode object.

Like most other interpreters and CPU hardware, we use the standard solution: reserve a block of memory for a stack and carve out stack frames from it as needed, with their two parts next to one another in each frame. The data stack part must be an array of Lisp_Object; here we have little choice. The metadata record consists of a few members each of which fits into the space of a Lisp_Object, which makes the current implementation fairly natural: store those in designated array slots.

There are alternatives, several of which have been tried. One which is basically an equivalent formulation of the same code is to use a C struct for the metadata, then allocate it and the local data stack out from a big untyped stack. This makes metadata access simpler and more type-safe, and eliminates the previously needed accessor functions (sf_get_lisp_ptr etc). The drawback is more casts between pointer types which is slightly more risky than the straightforward XLP etc conversions in the current code. On the other hand, it could actually be faster depending on how friendly the compiler is.

The latter alternative would become a little more palatable if we could use flexible array struct members on all platforms. Given that we assume C99, can we do that now?




  reply	other threads:[~2022-03-14 15:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-13 17:39 master 3ed79cd: Separate bytecode stack Eli Zaretskii
2022-03-13 18:44 ` Mattias Engdegård
2022-03-13 18:50   ` Eli Zaretskii
2022-03-14 15:56     ` Mattias Engdegård [this message]
2022-03-14 17:15       ` Eli Zaretskii
2022-03-15 14:20         ` Mattias Engdegård
2022-03-15 14:42           ` Eli Zaretskii
2022-03-15 15:08             ` Robert Pluim
2022-03-15 19:29             ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1EB42282-A67C-4C20-8E5D-BA8DA9A21E9C@acm.org \
    --to=mattiase@acm.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).