9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Bakul Shah <bakul+plan9@bitblocks.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] Itanium
Date: Mon, 12 Jan 2009 08:29:12 -0800	[thread overview]
Message-ID: <20090112162912.6E4BA5B1A@mail.bitblocks.com> (raw)
In-Reply-To: Your message of "Mon, 12 Jan 2009 10:36:37 EST." <5e6fbf273a941c5f8a3508496ab153b9@quanstro.net>

On Mon, 12 Jan 2009 10:36:37 EST erik quanstrom <quanstro@quanstro.net>  wrote:
> how do you get around the fact that the parallelism
> is limited by the instruction set and the fact that one
> slow sub-instruction could stall the whole instruction?
>
> > The hardware also has built-in support for closures.  Every function
> > executed is implicitly paired with a given local memory region.
>
> what's the difference between this and stack?

Consider this:

(define (counter n)
  (lambda () (set! n (+1 n)) n))

In C like syntax:

(int(*)()) counter(int n) {
	int foo() { return ++n;}
	return foo;
}

...
	int(*c1)() = counter(5);
	int(*c2)() = counter(2);

	int x = c1(); // x is 6
	x += c2(); // x is 6+3
	x += c2(); // x is 9+4

n lives past the lifetime of counter so a stack is not
enough.  So for the returned function from counter(), you
have to allocate n on the heap.  And you need to store ptr
to this space along with the returned function (e.g. c1 has
its own local store, so does c2).

However, in general what Itanium does is not a win since in
practice most functions do not need local storage (even if
written in a language richer than C!).

Such a ptr to the local store associated with a function ptr
can be used to implement objects -- ptrs of all "methods" to
the same object point to the same storage.  Not sure if
anyone has implemented objects this way.



  reply	other threads:[~2009-01-12 16:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-05 16:33 Benjamin Huntsman
2009-01-06  5:38 ` ron minnich
2009-01-08 10:05 ` Christopher
2009-01-08 13:55   ` erik quanstrom
2009-01-08 17:09     ` geoff
2009-01-08 18:14       ` Bakul Shah
2009-01-12 15:04   ` Christopher
2009-01-12 15:36     ` erik quanstrom
2009-01-12 16:29       ` Bakul Shah [this message]
2009-01-14 10:04       ` Christopher
2009-01-14 10:04     ` Christopher
2009-01-14 10:54       ` erik quanstrom
  -- strict thread matches above, loose matches on Subject: below --
2005-01-23 21:50 Ben Huntsman
2005-01-23 23:56 ` geoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090112162912.6E4BA5B1A@mail.bitblocks.com \
    --to=bakul+plan9@bitblocks.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).