Segmented stack
Chris Williams via Digitalmars-d
digitalmars-d at puremagic.com
Fri Oct 17 16:42:16 PDT 2014
On Thursday, 16 October 2014 at 19:46:42 UTC, Shucai wrote:
> 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
While the implementation isn't guaranteed, I think that Java
mandates that the VM behave like every function receives a fresh
stack. I imagine that the advantage of this was that it allows
the VM to supply only the minimal necessary memory for a function
to operate, at any given time. On small devices, it can swap the
stack out to disk. On large devices, it can just keep everything
in memory. Optimization for size/speed is handled for you, making
your code more portable. (Theoretically.)
Another possibility is that, while I can't think of the
application, being able to preserve discarded chunks of the stack
might be useful in some way. In a traditional stack arrangement,
a new function entry will generally cause the data from the
previous function entry to be overwritten. If you're allocating
each new entry as its own thing, then all of the old functions
continue to sit around to be processed by another thread, until
you're ready to completely get rid of them.
More information about the Digitalmars-d
mailing list