Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #19620

Re: Creating a new stack from an exisiting one.

From "Pascal J. Bourguignon" <pjb@informatimago.com>
Newsgroups comp.lang.java.programmer, comp.programming
Subject Re: Creating a new stack from an exisiting one.
Date 2012-11-04 14:41 +0100
Organization Informatimago
Message-ID <87mwyxlc39.fsf@informatimago.com> (permalink)
References (1 earlier) <0.73472d82415d5353822e.20121103155132GMT.87mwyyvg57.fsf@bsb.me.uk> <b227ba50-ccbc-4da0-9f6a-31bb809f329d@ah9g2000pbd.googlegroups.com> <0.898697c4e5f8819c7fa0.20121104004445GMT.878vaiurgi.fsf@bsb.me.uk> <87vcdllg3u.fsf@informatimago.com> <0.96b4857ea7d651ed53b3.20121104124839GMT.87txt5tty0.fsf@bsb.me.uk>

Cross-posted to 2 groups.

Show all headers | View raw


Ben Bacarisse <ben.usenet@bsb.me.uk> writes:

> "Pascal J. Bourguignon" <pjb@informatimago.com> writes:
> <snip>
>> Well, I don't know of any processor that uses a separate stack for the
>> frame pointers.
>
> No, me neither.  The description also lacked any mention of the return
> address so I don't think this is about hardware.  Maybe it's coursework,
> and the separate stacks are there to keep the concepts clear?  I don't
> know.

That said, in early Fortran and Pascal compilers, they used a "display
record" vector, which would point to the visible frames.  While such a
"display record" could be managed as a stack, static analysis allows
for a fixed size and direct updating.


So for example:

    function f (x:integer)
      function g (y:integer)
      begin
         if x>y then
            g:=x+y+f(x-y)-g(y+1)
         else
            g:=x+y;
      end;
    begin
      if x<0
         f:=1
      else
         f:=g(x-1)
    end;

while one could need an unbounded number of stack frames (depending on
the value of the parameters),  the invocations of the function g see
only the frame of one invocation of the function f, so we need a
"display record" of size 2.


          stack:
   -------------------
    stack frame for f
    stack frame for g
    stack frame for g
    stack frame for g
    stack frame for f
    stack frame for g
    stack frame for g
    stack frame for f <----+     display:
    stack frame for g      |     ---------
    stack frame for g      +------- f
    stack frame for g <------------ g

The display record is a kind of stack of lexical scopes.  If we get
outside of f, and enter another embedding of lexical scopes, another set
of stack frame pointers may be "stacked" into the display record.

-- 
__Pascal Bourguignon__
http://www.informatimago.com

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Creating a new stack from an exisiting one. Chad <cdalten@gmail.com> - 2012-11-03 07:45 -0700
  Re: Creating a new stack from an exisiting one. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-11-03 15:51 +0000
    Re: Creating a new stack from an exisiting one. Chad <cdalten@gmail.com> - 2012-11-03 09:22 -0700
      Re: Creating a new stack from an exisiting one. markspace <-@.> - 2012-11-03 11:20 -0700
      Re: Creating a new stack from an exisiting one. "BartC" <bc@freeuk.com> - 2012-11-03 18:58 +0000
      Re: Creating a new stack from an exisiting one. "Pascal J. Bourguignon" <pjb@informatimago.com> - 2012-11-04 00:49 +0100
      Re: Creating a new stack from an exisiting one. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-11-04 00:44 +0000
        Re: Creating a new stack from an exisiting one. "Pascal J. Bourguignon" <pjb@informatimago.com> - 2012-11-04 13:14 +0100
          Re: Creating a new stack from an exisiting one. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-11-04 12:48 +0000
            Re: Creating a new stack from an exisiting one. Thomas Richter <thor@math.tu-berlin.de> - 2012-11-04 14:14 +0100
              Re: Creating a new stack from an exisiting one. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-11-04 15:38 +0000
            Re: Creating a new stack from an exisiting one. "Pascal J. Bourguignon" <pjb@informatimago.com> - 2012-11-04 14:41 +0100
          Re: Creating a new stack from an exisiting one. "BartC" <bc@freeuk.com> - 2012-11-04 14:11 +0000
            Re: Creating a new stack from an exisiting one. "Pascal J. Bourguignon" <pjb@informatimago.com> - 2012-11-04 16:00 +0100
          Re: Creating a new stack from an exisiting one. markspace <-@.> - 2012-11-04 11:02 -0800
          Re: Creating a new stack from an exisiting one. Martin Gregorie <martin@address-in-sig.invalid> - 2012-11-04 19:56 +0000
    Re: Creating a new stack from an exisiting one. Jeff Higgins <jeff@invalid.invalid> - 2012-11-03 16:46 -0400
      Re: Creating a new stack from an exisiting one. Jeff Higgins <jeff@invalid.invalid> - 2012-11-04 08:22 -0500
        Re: Creating a new stack from an exisiting one. Jeff Higgins <jeff@invalid.invalid> - 2012-11-04 11:30 -0500
          Re: Creating a new stack from an exisiting one. Jeff Higgins <jeff@invalid.invalid> - 2012-11-04 19:40 -0500
  Re: Creating a new stack from an exisiting one. Lew <lewbloch@gmail.com> - 2012-11-03 16:02 -0700

csiph-web