all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Gerd Möllmann" <gerd.moellmann@gmail.com>
To: "Mattias Engdegård" <mattias.engdegard@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
	 Helmut Eller <eller.helmut@gmail.com>,
	Emacs Devel <emacs-devel@gnu.org>
Subject: Re: MPS: Bytecode stack
Date: Mon, 06 May 2024 15:35:40 +0200	[thread overview]
Message-ID: <m2h6fbgj0z.fsf@pro2.fritz.box> (raw)
In-Reply-To: <m2le4ngjla.fsf@pro2.fritz.box> ("Gerd Möllmann"'s message of "Mon, 06 May 2024 15:23:29 +0200")

Gerd Möllmann <gerd.moellmann@gmail.com> writes:

> Mattias Engdegård <mattias.engdegard@gmail.com> writes:
>
>> 6 maj 2024 kl. 14.47 skrev Gerd Möllmann <gerd.moellmann@gmail.com>:
>>
>>> It would be easiest if you'd look at scan_bc in igc.c on the branch
>>
>> I did, which is why I wondered whether I had understood the problem correctly. Maybe we can help each other:
>>
>>>    /* FIXME: AFAIU the current top frame starts at bc->fp->next_stack
>>
>> Does it? Look at the ASCII art in bytecode.c. During bytecode
>> execution, fp->next_stack is the lowest completely unused entry of the
>> bytecode stack, but that refers to the engine register `fp` which is
>> almost but not entirely in sync with `bc->fp`. There are gaps when
>> there is live data on the stack beyond bc->fp->next_stack, such as
>> during frame setup:
>>
>>  514   Lisp_Object *frame_base = bc->fp->next_stack;
>>  515   struct bc_frame *fp = (struct bc_frame *)(frame_base + max_stack);
>>  516 
>>  517   if ((char *)fp->next_stack > bc->stack_end)
>>  518     error ("Bytecode stack overflow");
>>  519 
>>  520   /* Save the function object so that the bytecode and vector are
>>  521      held from removal by the GC. */
>>  522   fp->fun = fun;
>>  523   /* Save previous stack pointer and pc in the new frame.  If we came
>>  524      directly from outside, these will be NULL.  */
>>  525   fp->saved_top = top;
>>  526   fp->saved_pc = pc;
>>  527   fp->saved_fp = bc->fp;
>>  528   bc->fp = fp;
>>
>> which is why I was concerned about whether there might be a race
>> somewhere. Note, however, that in this particular window we don't
>> stash anything to the stack beyond bc->fp->next_stack that isn't
>> already accessible via ambig refs elsewhere (`fun` in particular).
>>
>> There may be similar gaps when we pop stack frames: return from a
>> function and in the catch and condition-case handling, but it would be
>> easier if I knew what I was looking for.
>
> Ok, let me try to explain. Thanks for looking into this!
>
> I made the bc stack(s) ambig roots (conservativly scanned, like with
> mark_memory). For the root address range I use the stack's start and
> end. Since that is quite large (512K?), I though it a good idea to scan
> less. So scan_bc tries to figure out an 'end' address that is smaller
> the whole stack's end. That's all it is about. How to find a realistic,
> scan end.

Or, wait a moment... I'm wondering about what happens when the client
continues to exec byte code while we are scanning... The root is not
like objects in MPS memory to which we get granted exclusive access. Or
so I think ATM. But roots can have a barrier applied to them, I think.
MPS_RM_PROT. I have to read a bit.

(BTW, funny I think: Emacs/master froze while having Emacs/igc in LLDB,
and Emacs/igc was still functioning well :-))



  reply	other threads:[~2024-05-06 13:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-06  9:58 MPS: Bytecode stack Gerd Möllmann
2024-05-06 12:12 ` Mattias Engdegård
2024-05-06 12:47   ` Gerd Möllmann
2024-05-06 13:07     ` Mattias Engdegård
2024-05-06 13:23       ` Gerd Möllmann
2024-05-06 13:35         ` Gerd Möllmann [this message]
2024-05-06 13:54           ` Mattias Engdegård
2024-05-06 14:02             ` Gerd Möllmann
2024-05-06 14:14               ` Gerd Möllmann
2024-05-06 15:59               ` Mattias Engdegård

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

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

  git send-email \
    --in-reply-to=m2h6fbgj0z.fsf@pro2.fritz.box \
    --to=gerd.moellmann@gmail.com \
    --cc=eliz@gnu.org \
    --cc=eller.helmut@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=mattias.engdegard@gmail.com \
    /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 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.