Re: [v8-users] Re: Per-isolate FunctionTemplate cache

2016-11-22 Thread Toon Verwaest
If you do FunctionTemplate::New you get a caching template. With caching I
mean: every time you instantiate the template in the same native context,
you'll get the same function out. This is just how it's supposed to work
for Blink. This cache keeps the function strongly since even if objects
holding functions may disappear temporarily, the identity of the functions
needs to be preserved.

For your case it seems like you could just do Function::New, which
internally generates a non-caching template. That way there won't be a
strong reference from the cache.

I hope this helps,
Toon

On Mon, Nov 21, 2016 at 7:12 PM  wrote:

> Here's what Jochen originally said:
>
> v8 has an per-isolate cache of function templates. As the string is
> referenced by the function template, it will never go out of scope.
> I'd recommend to create a weak handle to the function you create via
> GetFunction() instead
>
>
> https://groups.google.com/d/msg/v8-users/Rshbi2HKYCM/LgwY-iJeAQAJ
>
> He later clarified "the function template won't ever get gc'd after you've
> instantiated it once."
>
> What I really want to know is why this is the case, and what purpose it
> serves.
>
> ~Theodore
>
> On Sunday, November 20, 2016 at 2:09:38 PM UTC-8, tbl...@icloud.com wrote:
>
> Jochen Eisinger said that "v8 has an per-isolate cache of function
> templates". I have a few questions about this cache:
>
> If I create multiple FunctionTemplates with different callback data but
> the same callback function and everything else, does it only create one
> function template and use the cache for the rest?
> If not, why does the cache exist?
>
> ~Theodore
>
> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> 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 v8-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Re: Per-isolate FunctionTemplate cache

2016-11-21 Thread tblodt
Here's what Jochen originally said:

v8 has an per-isolate cache of function templates. As the string is 
> referenced by the function template, it will never go out of scope.
> I'd recommend to create a weak handle to the function you create via 
> GetFunction() instead


https://groups.google.com/d/msg/v8-users/Rshbi2HKYCM/LgwY-iJeAQAJ

He later clarified "the function template won't ever get gc'd after you've 
instantiated it once."

What I really want to know is why this is the case, and what purpose it 
serves.

~Theodore

On Sunday, November 20, 2016 at 2:09:38 PM UTC-8, tbl...@icloud.com wrote:
>
> Jochen Eisinger said that "v8 has an per-isolate cache of function 
> templates". I have a few questions about this cache:
>
> If I create multiple FunctionTemplates with different callback data but 
> the same callback function and everything else, does it only create one 
> function template and use the cache for the rest?
> If not, why does the cache exist?
>
> ~Theodore
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.