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.
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
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.
Maybe you are seeing the same thing. If gforth has figured this out, I'd be=
super happy to learn how.
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.
- anton8th's M1 port uses "pthread_jit_write_protect_np()" as appropriate
before and after writing native code.
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.
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.
Yep. See for instance: https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon- anton8th's M1 port uses "pthread_jit_write_protect_np()" as appropriate
before and after writing native code.
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
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 233:00:07 |
Calls: | 6,624 |
Files: | 12,171 |
Messages: | 5,319,559 |