From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.devel Subject: Re: MPS: Bytecode stack Date: Mon, 6 May 2024 15:07:20 +0200 Message-ID: <038B57D6-C449-4C10-85F8-69D0A7844219@gmail.com> References: <3174C6A6-28A6-492E-A268-E391A13FEA36@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26215"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Helmut Eller , Emacs Devel To: =?utf-8?Q?Gerd_M=C3=B6llmann?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon May 06 15:08:26 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s3y4v-0006cb-Uf for ged-emacs-devel@m.gmane-mx.org; Mon, 06 May 2024 15:08:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3y40-00031m-8z; Mon, 06 May 2024 09:07:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3y3y-0002wu-Hq for emacs-devel@gnu.org; Mon, 06 May 2024 09:07:26 -0400 Original-Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s3y3w-0000uu-S6; Mon, 06 May 2024 09:07:26 -0400 Original-Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2e22a1bed91so25670281fa.0; Mon, 06 May 2024 06:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715000842; x=1715605642; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=tIXUT07Q0gptP4X4zKZrdHGte7VelEpwEYim115Vrxs=; b=mbU3hoksNWp3lQVxpRCqUKC7yu5LYM5XoXAoi3zEDrqdWVAy2qm/qkoFQjU9DPmeke rJG0kUiCbl8zM03d101mG5LAlhO/nZb4RJjexKH5VjGF2SCCVAQ9HEjqXOOfRxqhnaXr Lx11W0MsPJZSAu0IaFMX38BqstptDr/6Ygx1WHd40SlDtBEySd4QdtQci0OH6rvWC5Js Q94nrZAthk3rlr7GWYII98hJEIQwYHwyy9PyoJHgX6K+58LbkZM0olSsWJrbe2NiIAIB dvwznIp0HuqTSrYW46aMOzXGdKfcvgMgbN4jWU1VR3OKWBbaT5obPDBiPgpY3hX8wMpa yEqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715000842; x=1715605642; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=tIXUT07Q0gptP4X4zKZrdHGte7VelEpwEYim115Vrxs=; b=CaE/J8VgPyvujFlBp9XH+l13005uBDM2eCj+zmb75cn47AAh3W+90vGJcOkOcqqAv9 daFYxKh4tsrEG/0CVNt2t5wgAI9i/jbIDShRKU9BpC7hwZqFVKejxDZOeroYOxVdSaOL VRP6Pec9dB0P2GQ7G1rC5XSuuYuDql/6GSDVaxjvcFFDPk5CBg23upEbKtwCvsBze1jE mDhIViMxOEmA/n8zcZ31el9HNjUkhIezCP+GmMVeI8/YKGl++F6ipgcbIM9T97lCwIve FCS+AArvP9vXIhHesCt1+zcXwuMXRLxPtdiQeUWtEH/0P7JwRjpbUcYRhB7he5vCgUP0 GSFQ== X-Forwarded-Encrypted: i=1; AJvYcCXfEw3ggtq/eeqZ9LGbGhyZBwTSeo+76SoxJYkma14pJygP/PrgHUGrr20DEFldqF/8eCBGco78YPetBtrcgg3ll+7I X-Gm-Message-State: AOJu0YzPoxCqkZ47VU89dAFtuet/d0Ae9C6ef8/1t47W5114jBXm5DtG 4KVkR3evQ9VFGH1b4bD7ALIILW199gfdxVwABr2+kMBTk13Wu4gX X-Google-Smtp-Source: AGHT+IGjEus36vhATt92aZZ7Y+Ogqo+HgLej/orWjSmC3VvU4jZR5SJpyLUbOOse414F5hGSoULcnw== X-Received: by 2002:a2e:9dd1:0:b0:2df:a8e1:c24 with SMTP id x17-20020a2e9dd1000000b002dfa8e10c24mr6554630ljj.34.1715000841777; Mon, 06 May 2024 06:07:21 -0700 (PDT) Original-Received: from smtpclient.apple (c80-217-1-132.bredband.tele2.se. [80.217.1.132]) by smtp.gmail.com with ESMTPSA id s7-20020a2e9c07000000b002de118decbbsm1616002lji.53.2024.05.06.06.07.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2024 06:07:21 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.15) Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=mattias.engdegard@gmail.com; helo=mail-lj1-x22d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:318889 Archived-At: 6 maj 2024 kl. 14.47 skrev Gerd M=C3=B6llmann = : > 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 =3D bc->fp->next_stack; 515 struct bc_frame *fp =3D (struct bc_frame *)(frame_base + = max_stack); 516=20 517 if ((char *)fp->next_stack > bc->stack_end) 518 error ("Bytecode stack overflow"); 519=20 520 /* Save the function object so that the bytecode and vector are 521 held from removal by the GC. */ 522 fp->fun =3D 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 =3D top; 526 fp->saved_pc =3D pc; 527 fp->saved_fp =3D bc->fp; 528 bc->fp =3D 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.