Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Joy is wealth and love is the legal tender of the soul." -- Robert G. Ingersoll


devel / comp.lang.forth / Gforth on M1 macOS

SubjectAuthor
* Gforth on M1 macOSBranimir Maksimovic
`* Re: Gforth on M1 macOSAnton Ertl
 `* Re: Gforth on M1 macOSBranimir Maksimovic
  +- Re: Gforth on M1 macOSBranimir Maksimovic
  `* Re: Gforth on M1 macOSAnton Ertl
   `* Re: Gforth on M1 macOSKlapaucius Klapaucius
    +* Re: Gforth on M1 macOSAnton Ertl
    |`* Re: Gforth on M1 macOSRon AARON
    | +- Re: Gforth on M1 macOSRon AARON
    | `* Re: Gforth on M1 macOSminf...@arcor.de
    |  `- Re: Gforth on M1 macOSKlapaucius Klapaucius
    `* Re: Gforth on M1 macOSnone
     `- Re: Gforth on M1 macOSKlapaucius Klapaucius

1
Gforth on M1 macOS

<Vv%2J.176154$T_8.22116@fx48.iad>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14723&group=comp.lang.forth#14723

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx48.iad.POSTED!not-for-mail
Newsgroups: comp.lang.forth
From: branimir...@gmail.com (Branimir Maksimovic)
Subject: Gforth on M1 macOS
User-Agent: slrn/1.0.3 (Darwin)
Lines: 15
Message-ID: <Vv%2J.176154$T_8.22116@fx48.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Thu, 23 Sep 2021 13:43:17 UTC
Organization: usenet-news.net
Date: Thu, 23 Sep 2021 13:43:17 GMT
X-Received-Bytes: 688
 by: Branimir Maksimovic - Thu, 23 Sep 2021 13:43 UTC

Works.

I'll write some in it :P
let's make Forth propaganda :p
5 dup swap over rot . . . 5 5 5 ok
Perfect!
thanks, Anton.
--
7-77-777
\|/
---
/|\
--
Evil Sinner!

Re: Gforth on M1 macOS

<2021Sep23.165902@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14724&group=comp.lang.forth#14724

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Gforth on M1 macOS
Date: Thu, 23 Sep 2021 14:59:02 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 23
Message-ID: <2021Sep23.165902@mips.complang.tuwien.ac.at>
References: <Vv%2J.176154$T_8.22116@fx48.iad>
Injection-Info: reader02.eternal-september.org; posting-host="8fabd86d3e2b6929db1261085507aeab";
logging-data="28435"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18mPKbdfE74fw+so56F2tJK"
Cancel-Lock: sha1:jZCIp3KSypZ4vMhQVDDIlCsoTh8=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Thu, 23 Sep 2021 14:59 UTC

Branimir Maksimovic <branimir.maksimovic@gmail.com> writes:
>
>Works.

Good. Which version? I recommend a recent snapshot on Aarch64 for
performance.

Could you run

gforth-fast onebench.fs

and post (or send me) the output?

>thanks, Anton.

My pleasure, but I am not the only one working on Gforth.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Gforth on M1 macOS

<j_43J.84180$g81.48822@fx33.iad>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14725&group=comp.lang.forth#14725

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!peer01.ams4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx33.iad.POSTED!not-for-mail
Newsgroups: comp.lang.forth
From: branimir...@gmail.com (Branimir Maksimovic)
Subject: Re: Gforth on M1 macOS
References: <Vv%2J.176154$T_8.22116@fx48.iad>
<2021Sep23.165902@mips.complang.tuwien.ac.at>
User-Agent: slrn/1.0.3 (Darwin)
Lines: 71
Message-ID: <j_43J.84180$g81.48822@fx33.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Thu, 23 Sep 2021 19:57:03 UTC
Organization: usenet-news.net
Date: Thu, 23 Sep 2021 19:57:03 GMT
X-Received-Bytes: 2784
 by: Branimir Maksimovic - Thu, 23 Sep 2021 19:57 UTC

On 2021-09-23, Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
> Branimir Maksimovic <branimir.maksimovic@gmail.com> writes:
>>
>>Works.
>
> Good. Which version? I recommend a recent snapshot on Aarch64 for
> performance.
>
bmaxa@Branimirs-Air ~ % gforth -v
gforth 0.7.3

I'll try, but I don't need perf, just good program.
I'll plan to port some of my code to show how good
Forth is :P

tried to compile:
gcc -pthread engine-noll.o engine2-noll.o main-noll.o io.o signals.o support-noll.o arm-cacheflush0.o exp10.o sincos.o dblsub.o -ldl -lm libmain.o -o gforth-noll
true gforth-noll
cd engine && /Library/Developer/CommandLineTools/usr/bin/make DOSTRIP=true gforth-ditc-noll OPT=-noll OPTDEFINES= OPTOBJECTS=dblsub.o
make[4]: `gforth-ditc-noll' is up to date.
cp -p engine/gforth-ditc-noll gforth-ditc
true gforth-ditc
true
HOSTPREFIX="" GFORTHD="./gforth-ditc -p .:~+:." GFORTH="./gforth-ditc --die-on-signal --debug-mcheck -p .:~+:. -i kernl64l.fi exboot.fs startup.fs arch/arm/asm.fs arch/arm/disasm.fs" includedir=`pwd`/include extrastuff=' -I'`pwd`/include/gforth/0.7.9_20210916/arm bindir=`pwd` libccdir=`pwd`/lib/gforth/0.7.9_20210916/arm/libcc-named ./gforthmi gforth.fi --die-on-signal -p ".:~+:." -i kernl64l.fi exboot.fs startup.fs arch/arm/asm.fs arch/arm/disasm.fs

Segmentation fault: 11.

Segmentation fault: 11.

Segmentation fault: 11.
make[3]: *** [gforth.fi] Error 1
make[2]: *** [gforth-noll] Error 2
make[2]: *** Deleting file `gforth-noll'
make[1]: *** [optgforth] Error 2
make: *** [gforth] Error 2
> Could you run
>
> gforth-fast onebench.fs
>
> and post (or send me) the output?
bmaxa@Branimirs-Air projects % gforth-fast ./onebench.fs
sieve bubble matrix fib fft
0.244 0.244 0.176 0.276
in file included from *OS command line*:-1
onebench.fs:40: No such file or directory
>>>run-bench<<<
Backtrace:
$124813E98 throw
$124842378 included
$0
$E9DBE
$124842710 include-main-time
>
>>thanks, Anton.
>
> My pleasure, but I am not the only one working on Gforth.
>
kudos to all!
> - anton

Branimir.
--
7-77-777
\|/
---
/|\
--
Evil Sinner!

Re: Gforth on M1 macOS

<wyf3J.44293$ol1.10880@fx42.iad>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14735&group=comp.lang.forth#14735

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx42.iad.POSTED!not-for-mail
Newsgroups: comp.lang.forth
From: branimir...@gmail.com (Branimir Maksimovic)
Subject: Re: Gforth on M1 macOS
References: <Vv%2J.176154$T_8.22116@fx48.iad>
<2021Sep23.165902@mips.complang.tuwien.ac.at>
<j_43J.84180$g81.48822@fx33.iad>
User-Agent: slrn/1.0.3 (Darwin)
Lines: 109
Message-ID: <wyf3J.44293$ol1.10880@fx42.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Fri, 24 Sep 2021 07:58:20 UTC
Organization: usenet-news.net
Date: Fri, 24 Sep 2021 07:58:20 GMT
X-Received-Bytes: 3884
 by: Branimir Maksimovic - Fri, 24 Sep 2021 07:58 UTC

This is what I get by running 7.3 in gforth dir:
bmaxa@Branimirs-Air gforth % gforth-fast onebench.fs
sieve bubble matrix fib fft
0.357 0.399 0.290 0.452
in file included from *OS command line*:-1
in file included from onebench.fs:40
in file included from fft-bench.fs:3
in file included from fft.fs:23
complex.fs:43: Undefined word
: z+! ( z zaddr -- ) dup >r float+ >>>f+!<<< r> f+! ;
Backtrace:
$14F808A20 throw
$14F81EC40 no.extensions
$14F80C358 compiler-notfound1

so, I should try my best git version works.
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git://git.savannah.gnu.org/gforth.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master

--
7-77-777
\|/
---
/|\

On 2021-09-23, Branimir Maksimovic <branimir.maksimovic@gmail.com> wrote:
> On 2021-09-23, Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>> Branimir Maksimovic <branimir.maksimovic@gmail.com> writes:
>>>
>>>Works.
>>
>> Good. Which version? I recommend a recent snapshot on Aarch64 for
>> performance.
>>
> bmaxa@Branimirs-Air ~ % gforth -v
> gforth 0.7.3
>
> I'll try, but I don't need perf, just good program.
> I'll plan to port some of my code to show how good
> Forth is :P
>
> tried to compile:
> gcc -pthread engine-noll.o engine2-noll.o main-noll.o io.o signals.o support-noll.o arm-cacheflush0.o exp10.o sincos.o dblsub.o -ldl -lm libmain.o -o gforth-noll
> true gforth-noll
> cd engine && /Library/Developer/CommandLineTools/usr/bin/make DOSTRIP=true gforth-ditc-noll OPT=-noll OPTDEFINES= OPTOBJECTS=dblsub.o
> make[4]: `gforth-ditc-noll' is up to date.
> cp -p engine/gforth-ditc-noll gforth-ditc
> true gforth-ditc
> true
> HOSTPREFIX="" GFORTHD="./gforth-ditc -p .:~+:." GFORTH="./gforth-ditc --die-on-signal --debug-mcheck -p .:~+:. -i kernl64l.fi exboot.fs startup.fs arch/arm/asm.fs arch/arm/disasm.fs" includedir=`pwd`/include extrastuff=' -I'`pwd`/include/gforth/0.7.9_20210916/arm bindir=`pwd` libccdir=`pwd`/lib/gforth/0.7.9_20210916/arm/libcc-named ./gforthmi gforth.fi --die-on-signal -p ".:~+:." -i kernl64l.fi exboot.fs startup.fs arch/arm/asm.fs arch/arm/disasm.fs
>
>
> Segmentation fault: 11.
>
>
> Segmentation fault: 11.
>
>
> Segmentation fault: 11.
> make[3]: *** [gforth.fi] Error 1
> make[2]: *** [gforth-noll] Error 2
> make[2]: *** Deleting file `gforth-noll'
> make[1]: *** [optgforth] Error 2
> make: *** [gforth] Error 2
>> Could you run
>>
>> gforth-fast onebench.fs
>>
>> and post (or send me) the output?
> bmaxa@Branimirs-Air projects % gforth-fast ./onebench.fs
> sieve bubble matrix fib fft
> 0.244 0.244 0.176 0.276
> in file included from *OS command line*:-1
> onebench.fs:40: No such file or directory
> >>>run-bench<<<
> Backtrace:
> $124813E98 throw
> $124842378 included
> $0
> $E9DBE
> $124842710 include-main-time
> >
>>>thanks, Anton.
>>
>> My pleasure, but I am not the only one working on Gforth.
>>
> kudos to all!
>> - anton
>
> Branimir.
> --
> 7-77-777
> \|/
> ---
> /|\

--
Evil Sinner!

Re: Gforth on M1 macOS

<2021Sep24.095505@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14736&group=comp.lang.forth#14736

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Gforth on M1 macOS
Date: Fri, 24 Sep 2021 07:55:05 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 28
Message-ID: <2021Sep24.095505@mips.complang.tuwien.ac.at>
References: <Vv%2J.176154$T_8.22116@fx48.iad> <2021Sep23.165902@mips.complang.tuwien.ac.at> <j_43J.84180$g81.48822@fx33.iad>
Injection-Info: reader02.eternal-september.org; posting-host="10576c6f0c83c2f1d40feb39a5b048a0";
logging-data="20934"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/p/4hLS4TKxInt2TwXxUf5"
Cancel-Lock: sha1:NcucSEh3uuj5E7qSzO4PmMgz0h4=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 24 Sep 2021 07:55 UTC

Branimir Maksimovic <branimir.maksimovic@gmail.com> writes:
>On 2021-09-23, Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>HOSTPREFIX="" GFORTHD="./gforth-ditc -p .:~+:." GFORTH="./gforth-ditc --die-on-signal --debug-mcheck -p .:~+:. -i kernl64l.fi exboot.fs startup.fs arch/arm/asm.fs arch/arm/disasm.fs" includedir=`pwd`/include extrastuff=' -I'`pwd`/include/gforth/0.7.9_20210916/arm bindir=`pwd` libccdir=`pwd`/lib/gforth/0.7.9_20210916/arm/libcc-named ./gforthmi gforth.fi --die-on-signal -p ".:~+:." -i kernl64l.fi exboot.fs startup.fs arch/arm/asm.fs arch/arm/disasm.fs
>
>
>Segmentation fault: 11.
>
>
>Segmentation fault: 11.
>
>
>Segmentation fault: 11.

So the built gforth-ditc does not work. We will have to investigate
this.

>bmaxa@Branimirs-Air projects % gforth-fast ./onebench.fs
> sieve bubble matrix fib fft
> 0.244 0.244 0.176 0.276

Thanks.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Gforth on M1 macOS

<48865615-4d33-400a-975f-aa6b530dd74an@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=20771&group=comp.lang.forth#20771

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:1109:b0:39c:1d87:3b6c with SMTP id e9-20020a05622a110900b0039c1d873b6cmr8736902qty.139.1666225649362;
Wed, 19 Oct 2022 17:27:29 -0700 (PDT)
X-Received: by 2002:a81:48d6:0:b0:355:8d0a:d8a1 with SMTP id
v205-20020a8148d6000000b003558d0ad8a1mr8858518ywa.467.1666225649101; Wed, 19
Oct 2022 17:27:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 19 Oct 2022 17:27:28 -0700 (PDT)
In-Reply-To: <2021Sep24.095505@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=72.235.12.27; posting-account=un3CfgoAAAAUnJzu77CmHEesuP_2uaYl
NNTP-Posting-Host: 72.235.12.27
References: <Vv%2J.176154$T_8.22116@fx48.iad> <2021Sep23.165902@mips.complang.tuwien.ac.at>
<j_43J.84180$g81.48822@fx33.iad> <2021Sep24.095505@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <48865615-4d33-400a-975f-aa6b530dd74an@googlegroups.com>
Subject: Re: Gforth on M1 macOS
From: klapauc...@gmail.com (Klapaucius Klapaucius)
Injection-Date: Thu, 20 Oct 2022 00:27:29 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2275
 by: Klapaucius Klapauciu - Thu, 20 Oct 2022 00:27 UTC

How does gforth assemble new machine code at runtime ?

I'm not a FORTH expert, barely a neophyte. However, while trying to port a jonesforth variant for the heck of it, I did notice that Apple seems to disallow having pages with rwx permissions. You either can write to a page, or you can execute it, but not both.

Executing machine code created at runtime raises segfaults/gives bus errors..

For a FORTH that assembles code into a common segment, that poses a real quandary. I don't know how to separate the 'already written and immutable' and 'modifiable'/'new' parts of the code in FORTH - it's seems antithetical to FORTH's philosophy, if there is such a thing.

See:
[1] https://stackoverflow.com/questions/74132150/forth-implementation-with-jit-write-protection
[2] https://stackoverflow.com/questions/74124485/mmap-rwx-page-on-macos-arm64-architecture

Maybe you are seeing the same thing. If gforth has figured this out, I'd be super happy to learn how.

Re: Gforth on M1 macOS

<2022Oct20.090807@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=20773&group=comp.lang.forth#20773

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Gforth on M1 macOS
Date: Thu, 20 Oct 2022 07:08:07 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 30
Message-ID: <2022Oct20.090807@mips.complang.tuwien.ac.at>
References: <Vv%2J.176154$T_8.22116@fx48.iad> <2021Sep23.165902@mips.complang.tuwien.ac.at> <j_43J.84180$g81.48822@fx33.iad> <2021Sep24.095505@mips.complang.tuwien.ac.at> <48865615-4d33-400a-975f-aa6b530dd74an@googlegroups.com>
Injection-Info: reader01.eternal-september.org; posting-host="bf533649dfcac21154be660b3a763821";
logging-data="313325"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18TMm15AYnThIbqpD8+ub5L"
Cancel-Lock: sha1:OL77NTvfEJL5fc936xLZFlLfZqw=
X-newsreader: xrn 10.11
 by: Anton Ertl - Thu, 20 Oct 2022 07:08 UTC

Klapaucius Klapaucius <klapaucius@gmail.com> writes:
>How does gforth assemble new machine code at runtime ?
>
>I'm not a FORTH expert, barely a neophyte. However, while trying to port a =
>jonesforth variant for the heck of it, I did notice that Apple seems to dis=
>allow having pages with rwx permissions.

Yes, my (unfinished) attempts at porting Gforth to MacOS on ARM64
revealed that to me.

>Maybe you are seeing the same thing. If gforth has figured this out, I'd be=
> super happy to learn how.

For now Gforth does not work on MacOS on ARM64. My plan is to disable
native code generation and fall back to threaded code (so Gforth on
MacOS will be slower than Gforth on Linux on the same hardware). If I
was much more motivated, I would try to map the same memory twice,
once RW and once RX, and use one mapping for writing and one for
executing. I don't know if that works on MacOS on ARM64, though.
Another alternative is to change the page(s) you want to write to RW
before writing and back to RX afterwards, using mprotect(); note that
the code that is executed between these two mprotect()s has to be
executable all the time.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2022: https://euro.theforth.net

Re: Gforth on M1 macOS

<tiqvru$9qn3$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=20775&group=comp.lang.forth#20775

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: Gforth on M1 macOS
Date: Thu, 20 Oct 2022 11:11:41 +0300
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <tiqvru$9qn3$1@dont-email.me>
References: <Vv%2J.176154$T_8.22116@fx48.iad>
<2021Sep23.165902@mips.complang.tuwien.ac.at>
<j_43J.84180$g81.48822@fx33.iad>
<2021Sep24.095505@mips.complang.tuwien.ac.at>
<48865615-4d33-400a-975f-aa6b530dd74an@googlegroups.com>
<2022Oct20.090807@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Oct 2022 08:11:42 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="d5ea2b861b01775642c70fb5dd142d09";
logging-data="322275"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+U3a3K1caYTSaHcZL+BCcV"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.3.3
Cancel-Lock: sha1:KYqiDhQBO7qiBdj5sqvJ5+geyp4=
Content-Language: en-US
In-Reply-To: <2022Oct20.090807@mips.complang.tuwien.ac.at>
 by: Ron AARON - Thu, 20 Oct 2022 08:11 UTC

On 20/10/2022 10:08, Anton Ertl wrote:
> Klapaucius Klapaucius <klapaucius@gmail.com> writes:
>> How does gforth assemble new machine code at runtime ?
>>
>> I'm not a FORTH expert, barely a neophyte. However, while trying to port a =
>> jonesforth variant for the heck of it, I did notice that Apple seems to dis=
>> allow having pages with rwx permissions.
>
> Yes, my (unfinished) attempts at porting Gforth to MacOS on ARM64
> revealed that to me.
>
>> Maybe you are seeing the same thing. If gforth has figured this out, I'd be=
>> super happy to learn how.
>
> For now Gforth does not work on MacOS on ARM64. My plan is to disable
> native code generation and fall back to threaded code (so Gforth on
> MacOS will be slower than Gforth on Linux on the same hardware). If I
> was much more motivated, I would try to map the same memory twice,
> once RW and once RX, and use one mapping for writing and one for
> executing. I don't know if that works on MacOS on ARM64, though.
> Another alternative is to change the page(s) you want to write to RW
> before writing and back to RX afterwards, using mprotect(); note that
> the code that is executed between these two mprotect()s has to be
> executable all the time.
>
> - anton

8th's M1 port uses "pthread_jit_write_protect_np()" as appropriate
before and after writing native code.

Re: Gforth on M1 macOS

<tiqvv8$9qn3$2@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=20776&group=comp.lang.forth#20776

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: Gforth on M1 macOS
Date: Thu, 20 Oct 2022 11:13:27 +0300
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <tiqvv8$9qn3$2@dont-email.me>
References: <Vv%2J.176154$T_8.22116@fx48.iad>
<2021Sep23.165902@mips.complang.tuwien.ac.at>
<j_43J.84180$g81.48822@fx33.iad>
<2021Sep24.095505@mips.complang.tuwien.ac.at>
<48865615-4d33-400a-975f-aa6b530dd74an@googlegroups.com>
<2022Oct20.090807@mips.complang.tuwien.ac.at> <tiqvru$9qn3$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Oct 2022 08:13:28 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="d5ea2b861b01775642c70fb5dd142d09";
logging-data="322275"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+0RVpMw9+Gh7QO6l6Y5csT"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.3.3
Cancel-Lock: sha1:PjmXgD5fPqMDxFiBMKZmlhF3zZE=
In-Reply-To: <tiqvru$9qn3$1@dont-email.me>
Content-Language: en-US
 by: Ron AARON - Thu, 20 Oct 2022 08:13 UTC

On 20/10/2022 11:11, Ron AARON wrote:
> On 20/10/2022 10:08, Anton Ertl wrote:
>> Klapaucius Klapaucius <klapaucius@gmail.com> writes:
>>> How does gforth assemble new machine code at runtime ?
>>>
>>> I'm not a FORTH expert, barely a neophyte. However, while trying to
>>> port a =
>>> jonesforth variant for the heck of it, I did notice that Apple seems
>>> to dis=
>>> allow having pages with rwx permissions.
>>
>> Yes, my (unfinished) attempts at porting Gforth to MacOS on ARM64
>> revealed that to me.
>>
>>> Maybe you are seeing the same thing. If gforth has figured this out,
>>> I'd be=
>>> super happy to learn how.
>>
>> For now Gforth does not work on MacOS on ARM64.  My plan is to disable
>> native code generation and fall back to threaded code (so Gforth on
>> MacOS will be slower than Gforth on Linux on the same hardware).  If I
>> was much more motivated, I would try to map the same memory twice,
>> once RW and once RX, and use one mapping for writing and one for
>> executing.  I don't know if that works on MacOS on ARM64, though.
>> Another alternative is to change the page(s) you want to write to RW
>> before writing and back to RX afterwards, using mprotect(); note that
>> the code that is executed between these two mprotect()s has to be
>> executable all the time.
>>
>> - anton
>
> 8th's M1 port uses "pthread_jit_write_protect_np()" as appropriate
> before and after writing native code.

And, I almost forgot:

void __clear_cache(void *start, void *end)
{ sys_icache_invalidate(start, (char *)end-(char *)start);
}

Re: Gforth on M1 macOS

<716a5ee9-4290-4114-b346-fe70e981c296n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=20778&group=comp.lang.forth#20778

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5854:0:b0:39c:dba4:6fa0 with SMTP id h20-20020ac85854000000b0039cdba46fa0mr9990938qth.175.1666254248568;
Thu, 20 Oct 2022 01:24:08 -0700 (PDT)
X-Received: by 2002:a25:b851:0:b0:6ca:2b0b:d334 with SMTP id
b17-20020a25b851000000b006ca2b0bd334mr1984951ybm.104.1666254248320; Thu, 20
Oct 2022 01:24:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 20 Oct 2022 01:24:08 -0700 (PDT)
In-Reply-To: <tiqvru$9qn3$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f34:655:9c83:8c5b:62c5:f924;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f34:655:9c83:8c5b:62c5:f924
References: <Vv%2J.176154$T_8.22116@fx48.iad> <2021Sep23.165902@mips.complang.tuwien.ac.at>
<j_43J.84180$g81.48822@fx33.iad> <2021Sep24.095505@mips.complang.tuwien.ac.at>
<48865615-4d33-400a-975f-aa6b530dd74an@googlegroups.com> <2022Oct20.090807@mips.complang.tuwien.ac.at>
<tiqvru$9qn3$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <716a5ee9-4290-4114-b346-fe70e981c296n@googlegroups.com>
Subject: Re: Gforth on M1 macOS
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Thu, 20 Oct 2022 08:24:08 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3024
 by: minf...@arcor.de - Thu, 20 Oct 2022 08:24 UTC

Ron AARON schrieb am Donnerstag, 20. Oktober 2022 um 10:11:45 UTC+2:
> On 20/10/2022 10:08, Anton Ertl wrote:
> > Klapaucius Klapaucius <klapa...@gmail.com> writes:
> >> How does gforth assemble new machine code at runtime ?
> >>
> >> I'm not a FORTH expert, barely a neophyte. However, while trying to port a =
> >> jonesforth variant for the heck of it, I did notice that Apple seems to dis=
> >> allow having pages with rwx permissions.
> >
> > Yes, my (unfinished) attempts at porting Gforth to MacOS on ARM64
> > revealed that to me.
> >
> >> Maybe you are seeing the same thing. If gforth has figured this out, I'd be=
> >> super happy to learn how.
> >
> > For now Gforth does not work on MacOS on ARM64. My plan is to disable
> > native code generation and fall back to threaded code (so Gforth on
> > MacOS will be slower than Gforth on Linux on the same hardware). If I
> > was much more motivated, I would try to map the same memory twice,
> > once RW and once RX, and use one mapping for writing and one for
> > executing. I don't know if that works on MacOS on ARM64, though.
> > Another alternative is to change the page(s) you want to write to RW
> > before writing and back to RX afterwards, using mprotect(); note that
> > the code that is executed between these two mprotect()s has to be
> > executable all the time.
> >
> > - anton
> 8th's M1 port uses "pthread_jit_write_protect_np()" as appropriate
> before and after writing native code.

Yep. See for instance:
https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon

Re: Gforth on M1 macOS

<nnd$2797ea81$397320e6@88c307c2f707dbdf>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=20782&group=comp.lang.forth#20782

 copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
References: <Vv%2J.176154$T_8.22116@fx48.iad> <j_43J.84180$g81.48822@fx33.iad> <2021Sep24.095505@mips.complang.tuwien.ac.at> <48865615-4d33-400a-975f-aa6b530dd74an@googlegroups.com>
Subject: Re: Gforth on M1 macOS
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$2797ea81$397320e6@88c307c2f707dbdf>
Organization: KPN B.V.
Date: Thu, 20 Oct 2022 13:47:44 +0200
Path: i2pn2.org!i2pn.org!news.swapon.de!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe006.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 55
Injection-Date: Thu, 20 Oct 2022 13:47:44 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 3060
 by: none - Thu, 20 Oct 2022 11:47 UTC

In article <48865615-4d33-400a-975f-aa6b530dd74an@googlegroups.com>,
Klapaucius Klapaucius <klapaucius@gmail.com> wrote:
>How does gforth assemble new machine code at runtime ?
>
>I'm not a FORTH expert, barely a neophyte. However, while trying to port
>a jonesforth variant for the heck of it, I did notice that Apple seems
>to disallow having pages with rwx permissions. You either can write to a
>page, or you can execute it, but not both.
>
>Executing machine code created at runtime raises segfaults/gives bus errors.
>
>For a FORTH that assembles code into a common segment, that poses a real
>quandary. I don't know how to separate the 'already written and
>immutable' and 'modifiable'/'new' parts of the code in FORTH - it's
>seems antithetical to FORTH's philosophy, if there is such a thing.
>
>See:
>[1]
>https://stackoverflow.com/questions/74132150/forth-implementation-with-jit-write-protection
>[2]
>https://stackoverflow.com/questions/74124485/mmap-rwx-page-on-macos-arm64-architecture
>
>Maybe you are seeing the same thing. If gforth has figured this out, I'd
>be super happy to learn how.

jonesforth is loosely based on ciforth.
https://github.com/albertvanderhorst/ciforth
A guy name Spykerman has figured this out a long time ago for me
long ago for the Apple.

ciforth comes in a number of thoroughly tested versions under which
xina for the apple.
See ciforth.html on my site below.
The exercise to convert a ciforth to a jonesforth is trivial.
I don't like this much.
- ciforth is as simple as jonesforth
- ciforth is solid ISO94
- ciforth is carefully designed to allow extensions that
you can, but need not, use.
(fp, multitasking,decorators, scripting, native executables,
32/64 bit assembler, you name it.)

I have made a competing pedagogical effort to jonesforth:
https://github.com/albertvanderhorst/yourforth
that has at least no gratitious deviations from ISO94.
Throwing out doubles, the <# # #S #> has to be redefined as
<% % %S %> .

Groetjes Albert
--
"in our communism country Viet Nam, people are forced to be
alive and in the western country like US, people are free to
die from Covid 19 lol" duc ha
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

Re: Gforth on M1 macOS

<b1a135d1-6504-4f96-b2d0-a99227835f62n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=20787&group=comp.lang.forth#20787

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:20c1:b0:4b9:f285:de7e with SMTP id 1-20020a05621420c100b004b9f285de7emr1724643qve.14.1666291214625;
Thu, 20 Oct 2022 11:40:14 -0700 (PDT)
X-Received: by 2002:a25:190b:0:b0:6c4:ee7:5ab5 with SMTP id
11-20020a25190b000000b006c40ee75ab5mr12846824ybz.245.1666291214331; Thu, 20
Oct 2022 11:40:14 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 20 Oct 2022 11:40:14 -0700 (PDT)
In-Reply-To: <716a5ee9-4290-4114-b346-fe70e981c296n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=72.235.12.27; posting-account=un3CfgoAAAAUnJzu77CmHEesuP_2uaYl
NNTP-Posting-Host: 72.235.12.27
References: <Vv%2J.176154$T_8.22116@fx48.iad> <2021Sep23.165902@mips.complang.tuwien.ac.at>
<j_43J.84180$g81.48822@fx33.iad> <2021Sep24.095505@mips.complang.tuwien.ac.at>
<48865615-4d33-400a-975f-aa6b530dd74an@googlegroups.com> <2022Oct20.090807@mips.complang.tuwien.ac.at>
<tiqvru$9qn3$1@dont-email.me> <716a5ee9-4290-4114-b346-fe70e981c296n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b1a135d1-6504-4f96-b2d0-a99227835f62n@googlegroups.com>
Subject: Re: Gforth on M1 macOS
From: klapauc...@gmail.com (Klapaucius Klapaucius)
Injection-Date: Thu, 20 Oct 2022 18:40:14 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3976
 by: Klapaucius Klapauciu - Thu, 20 Oct 2022 18:40 UTC

I don't think that's enough. For a traditional java JIT etc, the code that generates the new code lives in a separate space, presumably. This is possible because the jit compiler itself is immutable.

In FORTH, the compiler itself can be and often is (re)written at runtime, in the same segments non-compiler stuff is.

I believe one would have to somehow separate out the 'compiler' code from 'non-compiler' code - then you could at least create native non-compiler code your way.

It seems like a lot of work for not that much benefit, at the cost of significantly complicating the FORTH language model.

It's annoying that Apple seems to have made a policy choice to intentionally cripple their machines without an out (e.g. remove sip protection). Sigh.

On Wednesday, October 19, 2022 at 10:24:09 PM UTC-10, minf...@arcor.de wrote:
> Ron AARON schrieb am Donnerstag, 20. Oktober 2022 um 10:11:45 UTC+2:
> > On 20/10/2022 10:08, Anton Ertl wrote:
> > > Klapaucius Klapaucius <klapa...@gmail.com> writes:
> > >> How does gforth assemble new machine code at runtime ?
> > >>
> > >> I'm not a FORTH expert, barely a neophyte. However, while trying to port a =
> > >> jonesforth variant for the heck of it, I did notice that Apple seems to dis=
> > >> allow having pages with rwx permissions.
> > >
> > > Yes, my (unfinished) attempts at porting Gforth to MacOS on ARM64
> > > revealed that to me.
> > >
> > >> Maybe you are seeing the same thing. If gforth has figured this out, I'd be=
> > >> super happy to learn how.
> > >
> > > For now Gforth does not work on MacOS on ARM64. My plan is to disable
> > > native code generation and fall back to threaded code (so Gforth on
> > > MacOS will be slower than Gforth on Linux on the same hardware). If I
> > > was much more motivated, I would try to map the same memory twice,
> > > once RW and once RX, and use one mapping for writing and one for
> > > executing. I don't know if that works on MacOS on ARM64, though.
> > > Another alternative is to change the page(s) you want to write to RW
> > > before writing and back to RX afterwards, using mprotect(); note that
> > > the code that is executed between these two mprotect()s has to be
> > > executable all the time.
> > >
> > > - anton
> > 8th's M1 port uses "pthread_jit_write_protect_np()" as appropriate
> > before and after writing native code.
> Yep. See for instance:
> https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon

Re: Gforth on M1 macOS

<75145ad2-b436-48ca-875b-70c878a7bbc2n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=20789&group=comp.lang.forth#20789

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5b51:0:b0:39a:ea24:2c6 with SMTP id n17-20020ac85b51000000b0039aea2402c6mr12948951qtw.490.1666294107039;
Thu, 20 Oct 2022 12:28:27 -0700 (PDT)
X-Received: by 2002:a0d:ef46:0:b0:35c:b6be:ac2a with SMTP id
y67-20020a0def46000000b0035cb6beac2amr12377051ywe.391.1666294106741; Thu, 20
Oct 2022 12:28:26 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 20 Oct 2022 12:28:26 -0700 (PDT)
In-Reply-To: <nnd$2797ea81$397320e6@88c307c2f707dbdf>
Injection-Info: google-groups.googlegroups.com; posting-host=72.235.12.27; posting-account=un3CfgoAAAAUnJzu77CmHEesuP_2uaYl
NNTP-Posting-Host: 72.235.12.27
References: <Vv%2J.176154$T_8.22116@fx48.iad> <j_43J.84180$g81.48822@fx33.iad>
<2021Sep24.095505@mips.complang.tuwien.ac.at> <48865615-4d33-400a-975f-aa6b530dd74an@googlegroups.com>
<nnd$2797ea81$397320e6@88c307c2f707dbdf>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <75145ad2-b436-48ca-875b-70c878a7bbc2n@googlegroups.com>
Subject: Re: Gforth on M1 macOS
From: klapauc...@gmail.com (Klapaucius Klapaucius)
Injection-Date: Thu, 20 Oct 2022 19:28:27 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4715
 by: Klapaucius Klapauciu - Thu, 20 Oct 2022 19:28 UTC

Very cool, ciforth!

I chose jonesforth mostly because I already had ported it to macOS Catalina on x64, and because I found a linux implemenation for ARM64 that I hoped would be trivial to port:

https://github.com/narenratan/jonesforth_arm64_apl/blob/master/jonesforth.S

It's pretty fun with all the APL syntax ;) I don't mind that it's not standards compatible, I'd care more if I were to write larger systems with it. It's more like a toy for me right now, and to learn a bit of ARM assembly code - porting a forth is a fun way of doing that ;)

If I had more time, I'd create a usable system for ARM/RISC SOC boards, like micropython. But my RTOS-fu is not up to the task and I don't have the time to level up ...
When I do, I keep ciforth in mind!

Have a great day!
K On Thursday, October 20, 2022 at 1:47:47 AM UTC-10, none albert wrote:
> In article <48865615-4d33-400a...@googlegroups.com>,
> Klapaucius Klapaucius <klapa...@gmail.com> wrote:
> >How does gforth assemble new machine code at runtime ?
> >
> >I'm not a FORTH expert, barely a neophyte. However, while trying to port
> >a jonesforth variant for the heck of it, I did notice that Apple seems
> >to disallow having pages with rwx permissions. You either can write to a
> >page, or you can execute it, but not both.
> >
> >Executing machine code created at runtime raises segfaults/gives bus errors.
> >
> >For a FORTH that assembles code into a common segment, that poses a real
> >quandary. I don't know how to separate the 'already written and
> >immutable' and 'modifiable'/'new' parts of the code in FORTH - it's
> >seems antithetical to FORTH's philosophy, if there is such a thing.
> >
> >See:
> >[1]
> >https://stackoverflow.com/questions/74132150/forth-implementation-with-jit-write-protection
> >[2]
> >https://stackoverflow.com/questions/74124485/mmap-rwx-page-on-macos-arm64-architecture
> >
> >Maybe you are seeing the same thing. If gforth has figured this out, I'd
> >be super happy to learn how.
> jonesforth is loosely based on ciforth.
> https://github.com/albertvanderhorst/ciforth
> A guy name Spykerman has figured this out a long time ago for me
> long ago for the Apple.
>
> ciforth comes in a number of thoroughly tested versions under which
> xina for the apple.
> See ciforth.html on my site below.
> The exercise to convert a ciforth to a jonesforth is trivial.
> I don't like this much.
> - ciforth is as simple as jonesforth
> - ciforth is solid ISO94
> - ciforth is carefully designed to allow extensions that
> you can, but need not, use.
> (fp, multitasking,decorators, scripting, native executables,
> 32/64 bit assembler, you name it.)
>
> I have made a competing pedagogical effort to jonesforth:
> https://github.com/albertvanderhorst/yourforth
> that has at least no gratitious deviations from ISO94.
> Throwing out doubles, the <# # #S #> has to be redefined as
> <% % %S %> .
>
> Groetjes Albert
> --
> "in our communism country Viet Nam, people are forced to be
> alive and in the western country like US, people are free to
> die from Covid 19 lol" duc ha
> albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor