Making "super" work outside a literal?
oliver at apple.com
Tue Jun 21 11:33:05 PDT 2011
I'm answering some of the performance questions in this, but i don't know what the intended semantics of 'dynamic super' would be so I can't give specific details of most of the use cases. If it's essentially sugar for super.foo => Object.getPrototypeOf(this).foo (with appropriate munging for calls, etc) then the cost is at point of use only, but if it's anything more fun (there are references to additional implicit parameters below which would be fairly bad for performance of calls)
On Jun 21, 2011, at 11:04 AM, Sean Eagan wrote:
> I disagree that a dynamic super would lead to a '50% increase in
> argument passing overhead, on average'. First, there is the implicit
> 'arguments' argument, which is an object that actually needs to be
> created per call site, not just a binding, and thus is presumably much
> more expensive.
Nope, creating an arguments object is on average free, as most uses can be lowered.
> Second, 'argument passing overhead' involves sunk
> costs that are not dependent on the number of argument bindings that
> need to be created.
Every additional argument has a performance cost
> Third, implicit arguments, as 'super' would be,
> should be less costly than explicit arguments since the argument value
> does not need to be resolved.
I haven't really been following this but why does super need to be passed as an additional parameter?
> A better estimate of the overhead of dynamic super would probably be
> the overhead of an implicit 'this' binding, i.e. the cost of creating
> a 'this' binding for a function activation that not involving an
> explicit 'this' via Function.prototype.call or
> Function.prototype.apply, or Function.prototype.bind. Does anyone
> have any estimates of this cost, either absolute or relative to some
> other cost?
That depends on the exact use case. JSC doesn't determine what |this| is at the callsite (In general strict mode makes that impossible), so it becomes a question of whether you use it or not.
> I was unaware that dynamic super had been discussed, proposed, or
> attempted previously for ES, or that it was ever included to have
> 'pervasive overhead'. Do you any references for this?
No idea -- it would depend on what the actual semantics of super were
More information about the es-discuss