On revoking access to the target of a proxy

David Bruant bruant.d at gmail.com
Fri Aug 3 17:58:23 PDT 2012


Le 03/08/2012 19:54, Brendan Eich a écrit :
> David Bruant wrote:
>> So your actual target can be GC'ed, but the dummyTarget has to keep 
>> observed non-configurable (and non-writable) properties. Or you can 
>> give up non-configurability.
>> I don't find any of these solutions satisfactory.
>
> Please see Tom's post-meeting notes on the wiki:
>
> http://wiki.ecmascript.org/doku.php?id=harmony:direct_proxies#discussed_during_tc39_july_2012_meeting_microsoft_redmond
>
> specifically
>
> *trapping isSealed and friends
>
> *
>
> Unless I've misunderstood, this addresses your concern.
I don't see how it does. This part is mostly about non-extensibility 
while I'm worried about non-configurability of some properties of the 
dummy target (not all properties have to be).

Some code to describe my concern:

     var target = {};
     // create a proxy with a dummyTarget instead of the actual target
     var {ref, revoke} = makeCareTaker(target);
     Object.defineProperty(ref, 'a', {value: hugeString, conf: false, 
writ:false};
     ref.b = 2; // no need to copy to the dummyTarget, because there is 
no invariant to check.
     revoke();
     ref.a; // throws thanks to revokation, but the dummyTarget can't be 
GC'ed

The problem is that the handler.defineProperty call either has to throw 
(forbid creation of non-conf/non-writ props) or accept in which case, it 
has to copy the descriptor on the dummy target first (including the 
hugeString), because that's how invariant enforcement works.
After the revokation, the target is not accessible which is what we 
want, but the dummyTarget will stay in memory as long as the proxy does.

In the end, revokability can be implemented, but the nice GC property 
that should come along can only be implemented if the revokable proxy 
does not support invariant checking. Regardless, it still requires to 
delete all configurable properties of the dummy target on revokation, 
which may take some time.

As we've seen with the Hueyfix, having enabling GC thanks to revokation 
sometimes yields tremendously excellent results (whether the properties 
of the GC'ed objects are configurable or not, this should not matter). I 
think it justifies language-level revokability.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120803/6b666b57/attachment.html>


More information about the es-discuss mailing list