Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

C for yourself.


devel / comp.lang.forth / Sections benefits quantified

SubjectAuthor
* Sections benefits quantifiedAnton Ertl
+* Re: Sections benefits quantifiedMarcel Hendrix
|`- Re: Sections benefits quantifiedAnton Ertl
+* Re: Sections benefits quantifiedAnton Ertl
|`- Re: Sections benefits quantifiedAnton Ertl
+* Re: Sections benefits quantifieddxforth
|`* Re: Sections benefits quantifiedAnton Ertl
| `* Re: Sections benefits quantifieddxforth
|  `- Re: Sections benefits quantifiedAnton Ertl
+* Re: Sections benefits quantifiedminf...@arcor.de
|`* Re: Sections benefits quantifiedAnton Ertl
| `- Re: Sections benefits quantifiedminf...@arcor.de
+* Re: Sections benefits quantifiedPaul Rubin
|+* Re: Sections benefits quantifieddxforth
||+* Re: Sections benefits quantifiedPaul Rubin
|||`- Re: Sections benefits quantifiedAnton Ertl
||`- Re: Sections benefits quantifiedAndy Valencia
|`* Re: Sections benefits quantifiedAnton Ertl
| `* Re: Sections benefits quantifiedPaul Rubin
|  `- Re: Sections benefits quantifiedAnton Ertl
+* Re: Sections benefits quantifiedGerry Jackson
|`* Re: Sections benefits quantifiedAnton Ertl
| `* Re: Sections benefits quantifiedGerry Jackson
|  +* Re: Sections benefits quantifiedHans Bezemer
|  |+- Re: Sections benefits quantifiedGerry Jackson
|  |`- Re: Sections benefits quantifieddxforth
|  `* Re: Sections benefits quantifiedAnton Ertl
|   `* Re: Sections benefits quantifiedKrishna Myneni
|    +- Re: Sections benefits quantifiedKrishna Myneni
|    `- Re: Sections benefits quantifiedAnton Ertl
+- Re: Sections benefits quantifiedMike
`* Sections formalization (was: Sections benefits quantified)Ruvim
 +* Re: Sections formalization (was: Sections benefits quantified)minf...@arcor.de
 |+- Re: Sections formalization (was: Sections benefits quantified)Ruvim
 |`* Re: Sections formalization (was: Sections benefits quantified)Anton Ertl
 | `* Re: Sections formalizationPaul Rubin
 |  +- Re: Sections formalizationdxforth
 |  `- Re: Sections formalizationAnton Ertl
 +* Re: Sections formalization (was: Sections benefits quantified)Anton Ertl
 |`* Re: Sections formalizationRuvim
 | `* Re: Sections formalizationAnton Ertl
 |  +* Re: Sections formalizationGerry Jackson
 |  |`- Re: Sections formalizationAnton Ertl
 |  `* Re: Sections formalizationRuvim
 |   `* Re: Sections formalizationAnton Ertl
 |    +- Re: Sections formalizationdxforth
 |    `* Re: Sections formalizationRuvim
 |     +* Re: Sections formalizationAnton Ertl
 |     |`* Re: Sections formalizationRuvim
 |     | `* Re: Sections formalizationAnton Ertl
 |     |  `- Re: Sections formalizationRuvim
 |     `* Re: Sections formalizationdxforth
 |      `- Re: Sections formalizationRuvim
 `- Re: Sections formalization (was: Sections benefits quantified)none

Pages:123
Sections benefits quantified

<2021Aug6.095019@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Sections benefits quantified
Date: Fri, 06 Aug 2021 07:50:19 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 104
Message-ID: <2021Aug6.095019@mips.complang.tuwien.ac.at>
Injection-Info: reader02.eternal-september.org; posting-host="347297b1f490ce60f1c8ef192e40269a";
logging-data="10530"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+Smlf7aWVdKsOnXbCTw/2"
Cancel-Lock: sha1:53/8J9DmWQaS6zf7oc7iN5KxY8E=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 6 Aug 2021 07:50 UTC

We have added multiple sections [ertl-sections16] to Gforth. Sections
are the same concept as in assembly language and binary formats
(e.g. ELF): Classical Forth has one section=dictionary: A stretch of
memory from the start to HERE, with the address space behind available
for future allocation. Each section works like the dictionary: It has
a stretch of allocated memory, and behind that there is memory
available for future allocation.

Gforth offers the following interface for sections: There is a current
section (by default the ordinary dictionary), and HERE and UNUSED
produce the results for the current section, and ALLOT etc. work on
that section. You can temporarily change the section.

We have a stack of sections starting with the ordinary dictionary. We
also have named sections (not section stacks, unstackable named
sections are good enough for now). E.g., when I type .SECTIONS after
starting gforth, I get:

start size +dp name
7F7FFB5D8000 4000 518 locals-headers
> 7F7FF9B81040 800000 898F8 Forth
7F7FF9980000 200000 4DE8 noname
7F7FF98FF000 80000 5B8 noname
7F7FFB401000 20000 100 noname

The "size" column indicates the maximum size of that section, "+dp"
the ALLOTed memory in that section. "Forth" is the traditional
dictionary, and the ">" indicates that it is the current section; the
noname sections below are the stack of sections associated with the
dictionary. "locals-headers" is a section that contains the names of
currently visible locals.

Some major uses of sections are for storing quotations and string
literals that are compiled into a colon definition: We switch to the
next section in the stack, put the quotation or string there, then
switch back, and compile some literal pointing to the quotation or
string in the other section. This avoids the need to branch around
the quotation or string compiled into the same section.

I would have liked to quantify the benefit that this use of sections
gives us by using the old branch-around scheme and comparing the
results, but a quick attempt resulted in a crash, so apparently there
is code in gforth that relies on sections being separate. However,
what I have seen is that just by loading a few Gforth files after the
sections code rather than before, the native code size in gforth-fast
shrank by 224 bytes.

Another (recent) use of sections is for storing the locals headers.
Originally Gforth had a 1000-Byte buffer for that, which served like a
section before we introduced sections. But that buffer was stored in
its whole length in the image, unlike sections, of which only the
alloted part is stored, so we did not want to make it really large.
In 2011 (I guess when we introduced quotations), we felt that
something less limited was needed, and we ALLOCATEd the names of the
locals (stored in a linked list for deallocation). Since then, we
have added sections, so yesterday I changed allocation of locals names
to use a section LOCALS-HEADERS instead of using ALLOCATE.

This allowed me to rip out the code for ALLOCATEing and FREEing the
locals names, and for allowing to CREATE names in that allocated
memory. The result is that the source code shrank by 40 lines:

git log --shortstat b3118b84...f634044881a
....
2 files changed, 25 insertions(+), 65 deletions(-)

The threaded code (on a 64-bit system) shrank by 2608 bytes, and the
native code on AMD64 gforth-fast shrank by 1744 bytes.

The paper below is surprisingly (to me) up-to-date. I originally
envisioned having stacks for all named sections, but they have not
been needed yet.

@InProceedings{ertl-sections16,
author = {M. Anton Ertl},
title = {Sections},
crossref = {euroforth16},
pages = {55--57},
url = {http://www.complang.tuwien.ac.at/papers/ertl-sections16.pdf},
video = {https://wiki.forth-ev.de/lib/exe/fetch.php/events:sections.mp4},
OPTnote = {not refereed},
abstract = {A section is a contiguous region of memory, to which
data or code can be appended (like the Forth
dictionary). Assembly languages and linkers have
supported multiple sections for a long time. This
paper describes the benefits of supporting multiple
sections in Forth, interfaces and implementation
techniques.}
}

@Proceedings{euroforth16,
title = {32nd EuroForth Conference},
booktitle = {32nd EuroForth Conference},
year = {2016},
key = {EuroForth'16},
url = {http://www.complang.tuwien.ac.at/anton/euroforth/ef16/papers/proceedings.pdf}
}

- 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: Sections benefits quantified

<43d62184-eca1-4421-8414-f156c4ad9bbcn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a0c:f40e:: with SMTP id h14mr10145010qvl.14.1628245173646;
Fri, 06 Aug 2021 03:19:33 -0700 (PDT)
X-Received: by 2002:ac8:7eea:: with SMTP id r10mr8170148qtc.286.1628245173507;
Fri, 06 Aug 2021 03:19:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 6 Aug 2021 03:19:33 -0700 (PDT)
In-Reply-To: <2021Aug6.095019@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f14:600:977:ebad:e7cd:6c8a;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f14:600:977:ebad:e7cd:6c8a
References: <2021Aug6.095019@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <43d62184-eca1-4421-8414-f156c4ad9bbcn@googlegroups.com>
Subject: Re: Sections benefits quantified
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Fri, 06 Aug 2021 10:19:33 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Marcel Hendrix - Fri, 6 Aug 2021 10:19 UTC

On Friday, August 6, 2021 at 10:56:05 AM UTC+2, Anton Ertl wrote:
> We have added multiple sections [ertl-sections16] to Gforth. Sections
> are the same concept as in assembly language and binary formats
> (e.g. ELF): Classical Forth has one section=dictionary: A stretch of
> memory from the start to HERE, with the address space behind available
> for future allocation. Each section works like the dictionary: It has
> a stretch of allocated memory, and behind that there is memory
> available for future allocation.
[..]
Doesn't this scheme complicate inlining?

-marcel

Re: Sections benefits quantified

<2021Aug6.125149@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Sections benefits quantified
Date: Fri, 06 Aug 2021 10:51:49 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 24
Message-ID: <2021Aug6.125149@mips.complang.tuwien.ac.at>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at> <43d62184-eca1-4421-8414-f156c4ad9bbcn@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="347297b1f490ce60f1c8ef192e40269a";
logging-data="26251"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+uqJGPHRKl/mTAHEAlRZSH"
Cancel-Lock: sha1:q+3QApcRHiH+PrDFZaQxHRLnzKo=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 6 Aug 2021 10:51 UTC

Marcel Hendrix <mhx@iae.nl> writes:
>On Friday, August 6, 2021 at 10:56:05 AM UTC+2, Anton Ertl wrote:
>> We have added multiple sections [ertl-sections16] to Gforth. Sections
>> are the same concept as in assembly language and binary formats
>> (e.g. ELF): Classical Forth has one section=dictionary: A stretch of
>> memory from the start to HERE, with the address space behind available
>> for future allocation. Each section works like the dictionary: It has
>> a stretch of allocated memory, and behind that there is memory
>> available for future allocation.
>[..]
>Doesn't this scheme complicate inlining?

Gforth does not have inlining, but I don't see why it would. If we
had inlining at the threaded-code level (for which we have sections),
it would just compile the contents of the called colon definition
instead of the call, all in the current section, so sections don't
come into play here.

- 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: Sections benefits quantified

<2021Aug6.125906@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Sections benefits quantified
Date: Fri, 06 Aug 2021 10:59:06 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 92
Message-ID: <2021Aug6.125906@mips.complang.tuwien.ac.at>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at>
Injection-Info: reader02.eternal-september.org; posting-host="347297b1f490ce60f1c8ef192e40269a";
logging-data="4498"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18/TrefUKoyCTIu27kcivpL"
Cancel-Lock: sha1:UKsmIpCD0W9pJ6KvmIht2Y7z/rQ=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 6 Aug 2021 10:59 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>We have added multiple sections [ertl-sections16] to Gforth. Sections
>are the same concept as in assembly language and binary formats
>(e.g. ELF): Classical Forth has one section=dictionary: A stretch of
>memory from the start to HERE, with the address space behind available
>for future allocation. Each section works like the dictionary: It has
>a stretch of allocated memory, and behind that there is memory
>available for future allocation.
>
>Gforth offers the following interface for sections: There is a current
>section (by default the ordinary dictionary), and HERE and UNUSED
>produce the results for the current section, and ALLOT etc. work on
>that section. You can temporarily change the section.
>
>We have a stack of sections starting with the ordinary dictionary. We
>also have named sections (not section stacks, unstackable named
>sections are good enough for now). E.g., when I type .SECTIONS after
>starting gforth, I get:
>
> start size +dp name
> 7F7FFB5D8000 4000 518 locals-headers
>> 7F7FF9B81040 800000 898F8 Forth
> 7F7FF9980000 200000 4DE8 noname
> 7F7FF98FF000 80000 5B8 noname
> 7F7FFB401000 20000 100 noname
>
>The "size" column indicates the maximum size of that section, "+dp"
>the ALLOTed memory in that section. "Forth" is the traditional
>dictionary, and the ">" indicates that it is the current section; the
>noname sections below are the stack of sections associated with the
>dictionary. "locals-headers" is a section that contains the names of
>currently visible locals.
>
>Some major uses of sections are for storing quotations and string
>literals that are compiled into a colon definition: We switch to the
>next section in the stack, put the quotation or string there, then
>switch back, and compile some literal pointing to the quotation or
>string in the other section. This avoids the need to branch around
>the quotation or string compiled into the same section.
>
>I would have liked to quantify the benefit that this use of sections
>gives us by using the old branch-around scheme and comparing the
>results, but a quick attempt resulted in a crash, so apparently there
>is code in gforth that relies on sections being separate.

I have now taken a different approach: Instead of measuring the
difference by having both versions and comparing the sizes, I now
count how many branches-around would have been generated, and
computing the size difference from that.

I count 550 calls to NEXT-SECTION (each of which replaces one branch
around). On the threaded-code level this replaces 8800 bytes on a
64-bit system.

On the native-code level, things are more complicated: Each
threaded-code branch is expanded into 16 bytes (in AMD64 gforth-fast).
But because we don't have sections on the native-code level, we still
make sure that a NEXT (5 bytes) is generated before a quotation. I
did not count the quotations, and anyway, there may have been a NEXT
generated before for other reasons. The bottom line is that between
(16-5)*550=6050 bytes and 16*550=8800 bytes of additional native code
would be generated if we did not use sections.

If the explanation for the native code is not clear to you, never
mind. Just consider how much these branches would cost in your
favourite implementation model.

>I changed allocation of locals names
>to use a section LOCALS-HEADERS instead of using ALLOCATE.
>
>This allowed me to rip out the code for ALLOCATEing and FREEing the
>locals names, and for allowing to CREATE names in that allocated
>memory. The result is that the source code shrank by 40 lines:
>
>git log --shortstat b3118b84...f634044881a
>...
>2 files changed, 25 insertions(+), 65 deletions(-)
>
>The threaded code (on a 64-bit system) shrank by 2608 bytes, and the
>native code on AMD64 gforth-fast shrank by 1744 bytes.

Of course the code for dealing with sections also has a cost: It costs
123 lines (without file header, test code and .SECTIONS), 4424 bytes
of dictionary (threaded code, etc) on a 64-bit system, and 4794 bytes
of native code.

- 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: Sections benefits quantified

<seje1f$367$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Sections benefits quantified
Date: Fri, 6 Aug 2021 23:38:55 +1000
Organization: Aioe.org NNTP Server
Message-ID: <seje1f$367$1@gioia.aioe.org>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="3271"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Fri, 6 Aug 2021 13:38 UTC

There must be complications that arise from having sections e.g.
dictionary trimming. How do you handle those?

Re: Sections benefits quantified

<2021Aug6.165657@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Sections benefits quantified
Date: Fri, 06 Aug 2021 14:56:57 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 82
Message-ID: <2021Aug6.165657@mips.complang.tuwien.ac.at>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at> <2021Aug6.125906@mips.complang.tuwien.ac.at>
Injection-Info: reader02.eternal-september.org; posting-host="347297b1f490ce60f1c8ef192e40269a";
logging-data="7307"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182qPfprVo0/QTs0lv4du/J"
Cancel-Lock: sha1:5ewlJpTvkq5AuIgWrBKeR8m9EZE=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 6 Aug 2021 14:56 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>We have added multiple sections [ertl-sections16] to Gforth. Sections
>>are the same concept as in assembly language and binary formats
>>(e.g. ELF): Classical Forth has one section=dictionary: A stretch of
>>memory from the start to HERE, with the address space behind available
>>for future allocation. Each section works like the dictionary: It has
>>a stretch of allocated memory, and behind that there is memory
>>available for future allocation.
>>
>>Gforth offers the following interface for sections: There is a current
>>section (by default the ordinary dictionary), and HERE and UNUSED
>>produce the results for the current section, and ALLOT etc. work on
>>that section. You can temporarily change the section.
>>
>>We have a stack of sections starting with the ordinary dictionary. We
>>also have named sections (not section stacks, unstackable named
>>sections are good enough for now). E.g., when I type .SECTIONS after
>>starting gforth, I get:
>>
>> start size +dp name
>> 7F7FFB5D8000 4000 518 locals-headers
>>> 7F7FF9B81040 800000 898F8 Forth
>> 7F7FF9980000 200000 4DE8 noname
>> 7F7FF98FF000 80000 5B8 noname
>> 7F7FFB401000 20000 100 noname
>>
>>The "size" column indicates the maximum size of that section, "+dp"
>>the ALLOTed memory in that section. "Forth" is the traditional
>>dictionary, and the ">" indicates that it is the current section; the
>>noname sections below are the stack of sections associated with the
>>dictionary. "locals-headers" is a section that contains the names of
>>currently visible locals.
>>
>>Some major uses of sections are for storing quotations and string
>>literals that are compiled into a colon definition: We switch to the
>>next section in the stack, put the quotation or string there, then
>>switch back, and compile some literal pointing to the quotation or
>>string in the other section. This avoids the need to branch around
>>the quotation or string compiled into the same section.
>>
>>I would have liked to quantify the benefit that this use of sections
>>gives us by using the old branch-around scheme and comparing the
>>results, but a quick attempt resulted in a crash, so apparently there
>>is code in gforth that relies on sections being separate.
>
>I have now taken a different approach: Instead of measuring the
>difference by having both versions and comparing the sizes, I now
>count how many branches-around would have been generated, and
>computing the size difference from that.
>
>I count 550 calls to NEXT-SECTION (each of which replaces one branch
>around). On the threaded-code level this replaces 8800 bytes on a
>64-bit system.
>
>On the native-code level, things are more complicated: Each
>threaded-code branch is expanded into 16 bytes (in AMD64 gforth-fast).
>But because we don't have sections on the native-code level, we still
>make sure that a NEXT (5 bytes) is generated before a quotation. I
>did not count the quotations, and anyway, there may have been a NEXT
>generated before for other reasons. The bottom line is that between
>(16-5)*550=6050 bytes and 16*550=8800 bytes of additional native code
>would be generated if we did not use sections.

I found another way to measure this: Insert a threaded-code branch
where the before-section code would have done so, but still switch the
section. As a result, I see a difference of 8800 bytes in threaded
code (as predicted) and 9456 bytes in native code. The native-code
result is more than the upper bound above. I tested some explanations
for that, but came up empty-handed.

I did the same measurement on ARM64. The Forth code is only partially
the same, because on AMD64 we have an AMD64 assembler and
disassembler, and likewise on ARM64. I see a difference of 8448 bytes
of threaded code and 9120 bytes of native code.

- 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: Sections benefits quantified

<2021Aug6.185434@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Sections benefits quantified
Date: Fri, 06 Aug 2021 16:54:34 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 12
Message-ID: <2021Aug6.185434@mips.complang.tuwien.ac.at>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at> <seje1f$367$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="347297b1f490ce60f1c8ef192e40269a";
logging-data="7307"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+33FKeRhtiGV4RD6Vn2Fze"
Cancel-Lock: sha1:wG6yp+RqwWGPMgQyTXUn9kPpTHw=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 6 Aug 2021 16:54 UTC

dxforth <dxforth@gmail.com> writes:
>There must be complications that arise from having sections e.g.
>dictionary trimming. How do you handle those?

What is dictionary trimming?

- 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: Sections benefits quantified

<57481cb4-4b18-4505-85da-d80022179500n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:2291:: with SMTP id o17mr12233963qkh.387.1628280448993;
Fri, 06 Aug 2021 13:07:28 -0700 (PDT)
X-Received: by 2002:a05:622a:1753:: with SMTP id l19mr9956327qtk.176.1628280448614;
Fri, 06 Aug 2021 13:07:28 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 6 Aug 2021 13:07:28 -0700 (PDT)
In-Reply-To: <2021Aug6.095019@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f2c:8b05:f009:b61a:c871:cd90;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f2c:8b05:f009:b61a:c871:cd90
References: <2021Aug6.095019@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <57481cb4-4b18-4505-85da-d80022179500n@googlegroups.com>
Subject: Re: Sections benefits quantified
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Fri, 06 Aug 2021 20:07:28 +0000
Content-Type: text/plain; charset="UTF-8"
 by: minf...@arcor.de - Fri, 6 Aug 2021 20:07 UTC

Anton Ertl schrieb am Freitag, 6. August 2021 um 10:56:05 UTC+2:
> We have added multiple sections [ertl-sections16] to Gforth. Sections
> are the same concept as in assembly language and binary formats
> (e.g. ELF): Classical Forth has one section=dictionary: A stretch of
> memory from the start to HERE, with the address space behind available
> for future allocation. Each section works like the dictionary: It has
> a stretch of allocated memory, and behind that there is memory
> available for future allocation. <snip>

This is gforth-specific and therefore no critique here.

For my part I use one (sometimes several) heap(s) for data objects such
as measured sensor data (time series). So they don't clutter the
dictionary, and access is controlled by a small set of heap management
words.

Headers for locals are temporarily compiled into the dictionary and
discarded/overwritten later so that they don't eat up space. I have not
yet found good reasons to compartmentalize the dictionary, except
keeping headers and code in different sections.

Re: Sections benefits quantified

<sekpto$1ln4$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Sections benefits quantified
Date: Sat, 7 Aug 2021 12:07:52 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sekpto$1ln4$1@gioia.aioe.org>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at>
<seje1f$367$1@gioia.aioe.org> <2021Aug6.185434@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="55012"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Sat, 7 Aug 2021 02:07 UTC

On 7/08/2021 02:54, Anton Ertl wrote:
> dxforth <dxforth@gmail.com> writes:
>>There must be complications that arise from having sections e.g.
>>dictionary trimming. How do you handle those?
>
> What is dictionary trimming?

FORGET MARKER EMPTY

It's a complication of Forth other languages have largely avoided.
If there's one thing in forth that's become a monster and dubious
benefit it's this. Inherently messy and complicated, sections only
make it worse. While I didn't have a choice, others do.

Regarding Forth 'in-lining' the classic example is CREATE DOES>.
Attempting to 'section off' the run-time colon definition can
actually cost more in space - as I discovered when implementing
my assembler.

Which brings me to quotations. When I looked at the possibility of
separating the quotation from the parent, I found it problematic to
the point of not pursuing.

Sections bring with them a good deal of complication. IMO one has
to have a substantial reason for using them that counter-balances
the negatives. That 'other languages have them' doesn't cut it.
Other languages don't have users screwing around with dictionaries.

Re: Sections benefits quantified

<2021Aug7.083816@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Sections benefits quantified
Date: Sat, 07 Aug 2021 06:38:16 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 75
Message-ID: <2021Aug7.083816@mips.complang.tuwien.ac.at>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at> <seje1f$367$1@gioia.aioe.org> <2021Aug6.185434@mips.complang.tuwien.ac.at> <sekpto$1ln4$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="f55d7bb75a641436fb9a006be1d83186";
logging-data="19914"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19nEMueyYvPCjuJ3IkXeYRB"
Cancel-Lock: sha1:6774lqkWh9I/7r4BKgXs9cxwyPU=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sat, 7 Aug 2021 06:38 UTC

dxforth <dxforth@gmail.com> writes:
>On 7/08/2021 02:54, Anton Ertl wrote:
>> dxforth <dxforth@gmail.com> writes:
>>>There must be complications that arise from having sections e.g.
>>>dictionary trimming. How do you handle those?
>>
>> What is dictionary trimming?
>
>FORGET MARKER EMPTY

MARKER needs to store the HERE of all sections, and when the marker is
called, the HEREs have to be restored. Any sections that did not
exist at MARKER time have to be eliminated.

Gforth does not have FORGET, nor EMPTY.

>It's a complication of Forth other languages have largely avoided.

FORGET is TOOLS EXT and therefore optional in the standard. It is
still marked as obsolescent, although I doubt that there will be
consensus for destandardizing it.

MARKER is CORE EXT (why not TOOLS EXT?) and therefore optional in the
standard.

EMPTY is non-standard.

So if you shy away from the complications of implementing these words,
the standard is certainly no obstacle to that (and given your
rethorics wrt standardization, the standard should be no obstacle
anyway).

My personal take is that BYE and restart is the appropriate way to
clean up the dictionary. It was different on the C64 when reloading
the Forth system and the application would cost a minute or several.

>If there's one thing in forth that's become a monster and dubious
>benefit it's this. Inherently messy and complicated, sections only
>make it worse.

Sure, although not much worse.

>Regarding Forth 'in-lining' the classic example is CREATE DOES>.

CREATE DOES> does not do any inlining, certainly not in classic Forth
implementations (where such words are represented by a CFA and
compilation just ","s this CFA), and not in Gforth (where such words
are represented by their CFA and compilation compiles a primitive
DOES-XT followed by the CFA.

>Attempting to 'section off' the run-time colon definition can
>actually cost more in space - as I discovered when implementing
>my assembler.

What do you mean by 'section off'?

>Sections bring with them a good deal of complication.

In addition to what I described earlier, the image saver (SAVESYSTEM),
the relocation data generator, and the image loader became
section-aware and more complicated. One could avoid these
complications by avoiding relocation and saving everything as one big
image (unused space included), and then loading it to the same
address.

>That 'other languages have them' doesn't cut it.

It's also a straw man.

- 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: Sections benefits quantified

<2021Aug7.092646@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Sections benefits quantified
Date: Sat, 07 Aug 2021 07:26:46 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 17
Message-ID: <2021Aug7.092646@mips.complang.tuwien.ac.at>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at> <57481cb4-4b18-4505-85da-d80022179500n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="f55d7bb75a641436fb9a006be1d83186";
logging-data="19914"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187u5Qf23DBsUi5g34aKm1H"
Cancel-Lock: sha1:U6CbYxTY7eaMsrALY8CETK3wM+A=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sat, 7 Aug 2021 07:26 UTC

"minf...@arcor.de" <minforth@arcor.de> writes:
>Headers for locals are temporarily compiled into the dictionary and
>discarded/overwritten later so that they don't eat up space. I have not
>yet found good reasons to compartmentalize the dictionary, except
>keeping headers and code in different sections.

Ok, so you can keep the locals headers in the normal dictionary
section because you compile the code in a different section. In
either case, the locals headers are stored in a different section than
the code.

- 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: Sections benefits quantified

<62a8c32f-fe2d-4f91-8284-afa2a8279fc2n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:621:: with SMTP id a1mr2011891qvx.12.1628363338544;
Sat, 07 Aug 2021 12:08:58 -0700 (PDT)
X-Received: by 2002:a37:6546:: with SMTP id z67mr15658018qkb.173.1628363338400;
Sat, 07 Aug 2021 12:08:58 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sat, 7 Aug 2021 12:08:58 -0700 (PDT)
In-Reply-To: <2021Aug7.092646@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f2c:8b41:4993:1d55:7683:2bad;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f2c:8b41:4993:1d55:7683:2bad
References: <2021Aug6.095019@mips.complang.tuwien.ac.at> <57481cb4-4b18-4505-85da-d80022179500n@googlegroups.com>
<2021Aug7.092646@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <62a8c32f-fe2d-4f91-8284-afa2a8279fc2n@googlegroups.com>
Subject: Re: Sections benefits quantified
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Sat, 07 Aug 2021 19:08:58 +0000
Content-Type: text/plain; charset="UTF-8"
 by: minf...@arcor.de - Sat, 7 Aug 2021 19:08 UTC

Anton Ertl schrieb am Samstag, 7. August 2021 um 09:35:01 UTC+2:
> "minf...@arcor.de" <minf...@arcor.de> writes:
> >Headers for locals are temporarily compiled into the dictionary and
> >discarded/overwritten later so that they don't eat up space. I have not
> >yet found good reasons to compartmentalize the dictionary, except
> >keeping headers and code in different sections.
> Ok, so you can keep the locals headers in the normal dictionary
> section because you compile the code in a different section. In
> either case, the locals headers are stored in a different section than
> the code.

No, code is compiled into dictionary space, but relocatible and moved upwards
when temporary local names are no longer needed "to close the gap".

Re: Sections benefits quantified

<87h7g16j0r.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Sections benefits quantified
Date: Sat, 07 Aug 2021 14:29:24 -0700
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <87h7g16j0r.fsf@nightsong.com>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="8e61b558664f1dac1f4b93100b09b1c2";
logging-data="19174"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+sWkIfUszmPKPKWHR3Ha5v"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:KIrq+cnD6HqdVhDw0Jq1GPLrAQY=
sha1:p2INhJUJcl7HdcUyOavno2IYUfA=
 by: Paul Rubin - Sat, 7 Aug 2021 21:29 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> Each section works like the dictionary: It has a stretch of allocated
> memory, and behind that there is memory available for future
> allocation.

Is this also a good way to implement the dictionaries and stacks in a
multitasking system?

Re: Sections benefits quantified

<seniiv$duf$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Sections benefits quantified
Date: Sun, 8 Aug 2021 13:21:03 +1000
Organization: Aioe.org NNTP Server
Message-ID: <seniiv$duf$1@gioia.aioe.org>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at>
<87h7g16j0r.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="14287"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Sun, 8 Aug 2021 03:21 UTC

On 8/08/2021 07:29, Paul Rubin wrote:
> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> Each section works like the dictionary: It has a stretch of allocated
>> memory, and behind that there is memory available for future
>> allocation.
>
> Is this also a good way to implement the dictionaries and stacks in a
> multitasking system?
>

Multi-user? There have been traditional ways of implementing that in
Forth. As for 'good' alternate ways, how to know unless one tried it?
More importantly would you be satisfied with an answer from someone
who hadn't? Most who ask questions aren't vitally interested, else
they'd find out for themselves instead of pursuing opinion. AFAIK
Chuck didn't consult authorities before embarking upon Forth.

Re: Sections benefits quantified

<87czqo7b58.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Sections benefits quantified
Date: Sat, 07 Aug 2021 22:34:11 -0700
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <87czqo7b58.fsf@nightsong.com>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at>
<87h7g16j0r.fsf@nightsong.com> <seniiv$duf$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="67caebb1ed3243e0ce123a12004985bc";
logging-data="13173"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1925a4KaviGN2kbSj8upyJS"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:uqOS0BXMeWuykeVdcmfloRJyETo=
sha1:qMcROCabfzFOo1LJ9KVm5oEM5zs=
 by: Paul Rubin - Sun, 8 Aug 2021 05:34 UTC

dxforth <dxforth@gmail.com> writes:
>> Is this also a good way to implement the dictionaries and stacks in a
>> multitasking system?
>>
> Multi-user? There have been traditional ways of implementing that in
> Forth. As for 'good' alternate ways, how to know unless one tried it?

I hadn't been thinking of multi-user, but maybe in a traditional single
user multitasking system, the tasks share a single dictionary, and only
the stacks and user variable areas would be in segments.

> More importantly would you be satisfied with an answer from someone
> who hadn't?

Anton implemented the segment scheme and has tons of Forth knowledge, so
of course I'd be satisfied with his answer.

> Most who ask questions aren't vitally interested,

I don't claim to be vitally interested and don't feel that I have such a
duty. It still seemed worth asking. The world is not binary and
neither are interest levels.

Re: Sections benefits quantified

<2021Aug8.082727@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Sections benefits quantified
Date: Sun, 08 Aug 2021 06:27:27 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 44
Message-ID: <2021Aug8.082727@mips.complang.tuwien.ac.at>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at> <87h7g16j0r.fsf@nightsong.com>
Injection-Info: reader02.eternal-september.org; posting-host="bac5d33f036bd1af4573fc3980699230";
logging-data="10856"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+BYg32sX03rBUhu05hd9aE"
Cancel-Lock: sha1:RGkNm7RwxHnKVv1ndo+MpxrzcnM=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 8 Aug 2021 06:27 UTC

Paul Rubin <no.email@nospam.invalid> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> Each section works like the dictionary: It has a stretch of allocated
>> memory, and behind that there is memory available for future
>> allocation.
>
>Is this also a good way to implement the dictionaries and stacks in a
>multitasking system?

Concerning the stacks, they are not in the sections. Every task has
its own set of stacks, and its own user area.

Concerning the dictionary, AFAIK Chuck Moore's (and later Forth,
Inc.'s) multitasking multi-user Forth systems had a dictionary for
each user. So he thought that was a good idea, and that feature was
continued in polyForth, so it appears to have been a success.

A difference from Gforth's sections is that the idea was to present an
unsectioned dictionary to each user, so it did not have the API for
dealing with sections nor did it make use of sections for its own
internal purposes. It would have been a bad idea on the machines of
the time: No paging MMU to allow sections to use only as much physical
RAM as is actually used (plus padding to the next page boundary), so
you would have to size the sections precisely to avoid wasting RAM,
which would diminish their utility greatly. Plus, sections cost RAM
for the management software, and with so little RAM overall, it's
questionable if that cost can be amortized.

By contrast, Gforth's multi-tasking is not multi-user, and a task
normally cannot do dictionary allocation. In particular, the compiler
is not designed for letting multiple tasks compile. The sections are
there for the main task (that can compile), although it's possible to
create a section, and let the CURRENT-SECTION of a task point to it,
and do dictionary allocation (ALLOT and ,) there (but no other task
should allocate to that section then).

Not sure if that answers your question.

- 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: Sections benefits quantified

<2021Aug8.090108@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Sections benefits quantified
Date: Sun, 08 Aug 2021 07:01:08 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 36
Message-ID: <2021Aug8.090108@mips.complang.tuwien.ac.at>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at> <87h7g16j0r.fsf@nightsong.com> <seniiv$duf$1@gioia.aioe.org> <87czqo7b58.fsf@nightsong.com>
Injection-Info: reader02.eternal-september.org; posting-host="bac5d33f036bd1af4573fc3980699230";
logging-data="10856"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LP/Q7WCM+L+g0WXlOz/Ii"
Cancel-Lock: sha1:5l0T8yE5hylH2Sc9VdDJBqVKa0s=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 8 Aug 2021 07:01 UTC

Paul Rubin <no.email@nospam.invalid> writes:
>dxforth <dxforth@gmail.com> writes:
>>> Is this also a good way to implement the dictionaries and stacks in a
>>> multitasking system?
>>>
>> Multi-user? There have been traditional ways of implementing that in
>> Forth. As for 'good' alternate ways, how to know unless one tried it?
>
>I hadn't been thinking of multi-user, but maybe in a traditional single
>user multitasking system, the tasks share a single dictionary, and only
>the stacks and user variable areas would be in segments.

In multi-tasking Forths of course each task has its own stacks and
user area. Early Forths also had multi-user capabilities, with each
user having a dictionary:

From
<https://www.forth.com/resources/forth-programming-language/#21_Forth_at_NRAO>:
|Multiuser operation of the sort that enabled NRAO’s astronomers to
|graphically analyze data while an operator controlled the telescope
|and live data was flowing in, was unheard-of.

Given that Gforth runs hosted on a multi-user OS, and Gforth EC runs
on 0-1 terminal-user embedded controllers, this feature is not
necessary in Gforth.

And I think the same is true in most other Forth systems today. AFAIK
Greg Bailey was still providing native (i.e., no OS below Forth) Forth
systems a while ago, not sure if he or his successors still do.

- 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: Sections benefits quantified

<878s1c73i9.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Sections benefits quantified
Date: Sun, 08 Aug 2021 01:19:10 -0700
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <878s1c73i9.fsf@nightsong.com>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at>
<87h7g16j0r.fsf@nightsong.com>
<2021Aug8.082727@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="67caebb1ed3243e0ce123a12004985bc";
logging-data="332"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+lN1oweqRgafAYZyLyIGPZ"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:BY7j+RP8vMJW8PDgO1sNBHmDoaY=
sha1:exJc7W9plWx8nJnjC28b9Ml+9Uc=
 by: Paul Rubin - Sun, 8 Aug 2021 08:19 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> Concerning the stacks, they are not in the sections. Every task has
> its own set of stacks, and its own user area.

Is there a particular reason to not use sections to allocate the stacks
and user areas? Or does it just not help significantly?

Is it usual in multitasking Forths to create and destroy tasks
dynamically (like a network server might do, as connections come and
go), or is there more commonly a fixed set of tasks through the
program's entire execution?

> The sections are there for the main task (that can compile)

Ah ok, if only the main task can compile, that is reasonable and
simplifies things. I guess there is some way to have separate names for
the user variables in the different tasks: I'll look at eforth to see
how it does that.

> Not sure if that answers your question.

Yes I think so. Actually in a system as big as gforth, maybe it is
reasonable to use garbage collection in the compiler, at least in a
hypothetical fancy analytical compiler of the future that could benefit
from it.

Re: Sections benefits quantified

<162842921515.32737.2796709101256980385@media.vsta.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: van...@vsta.org (Andy Valencia)
Newsgroups: comp.lang.forth
Subject: Re: Sections benefits quantified
Date: Sun, 08 Aug 2021 06:26:55 -0700
Lines: 19
Message-ID: <162842921515.32737.2796709101256980385@media.vsta.org>
References: <87czqo7b58.fsf@nightsong.com> <2021Aug6.095019@mips.complang.tuwien.ac.at> <87h7g16j0r.fsf@nightsong.com> <seniiv$duf$1@gioia.aioe.org>
X-Trace: individual.net coO8mXVAptxzDsqh8Fx1RwmSX9b12eLh5JVj2x3XwOSG3ddOyV
X-Orig-Path: media
Cancel-Lock: sha1:HPCHt9t2ENMcG3q63VK0ZS9Ny3w=
User-Agent: rn.py v0.0.1
 by: Andy Valencia - Sun, 8 Aug 2021 13:26 UTC

Paul Rubin <no.email@nospam.invalid> writes:
> dxforth <dxforth@gmail.com> writes:
> >> Is this also a good way to implement the dictionaries and stacks in a
> >> multitasking system?
> > Multi-user? There have been traditional ways of implementing that in
> > Forth. As for 'good' alternate ways, how to know unless one tried it?
> I hadn't been thinking of multi-user, but maybe in a traditional single
> user multitasking system, the tasks share a single dictionary, and only
> the stacks and user variable areas would be in segments.

You have to thinka about the heap. In ForthOS, each task has its own heap,
and every other comparable Forth system I've studied did this also. A
consequence of this is that only the primary task can do compilations;
making all the edge cases work nicely to compile on other tasks was--for
me--not worth the effort.

Andy Valencia
Home page: https://www.vsta.org/andy/
To contact me: https://www.vsta.org/contact/andy.html

Re: Sections benefits quantified

<2021Aug8.154141@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Sections benefits quantified
Date: Sun, 08 Aug 2021 13:41:41 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 52
Message-ID: <2021Aug8.154141@mips.complang.tuwien.ac.at>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at> <87h7g16j0r.fsf@nightsong.com> <2021Aug8.082727@mips.complang.tuwien.ac.at> <878s1c73i9.fsf@nightsong.com>
Injection-Info: reader02.eternal-september.org; posting-host="bac5d33f036bd1af4573fc3980699230";
logging-data="16840"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xC3Npzzpz5/8E5WXwHt0S"
Cancel-Lock: sha1:j/6kbEgRcJcaRPnVq0AT44JJTTA=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 8 Aug 2021 13:41 UTC

Paul Rubin <no.email@nospam.invalid> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> Concerning the stacks, they are not in the sections. Every task has
>> its own set of stacks, and its own user area.
>
>Is there a particular reason to not use sections to allocate the stacks
>and user areas? Or does it just not help significantly?

It does not help. Sections are for when you need to allocate
piecewise. Each stack and the user area are each allocated in one
chunk.

>Is it usual in multitasking Forths to create and destroy tasks
>dynamically (like a network server might do, as connections come and
>go), or is there more commonly a fixed set of tasks through the
>program's entire execution?

Gforth's multi-tasking certainly allows the former. My guess is that
on small systems you would have a fixed set of tasks in order to avoid
out-of-memory conditions.

>> The sections are there for the main task (that can compile)
>
>Ah ok, if only the main task can compile, that is reasonable and
>simplifies things. I guess there is some way to have separate names for
>the user variables in the different tasks: I'll look at eforth to see
>how it does that.

Every user variable has an instance in every task, so you tend to be
stingy with them. If you want thread-local data that is not
replicated across all threads, you have to do it differently. E.g.,
Gforth has user objects that take only one user-variable cell (the
address of the object), and you can dynamically allocate the object
(or not allocate it).

>> Not sure if that answers your question.
>
>Yes I think so. Actually in a system as big as gforth, maybe it is
>reasonable to use garbage collection in the compiler, at least in a
>hypothetical fancy analytical compiler of the future that could benefit
>from it.

I have plans for an analytical compiler, but no plans for using
garbage collection for it. Region-based memory allocation looks like
a good fit for a compiler.

- 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: Sections benefits quantified

<sepg2l$kt6$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: do-not-...@swldwa.uk (Gerry Jackson)
Newsgroups: comp.lang.forth
Subject: Re: Sections benefits quantified
Date: Sun, 8 Aug 2021 21:50:28 +0100
Organization: A noiseless patient Spider
Lines: 88
Message-ID: <sepg2l$kt6$1@dont-email.me>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 8 Aug 2021 20:50:29 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a314081f4200c979776576c690b5c1b8";
logging-data="21414"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ahlpOedZhShVNV1sM8F8JYVKPFWqUEiE="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Cancel-Lock: sha1:8qn8ZE5ywtsZqbaKN2r6e+NjbXE=
In-Reply-To: <2021Aug6.095019@mips.complang.tuwien.ac.at>
Content-Language: en-GB
 by: Gerry Jackson - Sun, 8 Aug 2021 20:50 UTC

On 06/08/2021 08:50, Anton Ertl wrote:
> We have added multiple sections [ertl-sections16] to Gforth. Sections
> are the same concept as in assembly language and binary formats
> (e.g. ELF): Classical Forth has one section=dictionary: A stretch of
> memory from the start to HERE, with the address space behind available
> for future allocation. Each section works like the dictionary: It has
> a stretch of allocated memory, and behind that there is memory
> available for future allocation.
>
> Gforth offers the following interface for sections: There is a current
> section (by default the ordinary dictionary), and HERE and UNUSED
> produce the results for the current section, and ALLOT etc. work on
> that section. You can temporarily change the section.
>
> We have a stack of sections starting with the ordinary dictionary. We
> also have named sections (not section stacks, unstackable named
> sections are good enough for now). E.g., when I type .SECTIONS after
> starting gforth, I get:
>
> start size +dp name
> 7F7FFB5D8000 4000 518 locals-headers
>> 7F7FF9B81040 800000 898F8 Forth
> 7F7FF9980000 200000 4DE8 noname
> 7F7FF98FF000 80000 5B8 noname
> 7F7FFB401000 20000 100 noname
>
> The "size" column indicates the maximum size of that section, "+dp"
> the ALLOTed memory in that section. "Forth" is the traditional
> dictionary, and the ">" indicates that it is the current section; the
> noname sections below are the stack of sections associated with the
> dictionary. "locals-headers" is a section that contains the names of
> currently visible locals.
>
> Some major uses of sections are for storing quotations and string
> literals that are compiled into a colon definition: We switch to the
> next section in the stack, put the quotation or string there, then
> switch back, and compile some literal pointing to the quotation or
> string in the other section. This avoids the need to branch around
> the quotation or string compiled into the same section.
>
> I would have liked to quantify the benefit that this use of sections
> gives us by using the old branch-around scheme and comparing the
> results, but a quick attempt resulted in a crash, so apparently there
> is code in gforth that relies on sections being separate. However,
> what I have seen is that just by loading a few Gforth files after the
> sections code rather than before, the native code size in gforth-fast
> shrank by 224 bytes.
>
> Another (recent) use of sections is for storing the locals headers.
> Originally Gforth had a 1000-Byte buffer for that, which served like a
> section before we introduced sections. But that buffer was stored in
> its whole length in the image, unlike sections, of which only the
> alloted part is stored, so we did not want to make it really large.
> In 2011 (I guess when we introduced quotations), we felt that
> something less limited was needed, and we ALLOCATEd the names of the
> locals (stored in a linked list for deallocation). Since then, we
> have added sections, so yesterday I changed allocation of locals names
> to use a section LOCALS-HEADERS instead of using ALLOCATE.
>
> This allowed me to rip out the code for ALLOCATEing and FREEing the
> locals names, and for allowing to CREATE names in that allocated
> memory. The result is that the source code shrank by 40 lines:
>
> git log --shortstat b3118b84...f634044881a
> ...
> 2 files changed, 25 insertions(+), 65 deletions(-)
>
> The threaded code (on a 64-bit system) shrank by 2608 bytes, and the
> native code on AMD64 gforth-fast shrank by 1744 bytes.
>

That's interesting. My system has had sections since I developed it in
approx 2005. Sections are named and mostly provide several dataspaces.
My motivation was to be able to use dataspace handling words such as
HERE , C, ALLOT ALIGN UNUSED in different areas of memory. For example
it is nice to be able to ALLOT or ALLOCATE a buffer as a section and use
C, to save characters in it. Sometimes a word may be defined to do a
similar but different action e.g define , to compile a string (ca u).
There is a current-section pointer - I've not considered a section stack
but would guess that having one would simplify a few things. The system
uses a few sections, these include headers, headers for locals and other
objects, code, string literals. I haven't used multiple sections for
code but in principle that is possible (I think!) but I didn't think of
doing so at the time - I'm not sure what benefit that would give me e.g.
quotations don't cost any extra space at present.

--
Gerry

Re: Sections benefits quantified

<2021Aug9.110036@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Sections benefits quantified
Date: Mon, 09 Aug 2021 09:00:36 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 51
Message-ID: <2021Aug9.110036@mips.complang.tuwien.ac.at>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at> <sepg2l$kt6$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="c0ded8ad0629ded41ae604c5bcdc7054";
logging-data="1485"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19T03xt8qPM9CXvju8jR5pJ"
Cancel-Lock: sha1:h/yN6q0rNgYIVR8AuTzUpgUOyes=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Mon, 9 Aug 2021 09:00 UTC

Gerry Jackson <do-not-use@swldwa.uk> writes:
>On 06/08/2021 08:50, Anton Ertl wrote:
>I haven't used multiple sections for
>code but in principle that is possible (I think!) but I didn't think of
>doing so at the time - I'm not sure what benefit that would give me e.g.
>quotations don't cost any extra space at present.

How does the code compiled for, e.g.,

: foo dup [: swap - ;] swap ! ;

look in your system. Before sections, Gforth compiles this code

\ header of foo
$7F4EDFCE84B8 dup
$7F4EDFCE84C0 branch
$7F4EDFCE84C8 <foo+$40>
$7F4EDFCE84D0 <(UValue)+$A8> \ header of a nameless word
$7F4EDFCE84D8 $4048C8 \ header of a nameless word
$7F4EDFCE84E0 swap
$7F4EDFCE84E8 -
$7F4EDFCE84F0 ;s
$7F4EDFCE84F8 lit
$7F4EDFCE8500 <foo+$20>
$7F4EDFCE8508 swap
$7F4EDFCE8510 !
$7F4EDFCE8518 ;s ok

With sections, it compiles this code:

For foo:
\ header of foo
$7FE8DC25ECD8 dup
$7FE8DC25ECE0 lit
$7FE8DC25ECE8 $7FE8DBFD8CB0
$7FE8DC25ECF0 swap
$7FE8DC25ECF8 !
$7FE8DC25ED00 ;s ok

For the quotation:
\ header of a nameless word
$7FE8DBFD8CB8 swap
$7FE8DBFD8CC0 -
$7FE8DBFD8CC8 ;s ok

- 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: Sections benefits quantified

<ser831$4kq$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: do-not-...@swldwa.uk (Gerry Jackson)
Newsgroups: comp.lang.forth
Subject: Re: Sections benefits quantified
Date: Mon, 9 Aug 2021 13:46:27 +0100
Organization: A noiseless patient Spider
Lines: 84
Message-ID: <ser831$4kq$1@dont-email.me>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at>
<sepg2l$kt6$1@dont-email.me> <2021Aug9.110036@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 9 Aug 2021 12:46:25 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="218cb35282a6c95ee06abcabd790b0f2";
logging-data="4762"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX198TaEwCYf298sfao1s98ztHi3J6qOFo3s="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Cancel-Lock: sha1:7/dw8xi3DBZ2eVv9qPVMpziclG0=
In-Reply-To: <2021Aug9.110036@mips.complang.tuwien.ac.at>
Content-Language: en-GB
 by: Gerry Jackson - Mon, 9 Aug 2021 12:46 UTC

On 09/08/2021 10:00, Anton Ertl wrote:
> Gerry Jackson <do-not-use@swldwa.uk> writes:
>> On 06/08/2021 08:50, Anton Ertl wrote:
>> I haven't used multiple sections for
>> code but in principle that is possible (I think!) but I didn't think of
>> doing so at the time - I'm not sure what benefit that would give me e.g.
>> quotations don't cost any extra space at present.
>
> How does the code compiled for, e.g.,
>
> : foo dup [: swap - ;] swap ! ;
>
> look in your system. Before sections, Gforth compiles this code
>
> \ header of foo
> $7F4EDFCE84B8 dup
> $7F4EDFCE84C0 branch
> $7F4EDFCE84C8 <foo+$40>
> $7F4EDFCE84D0 <(UValue)+$A8> \ header of a nameless word
> $7F4EDFCE84D8 $4048C8 \ header of a nameless word
> $7F4EDFCE84E0 swap
> $7F4EDFCE84E8 -
> $7F4EDFCE84F0 ;s
> $7F4EDFCE84F8 lit
> $7F4EDFCE8500 <foo+$20>
> $7F4EDFCE8508 swap
> $7F4EDFCE8510 !
> $7F4EDFCE8518 ;s ok
>
> With sections, it compiles this code:
>
> For foo:
> \ header of foo
> $7FE8DC25ECD8 dup
> $7FE8DC25ECE0 lit
> $7FE8DC25ECE8 $7FE8DBFD8CB0
> $7FE8DC25ECF0 swap
> $7FE8DC25ECF8 !
> $7FE8DC25ED00 ;s ok
>
> For the quotation:
> \ header of a nameless word
> $7FE8DBFD8CB8 swap
> $7FE8DBFD8CC0 -
> $7FE8DBFD8CC8 ;s ok
>

\ Header Section
$11DD124 \ Header for FOO with xt = $11DAAE4

\ Code Section
$11DAAD4 Start of quotation (colon def semantics pointer)
$11DAAD8 swap
$11DAADC -
$11DAAE0 ;s
$11DAAE4 Start of FOO (colon def semantics pointer)
$11DAAE8 dup
$11DAAEC (lit)
$11DAAF0 $11DAAD4 xt of quotation
$11DAAF4 swap
$11DAAF8 !
$11DAAFC ;s

\ Strings section
$11D8A8B "3foo" Counted string

The quotation code precedes that for FOO because my system initially
compiles to an intermediate code in a buffer until ; is reached when it
lays down the final code. When the quotation is encountered compilation
of FOO is suspended, the quotation compiled until complete, then
compilation of FOO is resumed. So there is no need for a branch over the
quotation. If quotations are nested the innermost is completed first.
This also permits colon definitions, variables etc to be nested inside
colon definitions.

THe Semantics pointer points to a structure with pointers to code to
interpret, compile the word etc. The same semantics structure is used
for all colon definitions with default semantics including quotations
and :NONAMEs

Why does Gforth need a header for a nameless word?

--
Gerry

Re: Sections benefits quantified

<d9df5328-5705-422d-b04b-8c9cf3de8137n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:9d3:: with SMTP id 202mr16594379qkj.369.1628524175733;
Mon, 09 Aug 2021 08:49:35 -0700 (PDT)
X-Received: by 2002:a05:6214:5182:: with SMTP id kl2mr13246535qvb.19.1628524175602;
Mon, 09 Aug 2021 08:49:35 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 9 Aug 2021 08:49:35 -0700 (PDT)
In-Reply-To: <ser831$4kq$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <2021Aug6.095019@mips.complang.tuwien.ac.at> <sepg2l$kt6$1@dont-email.me>
<2021Aug9.110036@mips.complang.tuwien.ac.at> <ser831$4kq$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d9df5328-5705-422d-b04b-8c9cf3de8137n@googlegroups.com>
Subject: Re: Sections benefits quantified
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Mon, 09 Aug 2021 15:49:35 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Hans Bezemer - Mon, 9 Aug 2021 15:49 UTC

On Monday, August 9, 2021 at 2:46:27 PM UTC+2, Gerry Jackson wrote:
> Why does Gforth need a header for a nameless word?

I wouldn't know. Just branch over the shebang.

Addr| Opcode Operand

0| branch 10
1| dup 0
2| literal 4
3| branch 7
4| swap 0
5| - 0
6| exit 0
7| swap 0
8| ! 0
9| exit 0

You guys do have AHEAD, don't you?

Hans Bezemer

Re: Sections benefits quantified

<servmi$s3v$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: do-not-...@swldwa.uk (Gerry Jackson)
Newsgroups: comp.lang.forth
Subject: Re: Sections benefits quantified
Date: Mon, 9 Aug 2021 20:29:22 +0100
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <servmi$s3v$1@dont-email.me>
References: <2021Aug6.095019@mips.complang.tuwien.ac.at>
<sepg2l$kt6$1@dont-email.me> <2021Aug9.110036@mips.complang.tuwien.ac.at>
<ser831$4kq$1@dont-email.me>
<d9df5328-5705-422d-b04b-8c9cf3de8137n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 9 Aug 2021 19:29:22 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="7721fe288f0c9c0a490bfa9ecca1084f";
logging-data="28799"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xvL6+YFFPzoYGFUMkT2SxqgEc7ARi/nU="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Cancel-Lock: sha1:GDufOF/4p5WAdndeEdqxEWuF1YU=
In-Reply-To: <d9df5328-5705-422d-b04b-8c9cf3de8137n@googlegroups.com>
Content-Language: en-GB
 by: Gerry Jackson - Mon, 9 Aug 2021 19:29 UTC

On 09/08/2021 16:49, Hans Bezemer wrote:
> On Monday, August 9, 2021 at 2:46:27 PM UTC+2, Gerry Jackson wrote:
>> Why does Gforth need a header for a nameless word?
>
> I wouldn't know. Just branch over the shebang.

How does that answer the question?

>
> Addr| Opcode Operand
>
> 0| branch 10
> 1| dup 0
> 2| literal 4
> 3| branch 7
> 4| swap 0
> 5| - 0
> 6| exit 0
> 7| swap 0
> 8| ! 0
> 9| exit 0
>
> You guys do have AHEAD, don't you?

How do you think Gforth generated the code before Anton introduced the
use of sections?

Why would I use AHEAD when my system's design meant I didn't need to?

--
Gerry

Pages:123
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor