All of lore.kernel.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Kautuk Consul <kconsul@linux.vnet.ibm.com>
Cc: Thomas Huth <thuth@redhat.com>,
	aik@ozlabs.ru, groug@kaod.org, slof@lists.ozlabs.org,
	kvm-ppc@vger.kernel.org
Subject: Re: [PATCH v2] slof/engine.in: refine +COMP and -COMP by not using COMPILE
Date: Fri, 23 Feb 2024 14:57:23 -0600	[thread overview]
Message-ID: <20240223205723.GO19790@gate.crashing.org> (raw)
In-Reply-To: <Zcnkzks7D0eHVYZQ@li-a450e7cc-27df-11b2-a85c-b5a9ac31e8ef.ibm.com>

On Mon, Feb 12, 2024 at 02:58:46PM +0530, Kautuk Consul wrote:
> Hi Segher/Thomas,
> 
> On 2024-02-02 00:15:48, Kautuk Consul wrote:
> > Use the standard "DOTICK <word> COMPILE," mechanism in +COMP and -COMP
> > as is being used by the rest of the compiler.
> > Also use "SEMICOLON" instead of "EXIT" to compile into HERE in -COMP
> > as that is more informative as it mirrors the way the col() macro defines
> > a colon definition.
> > 
> > Signed-off-by: Kautuk Consul <kconsul@linux.vnet.ibm.com>
> > ---
> >  slof/engine.in | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/slof/engine.in b/slof/engine.in
> > index 59e82f1..fa4d82e 100644
> > --- a/slof/engine.in
> > +++ b/slof/engine.in
> > @@ -422,8 +422,8 @@ imm(.( LIT(')') PARSE TYPE)
> >  col(COMPILE R> CELL+ DUP @ COMPILE, >R)
> > 
> >  var(THERE 0)
> > -col(+COMP STATE @ 1 STATE +! 0BRANCH(1) EXIT HERE THERE ! COMP-BUFFER DOTO HERE COMPILE DOCOL)
> > -col(-COMP -1 STATE +! STATE @ 0BRANCH(1) EXIT COMPILE EXIT THERE @ DOTO HERE COMP-BUFFER EXECUTE)
> > +col(+COMP STATE @ 1 STATE +! 0BRANCH(1) EXIT HERE THERE ! COMP-BUFFER DOTO HERE DOTICK DOCOL COMPILE,)
> > +col(-COMP -1 STATE +! STATE @ 0BRANCH(1) EXIT DOTICK SEMICOLON COMPILE, THERE @ DOTO HERE COMP-BUFFER EXECUTE)
> 
> What do you think about the above changes ?
> Are there any more changes I could do to this patch ?
> Or if you want to reject can you tell me why exactly ?

I think both changes are bad.  They reduce abstraction, for no reason at
all.

If you think the compiler should inline more, or do better optimisations
even, work on *that*, don't do one unimportant case of it manually.

I never made the indirect threading engine in Paflof faster, because it
was plenty fast already.  In SLOF, almost everything is compiled at
runtime, and if it is important to speed that up there are some well-
known usual caching tricks to make things *factors* faster.  The main
focus points for SLOF were to have an engine that is easily adapted for
different purposes (and it was! Ask me about it :-) ), and to have
things using it as debuggable as possible (you really need some hardware
debugging thing to make it real easy; I had one back then.  You need to
be able to look at all memory state after a stop (a crash, perhaps), and
seeing all CPU registers is useful as well.

If you want to improve engine.in, get rid of it completely?  Make the
whol thing cross-compile perhaps.  Everything from source code.  The
engine.in thing is essentially an already compiled thing (but not
relocated yet, not fixed to some address), which is still in mostly
obvious 1-1 correspondence to it source code, which can be easily
"uncompiled" as well.  Like:

col(+COMP STATE @ 1 STATE +! 0BRANCH(1) EXIT HERE THERE ! COMP-BUFFER DOTO HERE COMPILE DOCOL)
col(-COMP -1 STATE +! STATE @ 0BRANCH(1) EXIT COMPILE EXIT THERE @ DOTO HERE COMP-BUFFER EXECUTE)

: +comp  ( -- )
  state @  1 state +!  IF exit THEN
  here there !
  comp-buffer to here
  compile docol ;
: -comp ( -- )
  -1 state +!
  state @ IF exit THEN
  compile exit
  there @ to here
  comp-buffer execute ;

"['] semicolon compile," is not something a user would ever write.  A
user would write "compile exit".  It is standard Forth, it works
anywhere.  It is much more idiomatic..


Segher

  reply	other threads:[~2024-02-23 21:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02  5:15 [PATCH v2] slof/engine.in: refine +COMP and -COMP by not using COMPILE Kautuk Consul
2024-02-12  9:28 ` Kautuk Consul
2024-02-23 20:57   ` Segher Boessenkool [this message]
2024-02-26  4:39     ` Kautuk Consul
2024-03-07  6:33       ` Kautuk Consul
2024-03-18  5:12         ` Kautuk Consul
2024-05-22  9:04           ` Kautuk Consul
2024-05-27 12:33             ` Alexey Kardashevskiy
2024-05-28  4:02               ` Kautuk Consul
2024-02-22  7:38 ` Kautuk Consul
2024-02-22  9:04   ` Thomas Huth
2024-02-22 11:46     ` Kautuk Consul
2024-02-23  5:59       ` Kautuk Consul
2024-02-23 21:04         ` Segher Boessenkool
2024-02-26  4:32           ` Kautuk Consul
2024-02-26  4:43             ` Kautuk Consul
2024-02-26  6:47               ` Kautuk Consul
2024-02-26  6:59                 ` Kautuk Consul

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=20240223205723.GO19790@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=aik@ozlabs.ru \
    --cc=groug@kaod.org \
    --cc=kconsul@linux.vnet.ibm.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=slof@lists.ozlabs.org \
    --cc=thuth@redhat.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.
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.