Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.mb-net.net!open-news-network.org!aioe.org!.POSTED!not-for-mail From: Walter Banks Newsgroups: comp.lang.forth Subject: Re: Metrics on stack usage Date: Tue, 16 Sep 2014 15:04:41 -0400 Organization: Aioe.org NNTP Server Lines: 40 Message-ID: <541889C9.C49DBB52@bytecraft.com> References: <541855C0.2558D27D@bytecraft.com> NNTP-Posting-Host: YoO9jN9ybQgjv0MfopP4oQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Mailer: Mozilla 4.79 [en]C-CCK-MCD NSCPCD479 (Windows NT 5.0; U) X-Accept-Language: en X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:33391 "Elizabeth D. Rather" wrote: > On 9/16/14 5:22 AM, Walter Banks wrote: > > I am working on a code generator for a stack processor. > > Who better to ask about real stack requirements than a forth group. > > > > The question is what is the expected stack requirements for a > > forth implementation? > > > > Is there any benchmark code that test stack usage? > > > As others have noted, this issue obviously depends a lot on both > application needs and programming style. We at FORTH, Inc. have done > studies from time to time. The easiest way is to write a pattern (e.g. > #DEADBEEF) all over the relevant region of memory when the program is > launched, and after it has run for a while, dump the stack area and see > where it has been overwritten. > > As I recall, our studies found that stacks rarely exceeded half a dozen > items, at however many bytes/cell that took. Obviously if you're doing a > lot of recursion or something like that it would be different. For non hosted embedded systems the upper limit seems to be 14 levels and around half dozen was typical. I don't know of many cases where deep recursive algorithms cannot be generated with some form of tail end recursion by a code generator with full application data flow information. I am tracking actual stack usage in a development simulator and probably will initialize the the actual hardware with as you suggest DEADBEEF Are there ways that stack depth can be traded for reduced execution time other than the savings of intermediate values in expression evaluation? w..