Yes definitely helpful, although I'm still not quite sure if I'm doing this 
the right way. Perhaps it is worthwhile for me to give a little more 
context as to what I'm doing. Basically, I want to store a map of contexts 
to built in prototypes. The reason for this is that so far the best way 
I've found to get these built in prototypes is by doing the following:

Local<Array>::New(0)->GetPrototype() 
Local<String>::New(0)->GetPrototype()
...etc..

Since my JS code is calling into a function that needs these prototypes,I 
don't want to calculate them every time. So instead I do something along 
the lines of:

GetBuiltInsFor(args[0]->CreationContext())

GetBuiltinsFor has a map of persistent contexts to persistent saved 
prototypes, or if its not in there, then it does it and I only pay the cost 
once. As such, the first question is, "is there an easier way to get these 
prototypes without having to create objects like crazy" which would 
completely remove the need for this whole hashing business. But, short of 
that, is my Global()->IdentitifyHash strategy good for storing the 
contexts. If what I understand is correct, then at worst I will have to pay 
the cost an additional time if DetachGlobal() is called, which seems OK.

On Monday, May 11, 2015 at 4:37:23 AM UTC-7, Toon Verwaest wrote:
>
> You indeed need to be careful. Context->Global() changes semantics after 
> Context->DetachGlobal(). Until navigation it returns the global proxy, 
> afterwards it returns the internal global object for technical reasons... 
> (See 
> https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Split_object
>  
> for the diff between global proxy and global object).
>
> If you want a stable identity hash across iframe navigation, you have to 
> make sure you fetch it from the "global proxy" (correct for the iframe), 
> not the "global object" (correct for a specific page loaded in the iframe; 
> you don't have access to this until you navigate the context away).
>
> If you know the global proxy that was used for a specific context, or if 
> you know that you never detach the global (hence Global() always returns 
> the proxy), you can use that hash. That will obviously == the hash of other 
> pages loaded in the same iframe.
>
> HTH somewhat,
> Toon
>
> On Mon, May 11, 2015 at 11:44 AM Ben Noordhuis <[email protected] 
> <javascript:>> wrote:
>
>> On Sun, May 10, 2015 at 8:08 PM, Francisco Tolmasky <[email protected] 
>> <javascript:>> wrote:
>> > Contextsdon't appear to have a GetIdentityHash like Objects do. Is it 
>> safe
>> > to do Context->Global()->GetIdentityHash(). By that I suppose I mean, 
>> does
>> > Global ever change for a Context?
>>
>> You can detach the global object from the context with
>> v8::Context::DetachGlobal().  I'm not sure if that matters for the
>> identity hash but it might.
>>
>> --
>> --
>> v8-users mailing list
>> [email protected] <javascript:>
>> http://groups.google.com/group/v8-users
>> ---
>> You received this message because you are subscribed to the Google Groups 
>> "v8-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to