Making "super" work outside a literal?

Brendan Eich brendan at mozilla.com
Thu Jun 23 15:12:39 PDT 2011


On Jun 23, 2011, at 12:07 PM, Axel Rauschmayer wrote:

>>> I believe you about the dynamic super. I can summarize my question as follows:
>>> - Making "super" or "current object" available to a function incurs costs.
>> 
>> These are two separate costs. You didn't define which 'super' but from context I'll assume static. That's a function-creation-time internal property setting cost.
>> 
>> If by "current object" you mean |here|, please use that term for clarity's sake. That has a per-call cost: an extra implicit parameter. We've been over this about five times.
> 
> Yes, I’m not questioning, just repeating and agreeing. And comparing the cost of |here| to the cost |thisFunction|.

Oh, you meant the callee (the called function)? The "current object" phrase threw me.


>>> - Making "current function" available to a function does not incur costs? This is *not* an extra parameter, then?
>> 
>> Do you mean "current object", aka |here|?
>> 
>> If so, that's an extra parameter.
>> 
>> If not, I don't know what you mean.
> 
> Static super can only be accessed if you have a reference |thisFunction| to the function that is currently executed. I would think that  |thisFunction| would also incur costs, but Allen has since said that these costs are negligible.

The called function is part of the evaluation results needed to call the function. It is indeed passed on the stack in naive stack-based implementations, to support reflection (e.g. arguments usage by the callee; again remember the caller in general does not know whether the callee uses arguments, debugger, etc.), and debugging (kind of hyper-reflection).

In a JIT, the calling convention can use registers and avoid writing to memory more than the minimum needed based on whatever analysis the JIT can support.

In any event, there's no extra parameter beyond the situation in today's engines. With dynamic 'super', there is.


> Related topic: How would |super| be handled if |this| is lexical?

There's no connection, AFAIK. But we also don't have a lexical-this proposal in Harmony yet.

/be


More information about the es-discuss mailing list