From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,984d3d7860d7c8c X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 01 Jun 2004 23:07:31 -0500 Date: Wed, 02 Jun 2004 00:07:30 -0400 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Where are returned values stored? References: <75s9b0pgo91ctvlm5op2rcql82t9ip4me2@4ax.com> <1dptc.49822$tb4.1731604@news20.bellglobal.com> <2hv1auFhi91aU1@uni-berlin.de> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.90.114 X-Trace: sv3-R69ZxlslUfdRpDPmA4+dGzpf2QXT6HRn8qZup/5nwpDjQ+/z051IN5l7C2l8RxIJppTlXA1php6nDSU!2k+hbp2DF+MiMDXYcOZ1tGVNSCeUDOv4TptJNDF5K90vHoY4J9IKVA8O+ghsQQ== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: controlnews3.google.com comp.lang.ada:1007 Date: 2004-06-02T00:07:30-04:00 List-Id: Warren W. Gay VE3WWG wrote: > A 2nd stack would mean fragmenting your memory space even > more, requiring a extra level of planning. Determining > stack requirements is always tricky when you have > subprograms that recurse. Otherwise static analysis would > be sufficient. You are thinking like an embedded programmer, and probably should be using SPARK. In a virtual memory environment, things are much different. I've lived in both worlds. If you make tasks "heavy" threads, with their own virtual address space, the number of stacks and their size is a non-issue. On compilers where tasks are lightweight (all share a single address space) you can't be quite so free with addresses. But it usually suffices to materialize a minimum return stack if per task if and when it is referenced, and leave it unallocated otherwise. Of course, if a function returns a huge number of bytes, you allocate the space from the heap, and put a descriptor on the return stack. The definitions of minimum return stack size and huge are of course compiler dependent. And of course it is a bit of a pain if you have to grow the return stack by copying. (The return stack can contain addresses, but references into locations in the return stack have to be offsets. That way you can copy it if needed to expand it.) But definitions like an 8 kByte startiing size and treating anything over 1 kByte as 'huge' work pretty well. This is a side-effect of the Ada culture. Although Ada allows returning huge objects, for any meaning of huge, from functions and allocating huge object in stack frames, it turns out that in practice most huge arrays get allocated in package specs or bodies. When we were creating the Ada/SIL compiler a lot of things were postponed until we actually ran into them. We went for months without deciding what to do when any stack exceeded 128 kBytes. Final decision? Raise Storage_Error. The few logged cases of running into this limit were all accidental indefinite recursion, or attempts to allocate a maximum size String (2**31-1 bytes) or other maximum size array. Alsys has/had, whatever the name is now for the French compiler, a limit of 8 kBytes that was pretty similar. If an object type had an indefinite size that could be greater than 8 k, it would go on the heap with a descriptor on the stack. It allowed them to support indefinite record types (records with discriminants that have defaults and composite components whose bounds depend on one or more discriminants, where the object is declared without a discriminant constraint). Alsys used the name mutant records, and it became associated with their method of managing such objects more than the object types themselves. It really would be handy if such records had a short meaningful name... -- Robert I. Eachus "The terrorists rejoice in the killing of the innocent, and have promised similar violence against Americans, against all free peoples, and against any Muslims who reject their ideology of murder. Their barbarism cannot be appeased, and their hatred cannot be satisfied. There's only one way to deal with terror: We must confront the enemy and stay on the offensive until these killers are defeated." -- George W. Bush