Discussion:
Segmented stack
(too old to reply)
Shucai via Digitalmars-d
2014-10-16 19:46:41 UTC
Permalink
I am doing research on segmented stack mechanisms, and in
addition to academic papers, I am surveying whether segmented
stack mechanism is still useful on 64-bit machines. On 64 bit
machines, why they don’t just use a big enough stack, for
example, 1GB or even larger? Are segmented stacks only useful
for 32 bit machines? Are there other reasons for segmented
stacks on 64 bit machines?

Any response is appreciated, thanks, Shucai
Brad Anderson via Digitalmars-d
2014-10-16 22:20:32 UTC
Permalink
Post by Shucai via Digitalmars-d
I am doing research on segmented stack mechanisms, and in
addition to academic papers, I am surveying whether segmented
stack mechanism is still useful on 64-bit machines. On 64 bit
machines, why they don’t just use a big enough stack, for
example, 1GB or even larger? Are segmented stacks only useful
for 32 bit machines? Are there other reasons for segmented
stacks on 64 bit machines?
Any response is appreciated, thanks, Shucai
You might want to try asking the Go and Rust mailing lists since
they have a lot of experience with segmented stacks.

Rust abandoned them for a few reasons you can read about here[1].
The announcement specifically mentions they believe the MMU can
take care of the stack on 64-bits.

1.
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006314.html
via Digitalmars-d
2014-10-17 04:23:38 UTC
Permalink
Post by Brad Anderson via Digitalmars-d
You might want to try asking the Go and Rust mailing lists
since they have a lot of experience with segmented stacks.
But note that Go has a different problem since they want high
concurrency, so stacks have to stay small (and be able to
shrink). I believe they copy stacks and rewrite pointers
 (ugh)
Post by Brad Anderson via Digitalmars-d
Rust abandoned them for a few reasons you can read about
here[1]. The announcement specifically mentions they believe
the MMU can take care of the stack on 64-bits.
They don't have much of a choice since AMD64 does not provide a
segmented memory model.

Why they chose the flat model I cannot say, but I believe it has
to do with the x86 memory architecture and how 32-bit x86
implements segments as a separate layer from page tables with
segments pointing to address ranges rather than a page table
slot. If segment registers were more abstract (with no notion of
physical memory addresses) then it would make sense to have it
IMO.

Many-core probably make the 32-bit x86 model expensive to
implement with little gain, so the FS and GS registers have been
repurposed for other things instead.
thedeemon via Digitalmars-d
2014-10-17 05:46:21 UTC
Permalink
Post by Brad Anderson via Digitalmars-d
Post by Shucai via Digitalmars-d
I am doing research on segmented stack mechanisms, and in
addition to academic papers, I am surveying whether segmented
stack mechanism is still useful on 64-bit machines. On 64 bit
machines, why they don’t just use a big enough stack, for
example, 1GB or even larger? Are segmented stacks only useful
for 32 bit machines? Are there other reasons for segmented
stacks on 64 bit machines?
Any response is appreciated, thanks, Shucai
You might want to try asking the Go and Rust mailing lists
since they have a lot of experience with segmented stacks.
"Go 1.3 has changed the implementation of goroutine stacks away
from the old, "segmented" model to a contiguous model. When a
goroutine needs more stack than is available, its stack is
transferred to a larger single block of memory. "
https://golang.org/doc/go1.3

So I guess both of them abandoned segmented stacks.

Continue reading on narkive:
Loading...