Steve Fink wrote:
On Mon 29 Jul 2013 10:43:27 AM PDT, Brendan Eich wrote:
BTW destructuring plus array return should be optimized to erase the
allocation and use the stack instead. E.g.,

   function pair(a, b) { return [a, b]; }
   let [x, y] = pair(z, w);

should not allocate a fresh array in pair. Anyone know whether there's
a bug asking for this?

I don't know of a bug, but then, I wouldn't. (I don't even know that we
don't already do this.)

This is what I was referring to when I said it would require inlining,
though. And in my case, the pair() function does a bunch of
computation, including several loops, before returning (or yielding).
Which probably means it won't be considered for inlining.

Unless you're thinking of a more general optimization?


If the function builds up a big array with random logic, then you need an allocation. That wasn't what you wrote:

Le 28/07/2013 08:53, Steve Fink a écrit :
* using an array for a tuple feels heavyweight. |return [a,b]|. Compare
with Python's tuples or Perl's multiple return values.

OTOH, inlining is not required. Lars Thomas Hansen years ago talked about optimizing Scheme implementations (Larceny? Not sure), where the callee looks at its continuation and avoids the allocation collaboratively -- some kind of call PIC deal without the inlining being mandatory. Jim Blandy may know more ;-).

/be
_______________________________________________
dev-tech-js-engine-internals mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to